Bug 13037 - tfork fix issues with waiter process termination
Summary: tfork fix issues with waiter process termination
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Other (show other bugs)
Version: 4.7.0rc5
Hardware: All All
: P5 regression (vote)
Target Milestone: 4.7
Assignee: Ralph Böhme
QA Contact: Samba QA Contact
URL: https://lists.samba.org/archive/samba...
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-16 07:39 UTC by Stefan Metzmacher
Modified: 2017-09-17 16:59 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Metzmacher 2017-09-16 07:39:48 UTC
...
Comment 1 Andrew Bartlett 2017-09-16 18:36:54 UTC
The status_fd created by tfork_start_waiter_and_worker() can be unwittingly shared between the parent process and any other process created with tfork() or fork().

This means that a close() in the parent may not be enough to close the pipe, and so trigger a read in the waiter process (the child), and so the parent will block in the subsequent waitpid() until the FD is eventually closed by the other processes that also hold it, typically by exit(). 

Thankfully tfork() is currently only in use in samba_runcmd_send() with children that exec(), and the FD is set as close-on-exec, but if the process calling it, or a library it uses, calls fork() or a new different use of tfork() while there is an outstanding child, this issue becomes a lockup. 

See the detailed description in the commit message.
Comment 2 Stefan Metzmacher 2017-09-17 16:59:41 UTC
Pushed to v4-7-test with the review from slow@samba.org