kasan: fix bad call to unpoison_slab_object
Subsystems (2)
PATCH 1/1 kasan: fix bad call to unpoison_slab_object
From: Andrey Konovalov <[email protected]>
Commit 29d7355a9d05 ("kasan: save alloc stack traces for mempool") messed up one of the calls to unpoison_slab_object: the last two arguments are supposed to be GFP flags and whether to init the object memory.
Fix the call.
Without this fix, unpoison_slab_object provides the object's size as GFP flags to unpoison_slab_object, which can cause LOCKDEP reports (and probably other issues).
--- mm/kasan/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kasan/common.c +1 -1
@@ -532,7 +532,7 @@ void __kasan_mempool_unpoison_object(void *ptr, size_t size, unsigned long ip)return ;/* Unpoison the object and save alloc info for non-kmalloc() allocations. */ -unpoison_slab_object (slab->slab_cache, ptr, size, flags); +unpoison_slab_object (slab->slab_cache, ptr, flags, false);/* Poison the redzone and save alloc info for kmalloc() allocations. */ if (is_kmalloc_cache (slab->slab_cache))
Signature · 1 line
2.25.1
Quoted 9 lines · On Fri, 14 Jun 2024 at 16:16, <[email protected]> wrote:
From: Andrey Konovalov <[email protected]>
Commit
29d7355a9d05("kasan: save alloc stack traces for mempool") messed up one of the calls tounpoison_slab_object: the last two arguments are supposed to be GFP flags and whether to init the object memory.Fix the call.
Quoted 7 lines
Without this fix,
unpoison_slab_objectprovides the object's size as GFP flags tounpoison_slab_object, which can cause LOCKDEP reports (and probably other issues).Fixes 29d7355a9d05 ("kasan: save alloc stack traces for mempool")Reported-by Brad Spengler <[email protected]>Signed-off-by Andrey Konovalov <[email protected]>
Oof.
mm needs explicit Cc: stable, right? If so, we better add Cc: stable as well.
Quoted 20 lines
--- mm/kasan/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/kasan/common.c +1
-2@@ -532,7 +532,7 @@ void __kasan_mempool_unpoison_object(void *ptr, size_t size, unsigned long ip)return ;/* Unpoison the object and save alloc info for non-kmalloc() allocations. */ -unpoison_slab_object (slab->slab_cache, ptr, size, flags); +unpoison_slab_object (slab->slab_cache, ptr, flags, false);/* Poison the redzone and save alloc info for kmalloc() allocations. */ if (is_kmalloc_cache (slab->slab_cache)) --2.25.1
Andrey Konovalov
reviewerQuoted 19 lines · Marco Elver
Quoted 9 lines · On Fri, 14 Jun 2024 at 16:16, <[email protected]> wrote:
From: Andrey Konovalov <[email protected]>
Commit
29d7355a9d05("kasan: save alloc stack traces for mempool") messed up one of the calls tounpoison_slab_object: the last two arguments are supposed to be GFP flags and whether to init the object memory.Fix the call.
Quoted 7 lines
Without this fix,
unpoison_slab_objectprovides the object's size as GFP flags tounpoison_slab_object, which can cause LOCKDEP reports (and probably other issues).Fixes 29d7355a9d05 ("kasan: save alloc stack traces for mempool")Reported-by Brad Spengler <[email protected]>Signed-off-by Andrey Konovalov <[email protected]>
Quoted 5 lines
Oof.
Acked-by Marco Elver <[email protected]>mm needs explicit Cc: stable, right? If so, we better add Cc: stable as well.
Makes sense, sent v2 with CC stable and a commit message fix.
Thanks!