diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2021-10-28 12:04:58 +0530 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2021-10-28 16:30:07 -0700 |
commit | 92274e24b01b331ef7a4227135933e6163fe94aa (patch) | |
tree | e7fc60b8c4b80def6d9a9c74cd4b811589ad55ee /tools/lib/bpf/libbpf_probes.c | |
parent | libbpf: Ensure that BPF syscall fds are never 0, 1, or 2 (diff) | |
download | linux-92274e24b01b331ef7a4227135933e6163fe94aa.tar.xz linux-92274e24b01b331ef7a4227135933e6163fe94aa.zip |
libbpf: Use O_CLOEXEC uniformly when opening fds
There are some instances where we don't use O_CLOEXEC when opening an
fd, fix these up. Otherwise, it is possible that a parallel fork causes
these fds to leak into a child process on execve.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211028063501.2239335-6-memxor@gmail.com
Diffstat (limited to 'tools/lib/bpf/libbpf_probes.c')
-rw-r--r-- | tools/lib/bpf/libbpf_probes.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/libbpf_probes.c b/tools/lib/bpf/libbpf_probes.c index cd8c703dde71..68f2dbf364aa 100644 --- a/tools/lib/bpf/libbpf_probes.c +++ b/tools/lib/bpf/libbpf_probes.c @@ -33,7 +33,7 @@ static int get_vendor_id(int ifindex) snprintf(path, sizeof(path), "/sys/class/net/%s/device/vendor", ifname); - fd = open(path, O_RDONLY); + fd = open(path, O_RDONLY | O_CLOEXEC); if (fd < 0) return -1; |