Re: [tip:x86/asm] x86/dumpstack: Pin the target stack when dumping it

From: Josh Poimboeuf
Date: Fri Sep 16 2016 - 07:56:12 EST


On Fri, Sep 16, 2016 at 02:17:46AM -0700, tip-bot for Andy Lutomirski wrote:
> Commit-ID: 1959a60182f48879635812a03a99c02231ea8677
> Gitweb: http://git.kernel.org/tip/1959a60182f48879635812a03a99c02231ea8677
> Author: Andy Lutomirski <luto@xxxxxxxxxx>
> AuthorDate: Thu, 15 Sep 2016 22:45:45 -0700
> Committer: Ingo Molnar <mingo@xxxxxxxxxx>
> CommitDate: Fri, 16 Sep 2016 09:18:53 +0200
>
> x86/dumpstack: Pin the target stack when dumping it
>
> Specifically, pin the stack in save_stack_trace_tsk() and
> show_trace_log_lvl().
>
> This will prevent a crash if the target task dies before or while
> dumping its stack once we start freeing task stacks early.

This causes a hang:

# echo 1 > /proc/sys/kernel/sysrq
# echo l > /proc/sysrq-trigger
[ 26.553593] sysrq: SysRq : Show backtrace of all active CPUs
[ 26.554130] Sending NMI to all CPUs:
[ 26.554521] BAD LUCK: lost 2225 message(s) from NMI context!
[ 26.554521] NMI backtrace for cpu 0
[ 26.554521] CPU: 0 PID: 783 Comm: bash Not tainted 4.8.0-rc6+ #3
[ 26.554522] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.1-1.fc24 04/01/2014
[ 26.554522] task: ffff880074fbd480 task.stack: ffffc90000bcc000
[ 26.554522] RIP: 0010:[<ffffffff81071526>] [<ffffffff81071526>] native_write_msr+0x6/0x30
[ 26.554523] RSP: 0018:ffffc90000bcfd18 EFLAGS: 00000046
[ 26.554523] RAX: 0000000000000400 RBX: ffffffff81f83b20 RCX: 0000000000000830
[ 26.554523] RDX: 0000000000000000 RSI: 0000000000000400 RDI: 0000000000000830
[ 26.554523] RBP: ffffc90000bcfd20 R08: ffffffffffffffff R09: 0000000000000003
[ 26.554524] R10: ffffffff81e5d1a0 R11: 0000000000000001 R12: 0000000000080000
[ 26.554524] R13: 0000000000000000 R14: 000000000000a13c R15: 0000000000000000
[ 26.554524] FS: 00007f0c7b8a2700(0000) GS:ffff88007d200000(0000) knlGS:0000000000000000
[ 26.554525] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 26.554525] CR2: 00007f0c7b8a7000 CR3: 0000000074fff000 CR4: 00000000001406f0
[ 26.554525] Stack:
[ 26.554525] BUG: unable to handle kernel paging request at 00000000000025d0
[ 26.554526] IP: [<ffffffff81039ba8>] show_stack_log_lvl+0x28/0x240
[ 26.554526] PGD 718d3067 PUD 718d2067 PMD 0
[ 26.554526] Oops: 0000 [#1] PREEMPT SMP
[ 26.554527] Modules linked in: ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 xt_conntrack cfg80211 rfkill ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack snd_hda_codec_generic iptable_mangle iptable_security iptable_raw ppdev crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel snd_hda_intel snd_hda_codec serio_raw snd_hwdep snd_hda_core virtio_console virtio_balloon snd_pcm snd_timer snd virtio_net soundcore i2c_piix4 parport_pc parport virtio_blk ata_generic qxl drm_kms_helper ttm pata_acpi drm virtio_pci virtio_ring virtio
[ 26.554528] CPU: 0 PID: 783 Comm: bash Not tainted 4.8.0-rc6+ #3
[ 26.554528] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.1-1.fc24 04/01/2014
[ 26.554528] task: ffff880074fbd480 task.stack: ffffc90000bcc000
[ 26.554528] RIP: 0010:[<ffffffff81039ba8>] [<ffffffff81039ba8>] show_stack_log_lvl+0x28/0x240
[ 26.554529] RSP: 0018:ffff88007d205d40 EFLAGS: 00010046
[ 26.554529] RAX: 0000000000000000 RBX: ffff88007d205ef8 RCX: 0000000000000000
[ 26.554529] RDX: 0000000000000000 RSI: ffff88007d205ef8 RDI: 0000000000000000
[ 26.554530] RBP: ffff88007d205d98 R08: ffffffff81c35ef4 R09: 0000000000000005
[ 26.554530] R10: ffff880074fbd480 R11: ffff88007d3ce637 R12: ffffffff81071501
[ 26.554530] R13: ffff88007d205ef8 R14: 000000062ec39e9f R15: ffff88007d205ef8
[ 26.554530] FS: 00007f0c7b8a2700(0000) GS:ffff88007d200000(0000) knlGS:0000000000000000
[ 26.554531] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 26.554531] CR2: 00000000000025d0 CR3: 0000000074fff000 CR4: 00000000001406f0
[ 26.554531] Stack:
[ 26.554531] BUG: unable to handle kernel paging request at 00000000000025d0
[ 26.554532] IP: [<ffffffff81039ba8>] show_stack_log_lvl+0x28/0x240
[ 26.554532] PGD 718d3067 PUD 718d2067 PMD 0
[ 26.554532] Oops: 0000 [#2] PREEMPT SMP
[ 26.554533] Modules linked in: ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 xt_conntrack cfg80211 rfkill ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack snd_hda_codec_generic iptable_mangle iptable_security iptable_raw ppdev crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel snd_hda_intel snd_hda_codec serio_raw snd_hwdep snd_hda_core virtio_console virtio_balloon snd_pcm snd_timer snd virtio_net soundcore i2c_piix4 parport_pc parport virtio_blk ata_generic qxl drm_kms_helper ttm pata_acpi drm virtio_pci virtio_ring virtio
[ 26.554533] CPU: 0 PID: 783 Comm: bash Not tainted 4.8.0-rc6+ #3
[ 26.554534] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.1-1.fc24 04/01/2014
[ 26.554534] task: ffff880074fbd480 task.stack: ffffc90000bcc000
[ 26.554534] RIP: 0010:[<ffffffff81039ba8>] [<ffffffff81039ba8>] show_stack_log_lvl+0x28/0x240
[ 26.554535] RSP: 0018:ffff88007d205a28 EFLAGS: 00010046
[ 26.554535] RAX: 0000000000000000 RBX: ffff88007d205c98 RCX: 0000000000000000
[ 26.554535] RDX: 0000000000000000 RSI: ffff88007d205c98 RDI: 0000000000000000
[ 26.554535] RBP: ffff88007d205a80 R08: ffffffff81c35ef4 R09: 0000000000000005
[ 26.554536] R10: ffff880074fbd480 R11: ffff88007d3ced4e R12: 0000000000000000
[ 26.554536] R13: ffff88007d205c98 R14: 0000000000000000 R15: ffff88007d205c98
[ 26.554536] FS: 00007f0c7b8a2700(0000) GS:ffff88007d200000(0000) knlGS:0000000000000000
[ 26.554536] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 26.554537] CR2: 00000000000025d0 CR3: 0000000074fff000 CR4: 00000000001406f0
[ 26.554537] Stack:
[ 26.554537] BUG: unable to handle kernel paging request at 00000000000025d0
[ 26.554537] IP: [<ffffffff81039ba8>] show_stack_log_lvl+0x28/0x240
[ 26.554538] PGD 718d3067 PUD 718d2067 PMD 0
[ 26.554538] Oops: 0000 [#3] PREEMPT SMP
[ 26.554539] Modules linked in: ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 xt_conntrack cfg80211 rfkill ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack snd_hda_codec_generic iptable_mangle iptable_security iptable_raw ppdev crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel snd_hda_intel snd_hda_codec serio_raw snd_hwdep snd_hda_core virtio_console virtio_balloon snd_pcm snd_timer snd virtio_net soundcore i2c_piix4 parport_pc parport virtio_blk ata_generic qxl drm_kms_helper ttm pata_acpi drm virtio_pci virtio_ring virtio
[ 26.554539] CPU: 0 PID: 783 Comm: bash Not tainted 4.8.0-rc6+ #3
[ 26.554539] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.1-1.fc24 04/01/2014
[ 26.554540] task: ffff880074fbd480 task.stack: ffffc90000bcc000
[ 26.554540] RIP: 0010:[<ffffffff81039ba8>] [<ffffffff81039ba8>] show_stack_log_lvl+0x28/0x240
[ 26.554540] RSP: 0018:ffff88007d205708 EFLAGS: 00010046
[ 26.554540] RAX: 0000000000000000 RBX: ffff88007d205978 RCX: 0000000000000000
[ 26.554541] RDX: 0000000000000000 RSI: ffff88007d205978 RDI: 0000000000000000
[ 26.554541] RBP: ffff88007d205760 R08: ffffffff81c35ef4 R09: 0000000000000005
[ 26.554541] R10: ffff880074fbd480 R11: ffff88007d3cf465 R12: 0000000000000000
[ 26.554542] R13: ffff88007d205978 R14: 0000000000000000 R15: ffff88007d205978
[ 26.554542] FS: 00007f0c7b8a2700(0000) GS:ffff88007d200000(0000) knlGS:0000000000000000
[ 26.554542] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 26.554542] CR2: 00000000000025d0 CR3: 0000000074fff000 CR4: 00000000001406f0
[ 26.554542] Stack:
[ 26.554543] BUG: unable to handle kernel paging request at 00000000000025d0
[ 26.554543] IP: [<ffffffff81039ba8>] show_stack_log_lvl+0x28/0x240
[ 26.554543] PGD 718d3067 PUD 718d2067 PMD 0
[ 26.554543] Oops: 0000 [#4] PREEMPT SMP
[ 26.554545] Modules linked in: ip6t_rpfilter ip6t_REJECT nf_reject_ipv6 xt_conntrack cfg80211 rfkill ebtable_nat ebtable_broute bridge stp llc ebtable_filter ebtables ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 ip6table_mangle ip6table_security ip6table_raw ip6table_filter ip6_tables iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack snd_hda_codec_generic iptable_mangle iptable_security iptable_raw ppdev crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel snd_hda_intel snd_hda_codec serio_raw snd_hwdep snd_hda_core virtio_console virtio_balloon snd_pcm snd_timer snd virtio_net soundcore i2c_piix4 parport_pc parport virtio_blk ata_generic qxl drm_kms_helper ttm pata_acpi drm virtio_pci virtio_ring virtio
[ 26.554545] CPU: 0 PID: 783 Comm: bash Not tainted 4.8.0-rc6+ #3
[ 26.554545] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.9.1-1.fc24 04/01/2014
[ 26.554545] task: ffff880074fbd480 task.stack: ffffc90000bcc000
[ 26.554546] RIP: 0010:[<ffffffff81039ba8>] [<ffffffff81039ba8>] show_stack_log_lvl+0x28/0x240
[ 26.554546] RSP: 0018:ffff88007d2053e8 EFLAGS: 00010046
[ 26.554546] RAX: 0000000000000000 RBX: ffff88007d205658 RCX: 0000000000000000
[ 26.554546] RDX: 0000000000000000 RSI: ffff88007d205658 RDI: 0000000000000000
[ 26.554547] RBP: ffff88007d205440 R08: ffffffff81c35ef4 R09: 0000000000000005
[ 26.554547] R10: ffff880074fbd480 R11: ffff88007d3cfb7c R12: 0000000000000000
[ 26.554547] R13: ffff88007d205658 R14: 0000000000000000 R15: ffff88007d205658
[ 26.554547] FS: 00007f0c7b8a2700(0000) GS:ffff88007d200000(0000) knlGS:0000000000000000
[ 26.554548] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 26.554548] CR2: 00000000000025d0 CR3: 0000000074fff000 CR4: 00000000001406f0
[ 26.554548] Stack:
[ 26.554549] BUG:
[ 26.554632] Kernel Offset: disabled


--
Josh