Page MenuHomeFreeBSD

syslogd: do not turn pipe exec process into zombies
Needs ReviewPublic

Authored by bapt on Tue, Sep 1, 2:07 PM.

Details

Reviewers
markj
jfree
Summary

since 95381c0139d6 syslogd don't wait anymore for children pid this
has been replaced with a NOT_EXIT. Fix by reaping the process while their
process descriptor is closed.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76379
Build 73262: arc lint + arc unit

Event Timeline

bapt requested review of this revision.Tue, Sep 1, 2:07 PM
usr.sbin/syslogd/syslogd.c
732

I am confused. We ignore SIGCHLD in the loop below. Per signal(3), this means that zombies will not be created.

After capsicumization, syslogd's casper helper process is responsible for forking children, but the helper process is forked after we call sigaction(SIGCHLD, SIG_IGN), so it should inherit this behaviour.

So there is something missing, is this actually a kernel bug? I will try to reproduce the problem.

3783

We probably want an EN for this bug, so we should avoid using PD_NOWAITPID, as it's a brand new feature and not available in e.g., 15.1.

I can't reproduce any zombie leak if I do something like *.* |sleep 10 in syslog.conf. Do you have some repro steps?

*.* |exec /home/bapt/crap.sh

cat /home/bapt/crap.sh

#!/bin/sh
id
echo plop
sleep 1

It creates defunct for me on latest current without my patch.

*.* |exec /home/bapt/crap.sh

cat /home/bapt/crap.sh

#!/bin/sh
id
echo plop
sleep 1

It creates defunct for me on latest current without my patch.

I do not see any zombies with this repro either. I am running 16.0-CURRENT main-n288767-998f41f01189 GENERIC-KASAN in a VM.

root@freebsd:~ # cat /etc/syslog.conf
*.* |exec /root/crap.sh
root@freebsd:~ # service syslogd restart
Stopping syslogd.
Waiting for PIDS: 5245.
Starting syslogd.
root@freebsd:~ # logger foo && sleep 3
root@freebsd:~ # ps auxwww | grep defunct
root  5349   0.0  0.1 14316  2816  0  S+   17:53     0:00.01 grep defunct
root@freebsd:~ # ps auxwww | grep Z
USER   PID  %CPU %MEM   VSZ   RSS TT  STAT STARTED      TIME COMMAND
root  5351   0.0  0.1 14316  2804  0  S+   17:53     0:00.01 grep Z