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: <20210901051914.971603-2-imran.f.khan@oracle.com>
Date:   Wed,  1 Sep 2021 15:19:13 +1000
From:   Imran Khan <imran.f.khan@...cle.com>
To:     geert@...ux-m68k.org, vbabka@...e.cz, akpm@...ux-foundation.org
Cc:     linux-kernel@...r.kernel.org
Subject: [RFC PATCH 1/2] lib, stackdepot: check stackdepot handle before accessing slabs.

stack_depot_save allocates slabs that will be used for storing
objects in future.If this slab allocation fails we may get to
a situation where space allocation for a new stack_record fails,
causing stack_depot_save to return 0 as handle.
If user of this handle ends up invoking stack_depot_fetch with
this handle value, current implementation of stack_depot_fetch
will end up using slab from wrong index.
To avoid this check handle value at the beginning.
Also issue a warning for nil handle values and when slab allocation
for stackdepot fails for the first time.

Signed-off-by: Imran Khan <imran.f.khan@...cle.com>
Suggested-by: Vlastimil Babka <vbabka@...e.cz>
---
 lib/stackdepot.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index 0a2e417f83cb..1d42ef9ef766 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -232,6 +232,10 @@ unsigned int stack_depot_fetch(depot_stack_handle_t handle,
 	struct stack_record *stack;
 
 	*entries = NULL;
+	if (!handle) {
+		WARN(1, "stack depot handle is absent.\n");
+		return 0;
+	}
 	if (parts.slabindex > depot_index) {
 		WARN(1, "slab index %d out of bounds (%d) for stack id %08x\n",
 			parts.slabindex, depot_index, handle);
@@ -303,6 +307,8 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries,
 		page = alloc_pages(alloc_flags, STACK_ALLOC_ORDER);
 		if (page)
 			prealloc = page_address(page);
+		else
+			WARN_ONCE(1, "slab allocation for stack depot failed.\n");
 	}
 
 	raw_spin_lock_irqsave(&depot_lock, flags);
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ