]> git.kaiwu.me - haproxy.git/commit
BUG/MINOR: sockpair: set FD_CLOEXEC on fd received via SCM_RIGHTS
authorWilliam Lallemand <wlallemand@haproxy.com>
Mon, 16 Mar 2026 15:08:45 +0000 (16:08 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Mon, 16 Mar 2026 15:31:58 +0000 (16:31 +0100)
commitab7acdcc3a01afc3bf9988bf00b25dd6a4152c59
tree61c33b7c17389b0dfa831e343d73842eef0be723
parenta3bf0de6518e6a32eeafecd8b78dc8514cb63d53
BUG/MINOR: sockpair: set FD_CLOEXEC on fd received via SCM_RIGHTS

FDs received through recv_fd_uxst() do not have FD_CLOEXEC set.
The equivalent sock_accept_conn() already handles this correctly:
any FD accepted or received in the master must be marked close-on-exec
to avoid leaking it across the execvp() performed on soft-reload.

This is currently triggering a leak in the master since 3.1: the worker
sends a socketpair fd to the master  to issue the _send_status CLI
command, and recv_fd_uxst() receive it without setting FD_CLOEXEC.  If a
re-exec is emitted before the master had the chance to close that fd, it
survives execvp() and appears as an untracked unnamed AF_UNIX socket in
the new master generation.

This must be backported to all maintained branches.
src/proto_sockpair.c