The patch below does not apply to the 4.9-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 stable@vger.kernel.org.
Possible dependencies:
5bf2fedca8f5 ("exec: Copy oldsighand->action under spin-lock") 021691559245 ("exec: Factor unshare_sighand out of de_thread and call it separately") d036bda7d0e7 ("sched/core: Convert sighand_struct.count to refcount_t") 06e62a46bbba ("fork: don't copy inconsistent signal handler state to child") 2a1f062a4acf ("sched/headers: Move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h>") c3edc4010e9d ("sched/headers: Move task_struct::signal and task_struct::sighand types and accessors into <linux/sched/signal.h>") 11701c676836 ("sched/headers: Move task->mm coredumping related defines and methods from <linux/sched.h> to <linux/sched/coredump.h>") dea38c74cb92 ("sched/headers: Move loadavg related definitions from <linux/sched.h> to <linux/sched/loadavg.h>") 9164bb4a18df ("sched/headers: Prepare to move 'init_task' and 'init_thread_union' from <linux/sched.h> to <linux/sched/task.h>") 589ee62844e0 ("sched/headers: Prepare to remove the <linux/mm_types.h> dependency from <linux/sched.h>") f361bf4a66c9 ("sched/headers: Prepare for the reduction of <linux/sched.h>'s signal API dependency") 68db0cf10678 ("sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task_stack.h>") 299300258d1b ("sched/headers: Prepare for new header dependencies before moving code to <linux/sched/task.h>") ef8bd77f332b ("sched/headers: Prepare for new header dependencies before moving code to <linux/sched/hotplug.h>") b17b01533b71 ("sched/headers: Prepare for new header dependencies before moving code to <linux/sched/debug.h>") 370c91355c76 ("sched/headers: Prepare for new header dependencies before moving code to <linux/sched/nohz.h>") 03441a3482a3 ("sched/headers: Prepare for new header dependencies before moving code to <linux/sched/stat.h>") fd7712337ff0 ("sched/headers: Prepare to remove the <linux/gfp.h> include from <linux/sched.h>") 174cd4b1e5fb ("sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h>") 037741a6d4ab ("sched/headers: Prepare for the removal of <linux/rtmutex.h> from <linux/sched.h>")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 5bf2fedca8f59379025b0d52f917b9ddb9bfe17e Mon Sep 17 00:00:00 2001 From: Bernd Edlinger bernd.edlinger@hotmail.de Date: Mon, 7 Jun 2021 15:54:27 +0200 Subject: [PATCH] exec: Copy oldsighand->action under spin-lock
unshare_sighand should only access oldsighand->action while holding oldsighand->siglock, to make sure that newsighand->action is in a consistent state.
Signed-off-by: Bernd Edlinger bernd.edlinger@hotmail.de Cc: stable@vger.kernel.org Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kees Cook keescook@chromium.org Link: https://lore.kernel.org/r/AM8PR10MB470871DEBD1DED081F9CC391E4389@AM8PR10MB47...
diff --git a/fs/exec.c b/fs/exec.c index 349a5da91efe..32dc8cf5fceb 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1197,11 +1197,11 @@ static int unshare_sighand(struct task_struct *me) return -ENOMEM;
refcount_set(&newsighand->count, 1); - memcpy(newsighand->action, oldsighand->action, - sizeof(newsighand->action));
write_lock_irq(&tasklist_lock); spin_lock(&oldsighand->siglock); + memcpy(newsighand->action, oldsighand->action, + sizeof(newsighand->action)); rcu_assign_pointer(me->sighand, newsighand); spin_unlock(&oldsighand->siglock); write_unlock_irq(&tasklist_lock);