Skip to contentSkip to conversation

release_task-kill-unnecessary-rcu_read_lock-around-dec_rlimit_ucounts.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Nov 12, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: release_task: kill unnecessary rcu_read_lock() around dec_rlimit_ucounts()
has been removed from the -mm tree. Its filename was
release_task-kill-unnecessary-rcu_read_lock-around-dec_rlimit_ucounts.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: Oleg Nesterov <[email protected]>
Subject: release_task: kill unnecessary rcu_read_lock() around dec_rlimit_ucounts()
Date: Sun, 26 Oct 2025 15:31:40 +0100

rcu_read_lock() was added to shut RCU-lockdep up when this code used __task_cred()->rcu_dereference(), but after the commit 21d1c5e386bc ("Reimplement RLIMIT_NPROC on top of ucounts") it is no longer needed:
task_ucounts()->task_cred_xxx() takes rcu_read_lock() itself.

NOTE: task_ucounts() returns the pointer to another rcu-protected data, struct ucounts. So it should either be used when task->real_cred and thus task->real_cred->ucounts is stable (release_task, copy_process, copy_creds), or it should be called under rcu_read_lock(). In both cases it is pointless to take rcu_read_lock() to read the cred->ucounts pointer.

---

 kernel/exit.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/exit.c renamed from kernel/exit.c~release_task-kill-unnecessary-rcu_read_lock-around-dec_rlimit_ucounts +1 -3
@@ -251,10 +251,8 @@ repeat:
 	memset(&post, 0, sizeof(post));
 
 	/* don't need to get the RCU readlock here - the process is dead and
-	 * can't be modifying its own credentials. But shut RCU-lockdep up */
-	rcu_read_lock();
+	 * can't be modifying its own credentials. */
 	dec_rlimit_ucounts(task_ucounts(p), UCOUNT_RLIMIT_NPROC, 1);
-	rcu_read_unlock();
 
 	pidfs_exit(p);
 	cgroup_release(p);

_

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