PM / Hibernate: Don't let kasan instrument snapshot.c
Subsystems (2)
PATCH 1/1 PM / Hibernate: Don't let kasan instrument snapshot.c
Kasan causes the compiler to instrument C code and is used at runtime to detect accesses to memory that has been freed, or not yet allocated.
The code in snapshot.c saves and restores memory when hibernating. This will access whole pages in the slab cache that have both free and allocated areas, resulting in a large number of false positives from Kasan.
Disable instrumentation of this file.
---
With this, I can hibernate/resume a kernel built with kasan on arm64.
kernel/power/Makefile | 2 ++ 1 file changed, 2 insertions(+)
kernel/power/Makefile +2 -0
@@ -1,6 +1,8 @@ ccflags-$(CONFIG_PM_DEBUG) := -DDEBUG +KASAN_SANITIZE_snapshot.o := n + obj-y += qos.o obj-$(CONFIG_PM) += main.o obj-$(CONFIG_VT_CONSOLE_SLEEP) += console.o
Signature · 1 line
2.8.0.rc3
Rafael J. Wysocki
AppliedPATCH 1/1 PM / Hibernate: Don't let kasan instrument snapshot.c
Quoted 24 lines · James Morse
Kasan causes the compiler to instrument C code and is used at runtime to detect accesses to memory that has been freed, or not yet allocated.
The code in
snapshot.csaves and restores memory when hibernating. This will access whole pages in the slab cache that have both free and allocated areas, resulting in a large number of false positives from Kasan.Disable instrumentation of this file.
Signed-off-by James Morse <[email protected]>Acked-by Catalin Marinas <[email protected]>---
With this, I can hibernate/resume a kernel built with kasan on arm64.kernel/power/Makefile | 2 ++ 1 file changed, 2 insertions(+)kernel/power/Makefile +0
-0
kernel/power/Makefile line 8
Quoted 8 lines
kernel/power/Makefile +2
-0@@ -1,6 +1,8 @@ ccflags-$(CONFIG_PM_DEBUG) := -DDEBUG +KASAN_SANITIZE_snapshot.o := n + obj-y += qos.o obj-$(CONFIG_PM) += main.o obj-$(CONFIG_VT_CONSOLE_SLEEP) += console.o
Applied, thanks!
Does the arch code need to be annotated in a similar way too?
PATCH 1/1 PM / Hibernate: Don't let kasan instrument snapshot.c
Hi Rafael,
Quoted 1 line · Rafael J. Wysocki
Does the arch code need to be annotated in a similar way too?
Only if you do the restore copying from C, both 32bit and 64bit x86 do this copy in assembly code, which doesn't get instrumented.
Thanks,
James
PATCH 1/1 PM / Hibernate: Don't let kasan instrument snapshot.c
Quoted 7 lines · James Morse
Hi Rafael,
Quoted 1 line · Rafael J. Wysocki
Does the arch code need to be annotated in a similar way too?
Only if you do the restore copying from C, both 32bit and 64bit x86 do this copy in assembly code, which doesn't get instrumented.
OK, that's what I wanted to know.
Thanks!