diff options
| author | Christian Brauner <brauner@kernel.org> | 2026-09-21 15:44:56 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-10-05 13:11:50 +0200 |
| commit | 296a98c1fa50778c3b31eebed1a3f903f9684349 (patch) | |
| tree | 338ddae5437e83c4b1b93edd6eeb0c8935e2e4e6 /tools/lib/python | |
| parent | 97f08aa8224ed9b8643b905acf027cb7ed93bded (diff) | |
| download | linux-next-296a98c1fa50778c3b31eebed1a3f903f9684349.tar.gz linux-next-296a98c1fa50778c3b31eebed1a3f903f9684349.zip | |
fork: release the files of a failed fork after sched_cancel_fork()
Reorder copy_process() cleanup so sched_fork() taking scx_fork_rwsem
scx_pre_fork() is safe and isn't held around exiting files. Right now, a
fork that fails while another thread closed the bpf link fd will
deadlock against its own read side. It also blocks every fork on the
system:
copy_process() holds scx_fork_rwsem for read
exit_files()
close_files()
filp_close_sync()
bpf_scx_unreg()
kthread_flush_work() waits for the disable work
scx_root_disable()
percpu_down_write(&scx_fork_rwsem)
Simply release the child's files after sched_cancel_fork() dropped the
lock. The task starts out as a copy of its parent so p->files points to
the parent's table until copy_files() replaces it. exit_files() must not
run for a fork that failed before that. Clear p->files up front so
exit_files() is a no-op for those and make copy_files() set it
explicitly for CLONE_FILES.
Reported-by: Chris Mason <mason@kernel.org>
Link: https://patch.msgid.link/20260921-work-coredump-fixes-v3-7-8e4adb1619e6@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'tools/lib/python')
0 files changed, 0 insertions, 0 deletions
