mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* + release_task-kill-unnecessary-rcu_read_lock-around-dec_rlimit_ucounts.patch added to mm-nonmm-unstable branch
@ 2025-10-28  0:06 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2025-10-28  0:06 UTC (permalink / raw)
  To: mm-commits, paulmck, mjguzik, legion, kees, dhowells, oleg, akpm


The patch titled
     Subject: release_task: kill unnecessary rcu_read_lock() around dec_rlimit_ucounts()
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     release_task-kill-unnecessary-rcu_read_lock-around-dec_rlimit_ucounts.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/release_task-kill-unnecessary-rcu_read_lock-around-dec_rlimit_ucounts.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days

------------------------------------------------------
From: Oleg Nesterov <oleg@redhat.com>
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.

Link: https://lkml.kernel.org/r/20251026143140.GA22463@redhat.com
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Alexey Gladkov <legion@kernel.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Mateusz Guzik <mjguzik@gmail.com>
Cc: "Paul E . McKenney" <paulmck@kernel.org>
Cc: Kees Cook <kees@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/exit.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/kernel/exit.c~release_task-kill-unnecessary-rcu_read_lock-around-dec_rlimit_ucounts
+++ a/kernel/exit.c
@@ -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 oleg@redhat.com are

release_task-kill-unnecessary-rcu_read_lock-around-dec_rlimit_ucounts.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-10-28  0:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-28  0:06 + release_task-kill-unnecessary-rcu_read_lock-around-dec_rlimit_ucounts.patch added to mm-nonmm-unstable branch Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).