mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
exec: release the replaced file with do_close_execat()
When the format search stages an interpreter exec_binprm() swaps it in and releases the file it replaces. Dropping the write denial the open took is done manually ahead of both release paths. The one path that keeps the file silently relies on it not being called. Let's just use do_close_execat() on the two paths that release the file and drop the denial explicitly on the one that does not. No functional change. Link: https://patch.msgid.link/20260721-work-bpf-binfmt_misc-ptinterp-v2-6-e57866e4ae0f@kernel.org Reviewed-by: Farid Zakaria <farid.m.zakaria@gmail.com> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
parent
c41b9cd8cf
commit
9c50e37ca7
10
fs/exec.c
10
fs/exec.c
|
|
@ -1735,15 +1735,17 @@ static int exec_binprm(struct linux_binprm *bprm)
|
|||
bprm->file = bprm->interpreter;
|
||||
bprm->interpreter = NULL;
|
||||
|
||||
exe_file_allow_write_access(exec);
|
||||
if (unlikely(bprm->have_execfd)) {
|
||||
if (bprm->executable) {
|
||||
fput(exec);
|
||||
do_close_execat(exec);
|
||||
return -ENOEXEC;
|
||||
}
|
||||
/* Only the reference is kept, for AT_EXECFD. */
|
||||
exe_file_allow_write_access(exec);
|
||||
bprm->executable = exec;
|
||||
} else
|
||||
fput(exec);
|
||||
} else {
|
||||
do_close_execat(exec);
|
||||
}
|
||||
}
|
||||
|
||||
audit_bprm(bprm);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user