mm/memory_hotplug: refrain from adding memory into an impossible node
A misbehaving qemu created a situation where the ACPI SRAT table
advertised one fewer proximity domains than intended. The NFIT table did
describe all the expected proximity domains. This caused the device dax
driver to assign an impossible target_node to the device, and when
hotplugged as system memory, this would fail with the following signature:
BUG: kernel NULL pointer dereference, address:
0000000000000088
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD
80000001767d4067 P4D
80000001767d4067 PUD
10e0c4067 PMD 0
Oops: 0000 [#1] SMP PTI
CPU: 4 PID: 22737 Comm: kswapd3 Tainted: G O 5.6.0-rc5 #9
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
RIP: 0010:prepare_kswapd_sleep+0x7c/0xc0
Code: 89 df e8 87 fd ff ff 89 c2 31 c0 84 d2 74 e6 0f 1f 44 00 00 48 8b 05 fb af 7a 01 48 63 93 88 1d 01 00 48 8b 84 d0 20 0f 00 00 <48> 3b 98 88 00 00 00 75 28 f0 80 a0 80 00 00 00 fe f0 80 a3 38 20
RSP: 0018:
ffffc900017a3e78 EFLAGS:
00010202
RAX:
0000000000000000 RBX:
ffff8881209e0000 RCX:
0000000000000000
RDX:
0000000000000003 RSI:
0000000000000000 RDI:
ffff8881209e0e80
RBP:
0000000000000000 R08:
0000000000000000 R09:
0000000000008000
R10:
0000000000000000 R11:
0000000000000003 R12:
0000000000000003
R13:
0000000000000003 R14:
0000000000000000 R15:
ffffc900017a3ec8
FS:
0000000000000000(0000) GS:
ffff888318c00000(0000) knlGS:
0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0:
0000000080050033
CR2:
0000000000000088 CR3:
0000000120b50002 CR4:
00000000001606e0
Call Trace:
kswapd+0x103/0x520
kthread+0x120/0x140
ret_from_fork+0x3a/0x50
Add a check in the add_memory path to fail if the node to which we are
adding memory is in the node_possible_map
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Link: http://lkml.kernel.org/r/20200416225438.15208-1-vishal.l.verma@intel.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>