Message ID | AM8PR10MB470871DEBD1DED081F9CC391E4389@AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | exec: Copy oldsighand->action under spin-lock | expand |
On Mon, Jun 07, 2021 at 03:54:27PM +0200, Bernd Edlinger wrote: > 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> > --- > fs/exec.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/fs/exec.c b/fs/exec.c > index d8af85f..8344fba 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -1193,11 +1193,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); Oh, yeah, that's a nice catch. Reviewed-by: Kees Cook <keescook@chromium.org>
On Mon, 7 Jun 2021 15:54:27 +0200, Bernd Edlinger wrote: > unshare_sighand should only access oldsighand->action > while holding oldsighand->siglock, to make sure that > newsighand->action is in a consistent state. Applied to for-next/execve, thanks! [1/1] exec: Copy oldsighand->action under spin-lock https://git.kernel.org/kees/c/f53283b0165f
diff --git a/fs/exec.c b/fs/exec.c index d8af85f..8344fba 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1193,11 +1193,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);
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> --- fs/exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)