ctdb/server/ctdb_daemon.c set socket close on exec
authorGary Lockyer <gary@catalyst.net.nz>
Sun, 10 Dec 2017 20:36:08 +0000 (09:36 +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>
ctdb/server/ctdb_daemon.c

index 459dd2932ee27bcc628c57ea91aa37a1f6319c8c..35c1ab639b5f56ccf1160ff1bb086373b035d2f6 100644 (file)
@@ -949,6 +949,7 @@ static void ctdb_accept_client(struct tevent_context *ev,
        if (fd == -1) {
                return;
        }
+       smb_set_close_on_exec(fd);
 
        ret = set_blocking(fd, false);
        if (ret != 0) {