提交 89826cce 编写于 作者: E Eric W. Biederman

exec: Make unlocking exec_update_mutex explict

With install_exec_creds updated to follow immediately after
setup_new_exec, the failure of unshare_sighand is the only
code path where exec_update_mutex is held but not explicitly
unlocked.

Update that code path to explicitly unlock exec_update_mutex.

Remove the unlocking of exec_update_mutex from free_bprm.
Reviewed-by: NKees Cook <keescook@chromium.org>
Reviewed-by: NGreg Ungerer <gerg@linux-m68k.org>
Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
上级 e7f77854
...@@ -1344,7 +1344,7 @@ int flush_old_exec(struct linux_binprm * bprm) ...@@ -1344,7 +1344,7 @@ int flush_old_exec(struct linux_binprm * bprm)
*/ */
retval = unshare_sighand(me); retval = unshare_sighand(me);
if (retval) if (retval)
goto out; goto out_unlock;
set_fs(USER_DS); set_fs(USER_DS);
me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD | me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD |
...@@ -1361,6 +1361,8 @@ int flush_old_exec(struct linux_binprm * bprm) ...@@ -1361,6 +1361,8 @@ int flush_old_exec(struct linux_binprm * bprm)
do_close_on_exec(me->files); do_close_on_exec(me->files);
return 0; return 0;
out_unlock:
mutex_unlock(&me->signal->exec_update_mutex);
out: out:
return retval; return retval;
} }
...@@ -1477,8 +1479,6 @@ static void free_bprm(struct linux_binprm *bprm) ...@@ -1477,8 +1479,6 @@ static void free_bprm(struct linux_binprm *bprm)
{ {
free_arg_pages(bprm); free_arg_pages(bprm);
if (bprm->cred) { if (bprm->cred) {
if (bprm->called_exec_mmap)
mutex_unlock(&current->signal->exec_update_mutex);
mutex_unlock(&current->signal->cred_guard_mutex); mutex_unlock(&current->signal->cred_guard_mutex);
abort_creds(bprm->cred); abort_creds(bprm->cred);
} }
......
...@@ -47,8 +47,7 @@ struct linux_binprm { ...@@ -47,8 +47,7 @@ struct linux_binprm {
secureexec:1, secureexec:1,
/* /*
* Set by flush_old_exec, when exec_mmap has been called. * Set by flush_old_exec, when exec_mmap has been called.
* This is past the point of no return, when the * This is past the point of no return.
* exec_update_mutex has been taken.
*/ */
called_exec_mmap:1; called_exec_mmap:1;
#ifdef __alpha__ #ifdef __alpha__
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册