From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753070AbbDAJiV (ORCPT ); Wed, 1 Apr 2015 05:38:21 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:15169 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752961AbbDAJiO (ORCPT ); Wed, 1 Apr 2015 05:38:14 -0400 Message-ID: <551BBB6B.5090307@huawei.com> Date: Wed, 1 Apr 2015 17:33:31 +0800 From: Xishi Qiu User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Dave Young CC: , , , , , , , Tang Chen Subject: Re: [PATCH] x86/numa: kernel stack corruption fix References: <20150401045346.GA3461@dhcp-16-198.nay.redhat.com> <20150401051133.GC8680@dhcp-128-53.nay.redhat.com> <551B9DD7.5010603@huawei.com> <20150401074120.GF8680@dhcp-128-53.nay.redhat.com> <551BAA6D.30104@huawei.com> <551BADAE.4080404@huawei.com> <20150401091738.GI8680@dhcp-128-53.nay.redhat.com> In-Reply-To: <20150401091738.GI8680@dhcp-128-53.nay.redhat.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.25.179] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015/4/1 17:17, Dave Young wrote: > On 04/01/15 at 04:34pm, Xishi Qiu wrote: >> On 2015/4/1 16:21, Xishi Qiu wrote: >> >>> On 2015/4/1 15:41, Dave Young wrote: >>> >>>> On 04/01/15 at 03:27pm, Xishi Qiu wrote: >>>>> On 2015/4/1 13:11, Dave Young wrote: >>>>> >>>>>> Ccing Xishi Qiu who wrote the clear_kernel_node_hotplug code. >>>>>> >>>>>> On 04/01/15 at 12:53pm, Dave Young wrote: >>>>>>> I got below kernel panic during kdump test on Thinkpad T420 laptop: >>>>>>> >>>>>>> [ 0.000000] No NUMA configuration found >>>>>>> [ 0.000000] Faking a node at [mem 0x0000000000000000-0x0000000037ba4fff] >>>>>>> [ 0.000000] Kernel panic - not syncing: stack-protector: Kernel stack is cor >>>>>>> upted in: ffffffff81d21910 r >>>>>>> [ 0.000000] >>>>>>> [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.0.0-rc6+ #44 >>>>>>> [ 0.000000] Hardware name: LENOVO 4236NUC/4236NUC, BIOS 83ET76WW (1.46 ) 07/ >>>>>>> 5/2013 0 >>>>>>> [ 0.000000] 0000000000000000 c70296ddd809e4f6 ffffffff81b67ce8 ffffffff817c >>>>>>> a26 2 >>>>>>> [ 0.000000] 0000000000000000 ffffffff81a61c90 ffffffff81b67d68 ffffffff817b >>>>>>> 8d2 c >>>>>>> [ 0.000000] 0000000000000010 ffffffff81b67d78 ffffffff81b67d18 c70296ddd809 >>>>>>> 4f6 e >>>>>>> [ 0.000000] Call Trace: >>>>>>> [ 0.000000] [] dump_stack+0x45/0x57 >>>>>>> [ 0.000000] [] panic+0xd0/0x204 >>>>>>> [ 0.000000] [] ? numa_clear_kernel_node_hotplug+0xe6/0xf2 >>>>>>> [ 0.000000] [] __stack_chk_fail+0x1b/0x20 >>>>>>> [ 0.000000] [] numa_clear_kernel_node_hotplug+0xe6/0xf2 >>>>>>> [ 0.000000] [] numa_init+0x1a5/0x520 >>>>>>> [ 0.000000] [] x86_numa_init+0x19/0x3d >>>>>>> [ 0.000000] [] initmem_init+0x9/0xb >>>>>>> [ 0.000000] [] setup_arch+0x94f/0xc82 >>>>>>> [ 0.000000] [] ? early_idt_handlers+0x120/0x120 >>>>>>> [ 0.000000] [] ? printk+0x55/0x6b >>>>>>> [ 0.000000] [] ? early_idt_handlers+0x120/0x120 >>>>>>> [ 0.000000] [] start_kernel+0xe8/0x4d6 >>>>>>> [ 0.000000] [] ? early_idt_handlers+0x120/0x120 >>>>>>> [ 0.000000] [] ? early_idt_handlers+0x120/0x120 >>>>>>> [ 0.000000] [] x86_64_start_reservations+0x2a/0x2c >>>>>>> [ 0.000000] [] x86_64_start_kernel+0x161/0x184 >>>>>>> [ 0.000000] ---[ end Kernel panic - not syncing: stack-protector: Kernel sta >>>>>>> k is corrupted in: ffffffff81d21910 c >>>>>>> [ 0.000000] >>>>>>> PANIC: early exception 0d rip 10:ffffffff8105d2a6 error 7eb cr2 ffff8800371dd00 >>>>>>> [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.0.0-rc6+ #44 0 >>>>>>> [ 0.000000] Hardware name: LENOVO 4236NUC/4236NUC, BIOS 83ET76WW (1.46 ) 07/ >>>>>>> 5/2013 0 >>>>>>> [ 0.000000] 0000000000000000 c70296ddd809e4f6 ffffffff81b67c60 ffffffff817c >>>>>>> a26 2 >>>>>>> [ 0.000000] 0000000000000096 ffffffff81a61c90 ffffffff81b67d68 fffffff00000 >>>>>>> 084 0000000000000a0d 0000000000000a00 0 >>>>>>> [ 0.000000] Call Trace: >>>>>>> [ 0.000000] [] dump_stack+0x45/0x57 >>>>>>> [ 0.000000] [] early_idt_handler+0x90/0xb7 >>>>>>> [ 0.000000] [] ? native_irq_enable+0x6/0x10 >>>>>>> [ 0.000000] [] ? panic+0x1c3/0x204 >>>>>>> [ 0.000000] [] ? numa_clear_kernel_node_hotplug+0xe6/0xf2 >>>>>>> [ 0.000000] [] __stack_chk_fail+0x1b/0x20 >>>>>>> [ 0.000000] [] numa_clear_kernel_node_hotplug+0xe6/0xf2 >>>>>>> [ 0.000000] [] numa_init+0x1a5/0x520 >>>>>>> [ 0.000000] [] x86_numa_init+0x19/0x3d >>>>>>> [ 0.000000] [] initmem_init+0x9/0xb >>>>>>> [ 0.000000] [] setup_arch+0x94f/0xc82 >>>>>>> [ 0.000000] [] ? early_idt_handlers+0x120/0x120 >>>>>>> [ 0.000000] [] ? printk+0x55/0x6b >>>>>>> [ 0.000000] [] ? early_idt_handlers+0x120/0x120 >>>>>>> [ 0.000000] [] start_kernel+0xe8/0x4d6 >>>>>>> [ 0.000000] [] ? early_idt_handlers+0x120/0x120 >>>>>>> [ 0.000000] [] ? early_idt_handlers+0x120/0x120 >>>>>>> [ 0.000000] [] x86_64_start_reservations+0x2a/0x2c >>>>>>> [ 0.000000] [] x86_64_start_kernel+0x161/0x184 >>>>>>> [ 0.000000] RIP 0x46 >>>>>>> >>>>>>> This is caused by writing over end of numa mask bitmap. >>>>>>> >>>>>>> numa_clear_kernel_node try to set node id in a mask bitmap, it iterating all >>>>>>> reserved region and assume every regions have valid nid. It is not true because >>>>>>> There's an exception for graphic memory quirks. see function trim_snb_memory >>>>>>> in arch/x86/kernel/setup.c >>>>>>> >>>>>>> It is easily to reproduce the bug in kdump kernel because kdump kernel use >>>>>>> prereserved memory instead of whole memory, but kexec pass other reserved memory >>>>>>> ranges to 2nd kernel as well. like below in my test: >>>>>>> kdump kernel ram 0x2d000000 - 0x37bfffff >>>>>>> One of the reserved regions: 0x40000000 - 0x40100000 >>>>>>> >>>>>>> The above reserved region includes 0x40004000, a page excluded in >>>>>>> trim_snb_memory. For this memblock reserved region the nid is not set it is >>>>>>> still default value MAX_NUMNODES. later node_set callback will set bit >>>>>>> MAX_NUMNODES in nodemask bitmap thus stack corruption happen. >>>>>>> >>>>> >>>>> Hi Dave, >>>>> >>>>> Is it means, first reserved region 0x40000000 - 0x40100000, then boot the kdump >>>>> kernel, so this region is not include in "numa_meminfo", and memblock.reserved >>>>> (0x40004000) is still MAX_NUMNODES from trim_snb_memory(). >>>> >>>> Right, btw, I booted kdump kernel with numa=off for saving memory. >>>> >>>> I suspect it will also be reproduced with mem=XYZ with normal kernel. >>>> >>> >>> cc Tang Chen, numa_clear_kernel_node_hotplug() is original written by him. >>> >>> Hi Dave, >>> I tested the problem, and find the kdump's "numa_meminfo" is the same as the first >>> kernel. I did not set "numa=off" in kdump kernel, maybe this will lead to the >>> difference of "numa_meminfo" >>> >> >> Hi Dave, >> >> I find the reason, it's "dummy_numa_init() -> numa_add_memblk(0, 0, PFN_PHYS(max_pfn));", >> this lead to the difference of "numa_meminfo" when set "numa=off". >> >> However we should fix the bug when set "numa=off". > > So do you means MAXPFN should include non system ram region at the end? > No, I means when set "numa=off", numa_meminfo comes from max_pfn, this makes the difference. and max_pfn is come from e820, not SRAT tables. if no "numa=off", SRAT tables will fill the numa_meminfo. Thanks, Xishi Qiu > The case like below, I believe max_pfn is set to the end of system ram currently: > [what ever] [ system ram ] [ bios reserved region ] > > Thanks > Dave > > . >