winbind: Fix a race between the sigchld and 0-sized socket read
commit49adb5ac8fed5ec972bf3907169d2efd378970ca
authorVolker Lendecke <vl@samba.org>
Mon, 26 Feb 2018 14:12:14 +0000 (26 15:12 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 1 Mar 2018 08:53:46 +0000 (1 09:53 +0100)
tree81e0c5501fdb5a5c1fc2d5f5e4d846af297b20b7
parent33f5f5c4610f1a249c2dc88848e4262e2f343c94
winbind: Fix a race between the sigchld and 0-sized socket read

Fix a bug when a child dies when a request is pending in the child. If the
signal handler fires before epoll finds out the other end of the parent-child
socket is closed, we close the socket on our side without taking care of the
pending request. This causes two problems: First, that one pending request
never is replied to properly, and secondly, we might end up with EPOLL_DEL on a
wrong file descriptor. This causes all sorts of trouble if we hit an active
one.

The fix for this problem is not to close the socket in winbind_child_died().
This however stops an idle child that dies hard from being properly cleaned up.
The fix for that is to add the child->monitor_fde that is set pending only when
no child request is active. This way we can remove the close(sock) in the
signal handler.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13309

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/winbindd/winbindd.h
source3/winbindd/winbindd_dual.c