Skip to content

Commit 84c39ec

Browse files
bernd-edlingerkees
authored andcommitted
exec: Fix error handling in begin_new_exec()
If get_unused_fd_flags() fails, the error handling is incomplete because bprm->cred is already set to NULL, and therefore free_bprm will not unlock the cred_guard_mutex. Note there are two error conditions which end up here, one before and one after bprm->cred is cleared. Fixes: b8a61c9 ("exec: Generic execfd support") Signed-off-by: Bernd Edlinger <bernd.edlinger@hotmail.de> Acked-by: Eric W. Biederman <ebiederm@xmission.com> Link: https://lore.kernel.org/r/AS8P193MB128517ADB5EFF29E04389EDAE4752@AS8P193MB1285.EURP193.PROD.OUTLOOK.COM Cc: stable@vger.kernel.org Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent bdd8f62 commit 84c39ec

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

fs/exec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,6 +1424,9 @@ int begin_new_exec(struct linux_binprm * bprm)
14241424

14251425
out_unlock:
14261426
up_write(&me->signal->exec_update_lock);
1427+
if (!bprm->cred)
1428+
mutex_unlock(&me->signal->cred_guard_mutex);
1429+
14271430
out:
14281431
return retval;
14291432
}

0 commit comments

Comments
 (0)