From 67474173e3a561d39dce6809b5dccabc488944e2 Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Tue, 23 Apr 2019 16:15:07 -0700 Subject: [PATCH] kasan: Zero shadow memory on memory hotplug Vmalloc does not zero memory by default. In this instance, CONFIG_PAGE_POISONING was enabled, so the pages were initialized to 0xAA. kasan_report+0x28c/0x2f8 check_memory_region+0x1dc/0x1e8 memset+0x2c/0x50 kernel_poison_pages+0x234/0x398 __free_pages_ok+0x380/0xd50 __free_pages+0x4c/0xd0 online_pages_range+0x174/0x1c8 walk_system_ram_range+0x130/0x170 online_pages+0x298/0x458 memory_block_change_state+0x160/0x210 memory_subsys_online+0x68/0x90 device_online+0x9c/0xc8 add_memory_resource+0x18c/0x228 add_memory+0x118/0x180 Memory state around the buggy address: ffffffc17fffff00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffffffc17fffff80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffffffc180000000: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ^ ffffffc180000080: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa ffffffc180000100: aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa Change-Id: Id487a53d3cbe14a4ba73d43e151a51fd3162b1e0 Signed-off-by: Patrick Daly [isaacm@codeaurora.org: resolve merge conflicts] Signed-off-by: Isaac J. Manjarres --- mm/kasan/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 6814d6d6a023..ac9f624158b9 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -700,7 +700,7 @@ static int __meminit kasan_mem_notifier(struct notifier_block *nb, return NOTIFY_OK; ret = __vmalloc_node_range(shadow_size, PAGE_SIZE, shadow_start, - shadow_end, GFP_KERNEL, + shadow_end, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL, VM_NO_GUARD, pfn_to_nid(mem_data->start_pfn), __builtin_return_address(0));