kasan: fix memory notifier handling
Subsystems (2)
cover kasan: fix memory notifier handling
If onlining of pages fails, we don't properly free up memory. Also, the memory hotplug notifier is not registered early enough, still failing on certain setups where memory is detected, added and onlined early.
David Hildenbrand (2):
kasan: free allocated shadow memory on MEM_CANCEL_OFFLINE
kasan: fix memory hotplug during boot
mm/kasan/kasan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.0
PATCH 1/2 kasan: free allocated shadow memory on MEM_CANCEL_OFFLINE
We have to free memory again when we cancel onlining, otherwise a later onlining attempt will fail.
--- mm/kasan/kasan.c | 1 + 1 file changed, 1 insertion(+)
mm/kasan/kasan.c +1 -0
@@ -867,6 +867,7 @@ static int __meminit kasan_mem_notifier(struct notifier_block *nb,kmemleak_ignore (ret);return NOTIFY_OK ; } +case MEM_CANCEL_OFFLINE :case MEM_OFFLINE : {struct vm_struct *vm;
Signature · 1 line
2.17.0
PATCH 2/2 kasan: fix memory hotplug during boot
In reply to David HildenbrandUsing module_init() is wrong. E.g. ACPI adds and onlines memory before our memory notifier gets registered.
This makes sure that ACPI memory detected during boot up will not result in a kernel crash.
Easily reproducable with QEMU, just specify a DIMM when starting up.
--- mm/kasan/kasan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kasan/kasan.c +1 -1
@@ -892,5 +892,5 @@ static int __init kasan_memhotplug_init(void) return 0; } -module_init (kasan_memhotplug_init); +core_initcall (kasan_memhotplug_init);#endif
Signature · 1 line
2.17.0
Re: [PATCH v1 1/2] kasan: free allocated shadow memory on MEM_CANCEL_OFFLINE
In reply to David HildenbrandQuoted 13 lines · David Hildenbrand
We have to free memory again when we cancel onlining, otherwise a later onlining attempt will fail.
Signed-off-by David Hildenbrand <[email protected]>--- mm/kasan/kasan.c | 1 + 1 file changed, 1 insertion(+)mm/kasan/kasan.c +0
-0
mm/kasan/kasan.c static int __meminit kasan_mem_notifier(struct notifier_block *nb, · line 870
Quoted 4 lines
mm/kasan/kasan.c +1
-0@@ -867,6 +867,7 @@ static int __meminit kasan_mem_notifier(struct notifier_block *nb,kmemleak_ignore (ret);return NOTIFY_OK ; } +case MEM_CANCEL_OFFLINE :
Typo, MEM_CANCEL_ONLINE
Quoted 4 lines
mm/kasan/kasan.c +0
-0case MEM_OFFLINE : {struct vm_struct *vm;
Signature · 3 lines
Thanks, David / dhildenb