Random failures starting clamav-milter [patch]
Author: tlhackqueCreated Dec 27, 2022Updated Aug 30, 2026
Describe the bug
Seeming random failures for clamav-milter to start; hangs in startup.
clamav 0.103.7, but this is a long-standing bug.
How to reproduce the problem
Unfortunately, that's tough.
I happened to move clamav-milter to a machine where the timing made it 100% reproducible; previously the failures were very rare.
The issues are dependent on timing and environment.
daemonize_parent_wait()forks, then sets up a signal handler so the child can signal initialization complete. If the child sends the signal first, the parent (usually) exits due to the unhandled signal, not the planned wait.- Worse,
daemonize_signal_parent()drops privileges before sending the complete signal. Now the unpriv'd child tries to signal the still priv'd parent, and thekill()fails silently. In this case, the parent hangs forevever. - Finally, if the child doesn't exit but dies from a signal while the parent waits, the caller in the parent doesn't get an error return, and things get weird.
The attached patch resolves these issues.
- The child now signals the parent just before dropping privileges, so the
kill()will succeed. - The parent sets up its signal handler before
fork(), resolving the race with the child. - The proper error error code is returned if the child dies unexpectedly while the parent is waiting for it to initialize.
Attachments
Source: Cisco-Talos/clamav