mirror of
https://github.com/netdata/libbpf.git
synced 2026-03-21 16:59:07 +08:00
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
This commit is contained in:
committed by
Andrii Nakryiko
parent
cd85f34103
commit
20699ecf61
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user