Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kmemleak: disable kasan instrumentation for kmemleak

kmalloc internally round up allocation size, and kmemleak uses rounded up
size as object's size. This makes kasan to complain while kmemleak scans
memory or calculates of object's checksum. The simplest solution here is
to disable kasan.

Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Konstantin Serebryany <kcc@google.com>
Cc: Dmitry Chernenkov <dmitryc@google.com>
Signed-off-by: Andrey Konovalov <adech.fo@gmail.com>
Cc: Yuri Gribov <tetra2005@gmail.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Andrey Ryabinin and committed by
Linus Torvalds
e79ed2f1 df4c0e36

+6
+6
mm/kmemleak.c
··· 98 98 #include <asm/processor.h> 99 99 #include <linux/atomic.h> 100 100 101 + #include <linux/kasan.h> 101 102 #include <linux/kmemcheck.h> 102 103 #include <linux/kmemleak.h> 103 104 #include <linux/memory_hotplug.h> ··· 1114 1113 if (!kmemcheck_is_obj_initialized(object->pointer, object->size)) 1115 1114 return false; 1116 1115 1116 + kasan_disable_current(); 1117 1117 object->checksum = crc32(0, (void *)object->pointer, object->size); 1118 + kasan_enable_current(); 1119 + 1118 1120 return object->checksum != old_csum; 1119 1121 } 1120 1122 ··· 1168 1164 BYTES_PER_POINTER)) 1169 1165 continue; 1170 1166 1167 + kasan_disable_current(); 1171 1168 pointer = *ptr; 1169 + kasan_enable_current(); 1172 1170 1173 1171 object = find_and_get_object(pointer, 1); 1174 1172 if (!object)