libbpf: Use O_CLOEXEC uniformly when opening fds
authorKumar Kartikeya Dwivedi <memxor@gmail.com>
Thu, 28 Oct 2021 06:34:58 +0000 (12:04 +0530)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 28 Oct 2021 23:30:07 +0000 (16:30 -0700)
commit92274e24b01b331ef7a4227135933e6163fe94aa
treee7fc60b8c4b80def6d9a9c74cd4b811589ad55ee
parent549a63238603103fa33cecd49487cf6c0f52e503
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
tools/lib/bpf/btf.c
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_probes.c
tools/lib/bpf/linker.c
tools/lib/bpf/xsk.c