Skip to contentSkip to conversation

ipc-fix-to-protect-ipcs-lookups-using-rcu.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message May 12, 2025 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: ipc: fix to protect IPCS lookups using RCU
has been removed from the -mm tree. Its filename was
ipc-fix-to-protect-ipcs-lookups-using-rcu.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Jeongjun Park <[email protected]>
Subject: ipc: fix to protect IPCS lookups using RCU
Date: Thu, 24 Apr 2025 23:33:22 +0900

syzbot reported that it discovered a use-after-free vulnerability, [0]

[0]: https://lore.kernel.org/all/[email protected]/

idr_for_each() is protected by rwsem, but this is not enough. If it is not protected by RCU read-critical region, when idr_for_each() calls radix_tree_node_free() through call_rcu() to free the radix_tree_node structure, the node will be freed immediately, and when reading the next node in radix_tree_for_each_slot(), the already freed memory may be read.

Therefore, we need to add code to make sure that idr_for_each() is protected within the RCU read-critical region when we call it in shm_destroy_orphaned().

Fixes b34a6b1da371 ("ipc: introduce shm_rmid_forced sysctl")
Reported-by [email protected]
Cc Jeongjun Park <[email protected]>
Cc Liam Howlett <[email protected]>
Cc Lorenzo Stoakes <[email protected]>
Cc Matthew Wilcox (Oracle) <[email protected]>
Cc Vasiliy Kulikov <[email protected]>

---

 ipc/shm.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
ipc/shm.c renamed from ipc/shm.c~ipc-fix-to-protect-ipcs-lookups-using-rcu +4 -1
@@ -431,8 +431,11 @@ static int shm_try_destroy_orphaned(int
 void shm_destroy_orphaned(struct ipc_namespace *ns)
 {
 	down_write(&shm_ids(ns).rwsem);
-	if (shm_ids(ns).in_use)
+	if (shm_ids(ns).in_use) {
+		rcu_read_lock();
 		idr_for_each(&shm_ids(ns).ipcs_idr, &shm_try_destroy_orphaned, ns);
+		rcu_read_unlock();
+	}
 	up_write(&shm_ids(ns).rwsem);
 }
 

_

Patches currently in -mm which might be from [email protected] are

mm-vmalloc-fix-data-race-in-show_numa_info.patch