Page MenuHomeFreeBSD

imgact_elf: Make note_procstat_files best-effort to avoid deadlock
AbandonedPublic

Authored by cse_cem_gmail_com on May 20 2015, 8:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 22 2024, 8:36 PM
Unknown Object (File)
Dec 20 2023, 2:17 AM
Unknown Object (File)
Nov 28 2023, 5:38 AM
Unknown Object (File)
Nov 23 2023, 12:27 AM
Unknown Object (File)
Nov 22 2023, 11:39 PM
Unknown Object (File)
Nov 15 2023, 7:16 AM
Unknown Object (File)
Nov 13 2023, 6:00 PM
Unknown Object (File)
Nov 13 2023, 12:41 PM
Subscribers

Details

Reviewers
kib
jhb
imp
Summary

During core dump of process P, all of P's threads are suspended except
the one that proceeds from sigexit() into coredump(). Some suspended
threads may be sleeping in the filesystem with filesystem locks held.
Coredump, via elfN_prepare_notes -> note_procstat_files ->
kern_proc_filedesc_out -> export_*_to_sb, attempts to lock the process'
files LK_SHARED | LK_RETRY. As the suspended threads will not make
forward progress before coredump() has completed, this is classic
deadlock.

This was introduced in r249558 with the addition of the
NT_PROCSTAT_FILES dump note.

This patch adds 'lkflags' arguments to a number of routines that may act
on vnodes (vn_fullpath, kern_proc_filedesc_out, export_*_to_kinfo,
export_*_to_sb, fo_fill_kinfo, fo_fill_kinfo_t and every fill_kinfo fop,
vn_fullpath1, vn_vptocnp_locked, vn_fill_kinfo_vnode). At this time,
only 0 and LK_NOWAIT values are valid; a few KASSERTs are added to
reflect this.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage

Event Timeline

cse_cem_gmail_com retitled this revision from to imgact_elf: Make note_procstat_files best-effort to avoid deadlock.
cse_cem_gmail_com updated this object.
cse_cem_gmail_com edited the test plan for this revision. (Show Details)
cse_cem_gmail_com added reviewers: kib, jhb, imp.
cse_cem_gmail_com added subscribers: benno, markj.

My mistake. Sleeping with locks held in a way that thread_single() can interrupt is invalid. Thanks, kib@. Sorry for the spam, everyone.