diff options
author | Marco Vedovati <marco.vedovati@crowdstrike.com> | 2023-08-10 23:43:53 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2023-08-14 17:35:32 +0200 |
commit | 8e50750f122e59ea4cab4b4f696ef22b391bedc9 (patch) | |
tree | 199435fd4d8b8feca50d67ac2e031ca79be5446c /tools/lib | |
parent | bpftool: fix perf help message (diff) | |
download | linux-8e50750f122e59ea4cab4b4f696ef22b391bedc9.tar.xz linux-8e50750f122e59ea4cab4b4f696ef22b391bedc9.zip |
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
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/bpf/libbpf.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 17883f5a44b9..b14a4376a86e 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -1978,9 +1978,9 @@ static int bpf_object__read_kconfig_file(struct bpf_object *obj, void *data) return -ENAMETOOLONG; /* gzopen also accepts uncompressed files. */ - file = gzopen(buf, "r"); + file = gzopen(buf, "re"); if (!file) - file = gzopen("/proc/config.gz", "r"); + file = gzopen("/proc/config.gz", "re"); if (!file) { pr_warn("failed to open system Kconfig\n"); |