Page MenuHomeFreeBSD

syslogd: reap pipe children on config reload
ClosedPublic

Authored by bapt on Sep 2 2026, 8:56 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Oct 17, 12:55 AM
Unknown Object (File)
Thu, Oct 15, 4:51 AM
Unknown Object (File)
Tue, Oct 13, 1:58 PM
Unknown Object (File)
Sun, Oct 11, 10:06 PM
Unknown Object (File)
Fri, Oct 9, 8:47 PM
Unknown Object (File)
Thu, Oct 8, 9:13 AM
Unknown Object (File)
Tue, Oct 6, 9:06 PM
Unknown Object (File)
Mon, Oct 5, 10:23 AM
Subscribers

Details

Summary

On SIGHUP reload, closelogfiles() frees each F_PIPE filed even when its
pipe process is still running. close_filed() sets f_type to F_UNUSED
before the check, so the condition f_type != F_PIPE is always true and
the filed is freed while its process descriptor is still on the dead
queue and registered in the kqueue. When the child later exits, the
NOTE_EXIT handler dereferences the freed filed (use-after-free) and
never closes the process descriptor, leaving the pipe child as a
persistent zombie.

Capture whether the filed is a pipe with an active process descriptor
before calling close_filed(), and defer the free in that case so the
NOTE_EXIT handler can reap the child and free the filed.

Test Plan

with

*.info         |exec /home/bapt/zombies.sh

the script being

#!/bin/sh
while read -r line; do
    :
done

We ensure the script is spawned:
logger -p info -t test "spawn"
pkill -HUP syslogd

here you are you have your zombies

restart syslogd, they are reaped properly.

Diff Detail

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