On Sat, Feb 03, 2024 at 07:52:54PM +0900, Tetsuo Handa wrote: > A regression caused by commit 978ffcbf00d8 ("execve: open the executable > file before doing anything else") has been fixed by commit 4759ff71f23e > ("exec: Check __FMODE_EXEC instead of in_execve for LSMs") and commit > 3eab830189d9 ("uselib: remove use of __FMODE_EXEC"). While fixing this > regression, Linus commented that we want to remove current->in_execve flag. > > The current->in_execve flag was introduced by commit f9ce1f1cda8b ("Add > in_execve flag into task_struct.") when TOMOYO LSM was merged, and the > reason was explained in commit f7433243770c ("LSM adapter functions."). > > In short, TOMOYO's design is not compatible with COW credential model > introduced in Linux 2.6.29, and the current->in_execve flag was added for > emulating security_bprm_free() hook which has been removed by introduction > of COW credential model. > > security_task_alloc()/security_task_free() hooks have been removed by > commit f1752eec6145 ("CRED: Detach the credentials from task_struct"), > and these hooks have been revived by commit 1a2a4d06e1e9 ("security: > create task_free security callback") and commit e4e55b47ed9a ("LSM: Revive > security_task_alloc() hook and per "struct task_struct" security blob."). > > But security_bprm_free() hook did not revive until now. Now that Linus > wants TOMOYO to stop carrying state across two independent execve() calls, > and TOMOYO can stop carrying state if a hook for restoring previous state > upon failed execve() call were provided, this patch revives the hook. > > Since security_bprm_committing_creds() and security_bprm_committed_creds() > hooks are called when an execve() request succeeded, we don't need to call > security_bprm_free() hook when an execve() request succeeded. Therefore, > this patch adds security_execve_abort() hook which is called only when an > execve() request failed after successful prepare_bprm_creds() call. > > Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> This looks good to me. Given this touches execve and is related to the recent execve changes, shall I carry this in the execve tree for testing and send a PR to Linus for it before v6.8 releases? There's already an Ack from Serge, so this seems a reasonable way to go unless Paul would like it done some other way? Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx> -- Kees Cook