summaryrefslogtreecommitdiff
path: root/tools/lib/bpf/libbpf_probes.c
diff options
context:
space:
mode:
authorAndrii Nakryiko <andrii@kernel.org>2023-05-26 01:13:10 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2023-05-26 13:05:32 +0300
commit59842c5451fe830737600276ba9dee4595341d77 (patch)
treef40ea00ac329a8684ab22cdcb9451cc4dcc0b8da /tools/lib/bpf/libbpf_probes.c
parent321a64b328156fd43d3be589c24905a641c7995b (diff)
downloadlinux-59842c5451fe830737600276ba9dee4595341d77.tar.xz
libbpf: Ensure libbpf always opens files with O_CLOEXEC
Make sure that libbpf code always gets FD with O_CLOEXEC flag set, regardless if file is open through open() or fopen(). For the latter this means to add "e" to mode string, which is supported since pretty ancient glibc v2.7. Also drop the outdated TODO comment in usdt.c, which was already completed. Suggested-by: Lennart Poettering <lennart@poettering.net> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20230525221311.2136408-1-andrii@kernel.org
Diffstat (limited to 'tools/lib/bpf/libbpf_probes.c')
-rw-r--r--tools/lib/bpf/libbpf_probes.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/libbpf_probes.c b/tools/lib/bpf/libbpf_probes.c
index 6065f408a59c..5f78a023b474 100644
--- a/tools/lib/bpf/libbpf_probes.c
+++ b/tools/lib/bpf/libbpf_probes.c
@@ -38,7 +38,7 @@ static __u32 get_ubuntu_kernel_version(void)
if (faccessat(AT_FDCWD, ubuntu_kver_file, R_OK, AT_EACCESS) != 0)
return 0;
- f = fopen(ubuntu_kver_file, "r");
+ f = fopen(ubuntu_kver_file, "re");
if (!f)
return 0;