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-next>] [day] [month] [year] [list]
Date:   Fri, 6 May 2022 13:53:19 +0900
From:   Paran Lee <p4ranlee@...il.com>
To:     Christoph Lameter <cl@...ux.com>,
        Pekka Enberg <penberg@...nel.org>,
        David Rientjes <rientjes@...gle.com>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Vlastimil Babka <vbabka@...e.cz>,
        Roman Gushchin <roman.gushchin@...ux.dev>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...r.kernel.org,
        Oliver Glitta <glittao@...il.com>,
        Austin Kim <austindh.kim@...il.com>
Subject: [PATCH] slub: kunit catch kmem_cache_alloc failed

Catch kmem_cache_alloc failed on slub kunit test.

Signed-off-by: Paran Lee <p4ranlee@...il.com>
---
 lib/slub_kunit.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c
index 8662dc6cb509..7b80241dd498 100644
--- a/lib/slub_kunit.c
+++ b/lib/slub_kunit.c
@@ -32,6 +32,11 @@ static void test_next_pointer(struct kunit *test)
 	struct kmem_cache *s = kmem_cache_create("TestSlub_next_ptr_free", 64, 0,
 				SLAB_POISON, NULL);
 	u8 *p = kmem_cache_alloc(s, GFP_KERNEL);
+	if (!p) {
+		kunit_err(test, "Allocation failed: %s\n", __func__);
+		kmem_cache_destroy(s);
+		return;
+	}
 	unsigned long tmp;
 	unsigned long *ptr_addr;
 
@@ -77,6 +82,11 @@ static void test_first_word(struct kunit *test)
 	struct kmem_cache *s = kmem_cache_create("TestSlub_1th_word_free", 64, 0,
 				SLAB_POISON, NULL);
 	u8 *p = kmem_cache_alloc(s, GFP_KERNEL);
+	if (!p) {
+		kunit_err(test, "Allocation failed: %s\n", __func__);
+		kmem_cache_destroy(s);
+		return;
+	}
 
 	kmem_cache_free(s, p);
 	*p = 0x78;
@@ -92,6 +102,11 @@ static void test_clobber_50th_byte(struct kunit *test)
 	struct kmem_cache *s = kmem_cache_create("TestSlub_50th_word_free", 64, 0,
 				SLAB_POISON, NULL);
 	u8 *p = kmem_cache_alloc(s, GFP_KERNEL);
+	if (!p) {
+		kunit_err(test, "Allocation failed: %s\n", __func__);
+		kmem_cache_destroy(s);
+		return;
+	}
 
 	kmem_cache_free(s, p);
 	p[50] = 0x9a;
@@ -108,6 +123,11 @@ static void test_clobber_redzone_free(struct kunit *test)
 	struct kmem_cache *s = kmem_cache_create("TestSlub_RZ_free", 64, 0,
 				SLAB_RED_ZONE, NULL);
 	u8 *p = kmem_cache_alloc(s, GFP_KERNEL);
+	if (!p) {
+		kunit_err(test, "Allocation failed: %s\n", __func__);
+		kmem_cache_destroy(s);
+		return;
+	}
 
 	kasan_disable_current();
 	kmem_cache_free(s, p);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ