aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/netlink.c
diff options
context:
space:
mode:
authorKumar Kartikeya Dwivedi <[email protected]>2021-03-17 11:58:58 +0000
committerDaniel Borkmann <[email protected]>2021-03-17 23:50:21 +0000
commit58bfd95b554f1a23d01228672f86bb489bdbf4ba (patch)
tree1e62f2aa641a6d19717b5ae4fd6a7becde548892 /tools/lib/bpf/netlink.c
parentlibbpf: Fix error path in bpf_object__elf_init() (diff)
downloadkernel-58bfd95b554f1a23d01228672f86bb489bdbf4ba.tar.gz
kernel-58bfd95b554f1a23d01228672f86bb489bdbf4ba.zip
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 <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Toke Høiland-Jørgensen <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/lib/bpf/netlink.c')
-rw-r--r--tools/lib/bpf/netlink.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/netlink.c b/tools/lib/bpf/netlink.c
index 4dd73de00b6f..d2cb28e9ef52 100644
--- a/tools/lib/bpf/netlink.c
+++ b/tools/lib/bpf/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;