diff options
| author | Christian Brauner <brauner@kernel.org> | 2026-09-10 17:48:07 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-10-05 13:11:49 +0200 |
| commit | e07feeeb5b8db35ee02c2361e90a9d622d3050ee (patch) | |
| tree | 97e7a703328ea8f17fc9f4ff1a1d2977f7b6e949 /tools/lib/python | |
| parent | c6516bea4bb54963391f698c721e99eb4bb21241 (diff) | |
| download | linux-next-e07feeeb5b8db35ee02c2361e90a9d622d3050ee.tar.gz linux-next-e07feeeb5b8db35ee02c2361e90a9d622d3050ee.zip | |
fs: make close_cloexec_files() synchronous
Punting file closing to task work during exec slows down exec
significantly when its done with a bunch of file descriptors. We can
do this in-band instead. Flush already runs synchronous. Jann moved
close-on-exec in e780259b54e6 ("exec: do_close_on_exec() before taking
exec_update_lock") outside of exec_update_lock.
The only lock that's still held now is cred_guard_mutex. It's deprecated
and has five takers
(1) exec
(2) ptrace_attach()
(3) seccomp() with SECCOMP_FILTER_FLAG_TSYNC
(4) writes to /proc/<pid>/attr/*
(5) lsm_set_self_attr()
Four of them take the task's own cred_guard_mutex. When
close_cloexec_files() runs, de_thread() ensured that the calling task is
the only one alive in its thread-group. That leaves ptrace() waiting on
cred_guard_mutex of the tracee going through exec. exec already sleeps
under cred_guard_mutex in de_thread() when it reads binary and
interpreter. So while we add wait-time to an attaching ptracer no new
lock dependency is added. vfork() als waits but that's a dup_fd() copy
of the fdtable and rarely holds the last reference. If that's an issue
we can always change that later.
Link: https://lore.kernel.org/CAGudoHEsGP1P+sAWaw_tbh1NesJhSeww8869uzmaqtgk8F43=Q@mail.gmail.com
Link: https://patch.msgid.link/20260910-work-coredump-unlock-self-v4-9-a5c1800dc930@kernel.org
Reviewed-by: NeilBrown <neil@brown.name>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
