diff options
author | Kumar Kartikeya Dwivedi <memxor@gmail.com> | 2021-10-28 09:34:58 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2021-10-29 02:30:07 +0300 |
commit | 92274e24b01b331ef7a4227135933e6163fe94aa (patch) | |
tree | e7fc60b8c4b80def6d9a9c74cd4b811589ad55ee /tools/lib/bpf/btf.c | |
parent | 549a63238603103fa33cecd49487cf6c0f52e503 (diff) | |
download | linux-92274e24b01b331ef7a4227135933e6163fe94aa.tar.xz |
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/btf.c')
-rw-r--r-- | tools/lib/bpf/btf.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c index 0c628c33e23b..7e4c5586bd87 100644 --- a/tools/lib/bpf/btf.c +++ b/tools/lib/bpf/btf.c @@ -897,7 +897,7 @@ static struct btf *btf_parse_elf(const char *path, struct btf *base_btf, return ERR_PTR(-LIBBPF_ERRNO__LIBELF); } - fd = open(path, O_RDONLY); + fd = open(path, O_RDONLY | O_CLOEXEC); if (fd < 0) { err = -errno; pr_warn("failed to open %s: %s\n", path, strerror(errno)); |