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]
Message-ID: <20250219132905.8214-1-aha310510@gmail.com>
Date: Wed, 19 Feb 2025 22:29:05 +0900
From: Jeongjun Park <aha310510@...il.com>
To: akpm@...ux-foundation.org
Cc: willy@...radead.org,
	brauner@...nel.org,
	lorenzo.stoakes@...cle.com,
	Liam.Howlett@...cle.com,
	segoon@...nwall.com,
	linux-kernel@...r.kernel.org,
	syzbot+a2b84e569d06ca3a949c@...kaller.appspotmail.com,
	Jeongjun Park <aha310510@...il.com>
Subject: [PATCH] ipc: fix to protect IPCS lookups using RCU

In shm_destroy_orphaned(), we are not performing updates to the IPCS and are
only calling idr_for_each(), which can be protected by the RCU read-critical
section.

And if idr_for_each() is not protected by the RCU read-critical section,
then when radix_tree_node_free() is called to free the struct radix_tree_node
through call_rcu(), the node will be freed immediately, and when reading the
next node in radix_tree_for_each_slot(), the memory that has already been
freed may be read.

Therefore, when calling idr_for_each() in shm_destroy_orphaned(), it should
be modify to protect it within the RCU read critical section.

Reported-by: syzbot+a2b84e569d06ca3a949c@...kaller.appspotmail.com
Fixes: b34a6b1da371 ("ipc: introduce shm_rmid_forced sysctl")
Signed-off-by: Jeongjun Park <aha310510@...il.com>
---
 ipc/shm.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ipc/shm.c b/ipc/shm.c
index 99564c870084..baef5afadfb9 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -431,8 +431,10 @@ static int shm_try_destroy_orphaned(int id, void *p, void *data)
 void shm_destroy_orphaned(struct ipc_namespace *ns)
 {
 	down_write(&shm_ids(ns).rwsem);
+	rcu_read_lock();
 	if (shm_ids(ns).in_use)
 		idr_for_each(&shm_ids(ns).ipcs_idr, &shm_try_destroy_orphaned, ns);
+	rcu_read_unlock();
 	up_write(&shm_ids(ns).rwsem);
 }
 
--

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ