OSDN Git Service

libbpf: Ensure libbpf always opens files with O_CLOEXEC
authorAndrii Nakryiko <andrii@kernel.org>
Thu, 25 May 2023 22:13:10 +0000 (15:13 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 26 May 2023 10:05:32 +0000 (12:05 +0200)
commit59842c5451fe830737600276ba9dee4595341d77
treef40ea00ac329a8684ab22cdcb9451cc4dcc0b8da
parent321a64b328156fd43d3be589c24905a641c7995b
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
tools/lib/bpf/btf.c
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_probes.c
tools/lib/bpf/usdt.c