Page MenuHomeFreeBSD

kern: factor out the 'writing' bits of user process coredumping
ClosedPublic

Authored by kevans on Jul 16 2025, 4:50 AM.
Tags
None
Referenced Files
F131953359: D51337.id159207.diff
Sun, Oct 12, 11:32 AM
F131891604: D51337.id.diff
Sun, Oct 12, 12:37 AM
F131891603: D51337.id158586.diff
Sun, Oct 12, 12:37 AM
F131840663: D51337.diff
Sat, Oct 11, 3:04 PM
Unknown Object (File)
Sun, Sep 28, 3:00 AM
Unknown Object (File)
Wed, Sep 24, 9:55 AM
Unknown Object (File)
Sun, Sep 21, 6:23 PM
Unknown Object (File)
Sep 12 2025, 12:56 AM
Subscribers

Details

Summary

Instead of assuming we have a vnode to dump to, pull out the bits that
describe how to write acoredump into a struct coredump_writer; the ctx in
that is expected to be opaque, but used by write/extend functions. This
should not be a functional change- we change two callers to use the classic
vnode write/extend interface.

This opens us up to other possible targets for coredumps, such as a shmfd.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/kern/kern_exec.c
2002

Move these functions to hypothetical vnode dumper source file.

kevans added inline comments.
sys/kern/kern_exec.c
2002

I left these alone here and moved them along with everything else in the next commit, since that diff had ended up a bit larger than I expected.

This revision is now accepted and ready to land.Jul 18 2025, 2:18 PM
kevans marked an inline comment as done.

Add an init_fn to the coredump_writer

This gives the caller a chance to do some lazy initialization or record the
coredump parameters. It will be documented in coredumper_register(9) in a later
change in this stack.

The vnode dumper could probably move vnode setup/corefile_open to an init
function and avoid leaving a 0-byte .core file around if sv_imgact is just going
to fail in the early stages anyways (racct/limit checking, compressor_init), but
I decided that that's probably more of a cosmetic issue and punted for now.

This revision now requires review to proceed.Jul 23 2025, 11:30 PM

ninja edit: missed a hunk in patch transfer, s/return/goto done/ if init_fn fails

This revision is now accepted and ready to land.Jul 26 2025, 9:51 AM