Skip to content

Commit 89826cc

Browse files
committed
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: Kees Cook <[email protected]> Reviewed-by: Greg Ungerer <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent e7f7785 commit 89826cc

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

fs/exec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,7 @@ int flush_old_exec(struct linux_binprm * bprm)
13441344
*/
13451345
retval = unshare_sighand(me);
13461346
if (retval)
1347-
goto out;
1347+
goto out_unlock;
13481348

13491349
set_fs(USER_DS);
13501350
me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD |
@@ -1361,6 +1361,8 @@ int flush_old_exec(struct linux_binprm * bprm)
13611361
do_close_on_exec(me->files);
13621362
return 0;
13631363

1364+
out_unlock:
1365+
mutex_unlock(&me->signal->exec_update_mutex);
13641366
out:
13651367
return retval;
13661368
}
@@ -1477,8 +1479,6 @@ static void free_bprm(struct linux_binprm *bprm)
14771479
{
14781480
free_arg_pages(bprm);
14791481
if (bprm->cred) {
1480-
if (bprm->called_exec_mmap)
1481-
mutex_unlock(&current->signal->exec_update_mutex);
14821482
mutex_unlock(&current->signal->cred_guard_mutex);
14831483
abort_creds(bprm->cred);
14841484
}

include/linux/binfmts.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ struct linux_binprm {
4747
secureexec:1,
4848
/*
4949
* Set by flush_old_exec, when exec_mmap has been called.
50-
* This is past the point of no return, when the
51-
* exec_update_mutex has been taken.
50+
* This is past the point of no return.
5251
*/
5352
called_exec_mmap:1;
5453
#ifdef __alpha__

0 commit comments

Comments
 (0)