FAILED: patch "[PATCH] coredump: hold RCU while releasing parked threads" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 61d58591aa0188bf2463e263962256316ff8b576
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026102802-parasite-try-a089@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 61d58591aa0188bf2463e263962256316ff8b576 Mon Sep 17 00:00:00 2001
From: Christian Brauner <[email protected]>
Date: Mon, 21 Sep 2026 15:44:50 +0200
Subject: [PATCH] coredump: hold RCU while releasing parked threads
coredump_finish() releases the parked threads by clearing ->task in their core_thread entry and calling wake_up_process() on each of them. It does that without holding a reference on the task and without being inside rcu.
But calling wake_up_process(task) without rcu here isn't safe. A parked thread doesn't need that wakeup to leave. A spurious wakeup or a preemption after the store is enough for the task to go away.
So if the coredump client is preempted between the store and wake_up_process() the thread can exit and be freed in the meantime and try_to_wake_up() takes pi_lock in freed memory.
Hold rcu across the loop.
fs/coredump.c +3 -0
@@ -562,6 +562,8 @@ static void coredump_finish(bool core_dumped) current->signal->core_state =NULL ;spin_unlock_irq (¤t->sighand->siglock); +/* A released thread may exit and be freed before it is woken. */ +guard (rcu)();while ((curr = next) !=NULL ) { next = curr->next; task = curr->task;
@@ -570,6 +572,7 @@ static void coredump_finish(bool core_dumped)* ->task == NULL before we read ->next. */ smp_mb (); +/* Any wakeup now lets the thread exit, rcu keeps it alive. */ curr->task =NULL ;wake_up_process (task); }
Sasha Levin
maintainerPATCH 1/1 coredump: hold RCU while releasing parked threads
From: Christian Brauner <[email protected]>
[ Upstream commit 61d58591aa0188bf2463e263962256316ff8b576 ]
coredump_finish() releases the parked threads by clearing ->task in their core_thread entry and calling wake_up_process() on each of them. It does that without holding a reference on the task and without being inside rcu.
But calling wake_up_process(task) without rcu here isn't safe. A parked thread doesn't need that wakeup to leave. A spurious wakeup or a preemption after the store is enough for the task to go away.
So if the coredump client is preempted between the store and wake_up_process() the thread can exit and be freed in the meantime and try_to_wake_up() takes pi_lock in freed memory.
Hold rcu across the loop.
--- fs/coredump.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/coredump.c +4 -0
@@ -529,6 +529,8 @@ static void coredump_finish(struct mm_struct *mm, bool core_dumped)spin_unlock_irq (¤t->sighand->siglock); next = mm->core_state->dumper.next; +/* A released thread may exit and be freed before it is woken. */ +rcu_read_lock ();while ((curr = next) !=NULL ) { next = curr->next; task = curr->task;
@@ -537,9 +539,11 @@ static void coredump_finish(struct mm_struct *mm, bool core_dumped)* ->task == NULL before we read ->next. */ smp_mb (); +/* Any wakeup now lets the thread exit, rcu keeps it alive. */ curr->task =NULL ;wake_up_process (task); } +rcu_read_unlock (); mm->core_state =NULL ; }
Signature · 1 line
2.53.0