This is a note to let you know that I've just added the patch titled exec: Fix error handling in begin_new_exec() to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: exec-fix-error-handling-in-begin_new_exec.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 84c39ec57d409e803a9bb6e4e85daf1243e0e80b Mon Sep 17 00:00:00 2001 From: Bernd Edlinger <bernd.edlinger@xxxxxxxxxx> Date: Mon, 22 Jan 2024 19:34:21 +0100 Subject: exec: Fix error handling in begin_new_exec() From: Bernd Edlinger <bernd.edlinger@xxxxxxxxxx> commit 84c39ec57d409e803a9bb6e4e85daf1243e0e80b upstream. 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: b8a61c9e7b4a ("exec: Generic execfd support") Signed-off-by: Bernd Edlinger <bernd.edlinger@xxxxxxxxxx> Acked-by: Eric W. Biederman <ebiederm@xxxxxxxxxxxx> Link: https://lore.kernel.org/r/AS8P193MB128517ADB5EFF29E04389EDAE4752@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/exec.c | 3 +++ 1 file changed, 3 insertions(+) --- a/fs/exec.c +++ b/fs/exec.c @@ -1410,6 +1410,9 @@ int begin_new_exec(struct linux_binprm * out_unlock: up_write(&me->signal->exec_update_lock); + if (!bprm->cred) + mutex_unlock(&me->signal->cred_guard_mutex); + out: return retval; } Patches currently in stable-queue which might be from bernd.edlinger@xxxxxxxxxx are queue-5.15/exec-fix-error-handling-in-begin_new_exec.patch queue-5.15/net-stmmac-wait-a-bit-for-the-reset-to-take-effect.patch