aboutsummaryrefslogtreecommitdiff
path: root/src/netlink.c
diff options
context:
space:
mode:
authorKumar Kartikeya Dwivedi <memxor@gmail.com>2021-03-17 17:28:58 +0530
committerAndrii Nakryiko <andrii.nakryiko@gmail.com>2021-03-25 23:31:23 -0700
commitbbc65156d75ab64180dbf5f1ae93dd4f1a6d3cc8 (patch)
tree01f84d4adb94111a7331e7f5219af4bb5bbe6612 /src/netlink.c
parentc903b3ab70adb8e1afd1c736988838e641c7c0f7 (diff)
downloadlibbpf-bbc65156d75ab64180dbf5f1ae93dd4f1a6d3cc8.tar.gz
libbpf: Use SOCK_CLOEXEC when opening the netlink socket
Otherwise, there exists a small window between the opening and closing of the socket fd where it may leak into processes launched by some other thread. Fixes: 949abbe88436 ("libbpf: add function to setup XDP") Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Toke Høiland-Jørgensen <toke@redhat.com> Link: https://lore.kernel.org/bpf/20210317115857.6536-1-memxor@gmail.com
Diffstat (limited to 'src/netlink.c')
-rw-r--r--src/netlink.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/netlink.c b/src/netlink.c
index 4dd73de..d2cb28e 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -40,7 +40,7 @@ static int libbpf_netlink_open(__u32 *nl_pid)
memset(&sa, 0, sizeof(sa));
sa.nl_family = AF_NETLINK;
- sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
+ sock = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE);
if (sock < 0)
return -errno;