Race condition in tdb_runtime_check_for_robust_mutexes()

Uri Simchoni uri at samba.org
Wed Mar 23 08:56:06 UTC 2016

On 03/23/2016 10:30 AM, Ralph Boehme wrote:
> On Wed, Mar 23, 2016 at 07:36:53AM +0200, Uri Simchoni wrote:
>> OK I've figured out why we want the waitpid() in the signal handler - we
>> want to catch the child terminating yet still support SIGCHLD handling of
>> the enclosing process.
>> Hopefully I'll submit a patch shortly.
> I just briefly looked over this, so I might be missing something, but
> afaict we could block SIGCHLD, getting rid of our own signal handler
> and thus getting rid of the race between two calls to waitpid().
> -Ralph
We have to make sure SIGCHLD is not set to SIG_IGN or we won't be able 
to waitpid().

An alternative approach to today's signal handler might be:
1. block SIGCHLD
2. set SIGCHLD handler to SIG_DFL - this makes sure it's not SIG_IGN
3. fork, do handshake, waitpid()
4. restore signal handler
5. restore signal mask

It's certainly less code, given that a fix that maintains the current 
signal handler also has to temporarily block SIGCHLD in order to avoid 
the race.

Perhaps the intent of the existing signal handler is to leave absolutely 
no trace of this child process - if there is a pre-installed signal 
handler, after we unblock SIGCHLD it will see something that looks like 
a spurious SIGCHLD.

Currently I'm testing a fix that leaves the signal handler as-is and 
hopefully fixes the issue.


More information about the samba-technical mailing list