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
F103485727: D2602.id.diff
Mon, Nov 25, 3:37 PM
F103485725: D2602.id5514.diff
Mon, Nov 25, 3:36 PM
F103484527: D2602.diff
Mon, Nov 25, 3:17 PM
Unknown Object (File)
Sun, Nov 24, 6:36 AM
Unknown Object (File)
Sun, Nov 24, 6:26 AM
Unknown Object (File)
Oct 3 2024, 9:35 PM
Unknown Object (File)
Oct 1 2024, 2:56 PM
Unknown Object (File)
Sep 26 2024, 3:49 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.