OSDN Git Service

libbpf: Set close-on-exec flag on gzopen
authorMarco Vedovati <marco.vedovati@crowdstrike.com>
Thu, 10 Aug 2023 21:43:53 +0000 (14:43 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 14 Aug 2023 15:35:32 +0000 (17:35 +0200)
commit8e50750f122e59ea4cab4b4f696ef22b391bedc9
tree199435fd4d8b8feca50d67ac2e031ca79be5446c
parent6da4fea89d258ff4816e53345fcbc593104f98ec
libbpf: Set close-on-exec flag on gzopen

Enable the close-on-exec flag when using gzopen. This is especially important
for multithreaded programs making use of libbpf, where a fork + exec could
race with libbpf library calls, potentially resulting in a file descriptor
leaked to the new process. This got missed in 59842c5451fe ("libbpf: Ensure
libbpf always opens files with O_CLOEXEC").

Fixes: 59842c5451fe ("libbpf: Ensure libbpf always opens files with O_CLOEXEC")
Signed-off-by: Marco Vedovati <marco.vedovati@crowdstrike.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230810214350.106301-1-martin.kelly@crowdstrike.com
tools/lib/bpf/libbpf.c