Bug 216306

Summary: KASAN: print alloc stacks in kmem_cache_destroy() for leaked objects
Product: Memory Management Reporter: Dmitry Vyukov (dvyukov)
Component: SanitizersAssignee: MM/Sanitizers virtual assignee (mm_sanitizers)
Status: NEW ---    
Severity: enhancement CC: kasan-dev
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: ALL Subsystem:
Regression: No Bisected commit-id:

Description Dmitry Vyukov 2022-07-29 12:30:36 UTC
There is a WARNING in kmem_cache_destroy() for the cases when a cache is destroyed with live objects:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/slab_common.c?id=e0dccc3b76fb35bb257b4118367a883073d7390e#n506

When KASAN is enabled we could print allocation stacks for all leaked objects to give more useful info for debugging.

For context see:
https://lore.kernel.org/all/2916828.W3qMjvkFlE@silver/
Comment 1 Dmitry Vyukov 2022-07-29 12:39:49 UTC
Allocation stacks may always be the same for custom caches, but they may also be different. E.g. in this case the allocation happens in a common p9_client_prepare_req() function that it called in multiple places.
But KASAN can also provide "aux" stacks that may also give some glues.