On 10/23/24 08:21, Pei Xiao wrote: > 'modprobe slub_kunit',will have a warning [1].The root cause is that > __kmalloc_cache_noprof was directly used,which resulted in no alloc_tag > being allocated.This caused current->alloc_tag to be null,leading to > a warning in alloc_tag_add_check. > > Let's add an alloc_hook layer to __kmalloc_cache_noprof specifically > within lib/slub_kunit.c. > > [1]. > [58162.947016] WARNING: CPU: 2 PID: 6210 at > ./include/linux/alloc_tag.h:125 alloc_tagging_slab_alloc_hook+0x268/0x27c > [58162.957721] Call trace: > [58162.957919] alloc_tagging_slab_alloc_hook+0x268/0x27c > [58162.958286] __kmalloc_cache_noprof+0x14c/0x344 > [58162.958615] test_kmalloc_redzone_access+0x50/0x10c [slub_kunit] > [58162.959045] kunit_try_run_case+0x74/0x184 [kunit] > [58162.959401] kunit_generic_run_threadfn_adapter+0x2c/0x4c [kunit] > [58162.959841] kthread+0x10c/0x118 > [58162.960093] ret_from_fork+0x10/0x20 > [58162.960363] ---[ end trace 0000000000000000 ]--- > > Signed-off-by: Pei Xiao <xiaopei01@xxxxxxxxxx> > Fixes: a0a44d9175b3 ("mm, slab: don't wrap internal functions with alloc_hooks()") Thanks, I'm adding the fix for test_kmalloc_redzone_access() to slab/for-6.12-rc4/fixes as a 6.12 hotfix > Fixes: a286da323418 ("mm/slub, kunit: Add testcase for krealloc redzone and zeroing") This is in slab/for-next so I will just adjust the new tests in place there. > --- > lib/slub_kunit.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c > index 3cd1cc667988..f11691315c2f 100644 > --- a/lib/slub_kunit.c > +++ b/lib/slub_kunit.c > @@ -141,7 +141,7 @@ static void test_kmalloc_redzone_access(struct kunit *test) > { > struct kmem_cache *s = test_kmem_cache_create("TestSlub_RZ_kmalloc", 32, > SLAB_KMALLOC|SLAB_STORE_USER|SLAB_RED_ZONE); > - u8 *p = __kmalloc_cache_noprof(s, GFP_KERNEL, 18); > + u8 *p = alloc_hooks(__kmalloc_cache_noprof(s, GFP_KERNEL, 18)); > > kasan_disable_current(); > > @@ -199,7 +199,7 @@ static void test_krealloc_redzone_zeroing(struct kunit *test) > struct kmem_cache *s = test_kmem_cache_create("TestSlub_krealloc", 64, > SLAB_KMALLOC|SLAB_STORE_USER|SLAB_RED_ZONE); > > - p = __kmalloc_cache_noprof(s, GFP_KERNEL, 48); > + p = alloc_hooks(__kmalloc_cache_noprof(s, GFP_KERNEL, 48)); > memset(p, 0xff, 48); > > kasan_disable_current();