]> www.infradead.org Git - users/jedix/linux-maple.git/commit
libbpf: keep FD_CLOEXEC flag when dup()'ing FD
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 29 May 2024 22:32:39 +0000 (15:32 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 1 Jun 2024 03:35:55 +0000 (20:35 -0700)
commit531876c80004ecff7bfdbd8ba6c6b48835ef5e22
tree2155c4d8b9eae681b2ac8081c12d43ce80c7c6e5
parent3f8fde319524411b96badee3c96f35831300388a
libbpf: keep FD_CLOEXEC flag when dup()'ing FD

Make sure to preserve and/or enforce FD_CLOEXEC flag on duped FDs.
Use dup3() with O_CLOEXEC flag for that.

Without this fix libbpf effectively clears FD_CLOEXEC flag on each of BPF
map/prog FD, which is definitely not the right or expected behavior.

Reported-by: Lennart Poettering <lennart@poettering.net>
Fixes: bc308d011ab8 ("libbpf: call dup2() syscall directly")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20240529223239.504241-1-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/libbpf_internal.h