lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <0c215961308b0433cd76389fe53d7f7776a32dcb.1729663738.git.xiaopei01@kylinos.cn>
Date: Wed, 23 Oct 2024 14:21:17 +0800
From: Pei Xiao <xiaopei01@...inos.cn>
To: surenb@...gle.com
Cc: akpm@...ux-foundation.org,
	gehao@...inos.cn,
	hao.ge@...ux.dev,
	linux-kernel@...r.kernel.org,
	linux-mm@...ck.org,
	vbabka@...e.cz,
	xiaopei01@...inos.cn,
	xiaopeitux@...mail.com,
	xiongxin@...inos.cn,
	yuzhao@...gle.com
Subject: [PATCH] slub_kunit:fix a WARNING due to __kmalloc_cache_noprof incorretly use

'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@...inos.cn>
Fixes: a0a44d9175b3 ("mm, slab: don't wrap internal functions with alloc_hooks()")
Fixes: a286da323418 ("mm/slub, kunit: Add testcase for krealloc redzone and zeroing")
---
 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();
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ