[PATCH 0/9] mm: kmemleak: fix unreported memory leaks

George Prekas
2023-01-23T17:05:02Z

Fix a couple of issues with kmemleak that lead to missed (not reported)
leaks. Parts of the kernel keep references to allocated objects which
are not properly communicated to kmemleak. This causes kmemleak to fail
to report some memory leaks.

I have also written a kmemleak test. It is a userspace Python script
and a device driver that communicate over ioctl, allocate and free
memory and verify that memory leaks are reported correctly. You can find
it here:

https://gist.github.com/george-enf/2d7cc288202b94defbe253f4ca26357b

George Prekas (9):
mm: kmemleak: properly disable task stack scanning
Revert "mm/kmemleak: make create_object return void"
mm: kmemleak: propagate NO_SCAN flag in delete_object_part
mm: kmemleak: add kmemleak_noscan_phys function
mm: kmemleak: do not scan sparsemap_buf
mm: kmemleak: do not scan cpu_cache of struct kmem_cache
mm: kmemleak: erase page->s_mem in slab_destroy
mm: kmemleak: erase page->freelist in slab_destroy
mm: kmemleak: fix undetected leaks for page aligned objects

include/linux/kmemleak.h | 5 ++
kernel/fork.c | 3 ++
mm/kmemleak.c | 98 ++++++++++++++++++++++++++--------------
mm/slab.c | 20 +++-----
mm/slab.h | 7 ++-
mm/sparse.c | 3 ++
6 files changed, 88 insertions(+), 48 deletions(-)

--
2.37.1