source3/winbindd/winbindd.c set socket close on exec
authorGary Lockyer <gary@catalyst.net.nz>
Sun, 10 Dec 2017 20:58:59 +0000 (09:58 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 18 Dec 2017 03:38:20 +0000 (04:38 +0100)
Set SOCKET_CLOEXEC on the sockets returned by accept.  This ensures that
the socket is unavailable to any child process created by system().
Making it harder for malicious code to set up a command channel,
as seen in the exploit for CVE-2015-0240

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/winbindd/winbindd.c

index 23e8a5ede5e218c78773d722abe129eedb75e945..fc7c1691873f76195531bcd4f004a7e45ed6ef8a 100644 (file)
@@ -874,6 +874,7 @@ static void new_connection(int listen_sock, bool privileged)
                }
                return;
        }
+       smb_set_close_on_exec(sock);
 
        DEBUG(6,("accepted socket %d\n", sock));