From: Bernd Edlinger Date: Mon, 7 Jun 2021 13:54:27 +0000 (+0200) Subject: exec: Copy oldsighand->action under spin-lock X-Git-Tag: v6.6.17~6048^2~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5bf2fedca8f59379025b0d52f917b9ddb9bfe17e;p=platform%2Fkernel%2Flinux-rpi.git 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 Cc: stable@vger.kernel.org Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/AM8PR10MB470871DEBD1DED081F9CC391E4389@AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM --- diff --git a/fs/exec.c b/fs/exec.c index 349a5da..32dc8cf 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);