source3/lib/server_prefork.c set socket close on exec
authorGary Lockyer <gary@catalyst.net.nz>
Sun, 10 Dec 2017 20:46:07 +0000 (09:46 +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/lib/server_prefork.c

index 1d64db2af0c66467845a90736be2591c45f62322..52c11ad12fe3e2cc977ffba5382c944ad0039f49 100644 (file)
@@ -620,6 +620,7 @@ static void prefork_listen_accept_handler(struct tevent_context *ev,
                          state->error, strerror(state->error)));
                goto done;
        }
+       smb_set_close_on_exec(sd);
 
        state->accept_fd = sd;