BPF List
 help / color / mirror / Atom feed
* [PATCH] libbpf: don't preserve ownership during install
@ 2026-07-28  7:14 Martin Kaiser
  2026-07-28  7:25 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Kaiser @ 2026-07-28  7:14 UTC (permalink / raw)
  To: Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Kumar Kartikeya Dwivedi, Martin KaFai Lau,
	Song Liu, Yonghong Song, Jiri Olsa, Emil Tsalapatis
  Cc: Martin Kaiser, Florian Schmaus, bpf, linux-kernel

When a libbpf build is integrated into build systems like Yocto, the
source tree might be owned by a non-root developer user.

The install_lib target in libbpf's Makefile uses cp -p to copy libraries
and preserve ownership. This leaks the UID of the source tree owner into
the root filesystem where the libraries are installed.

Update the cp command to preserve only mode and timestamps. The copied
files will then be owned by the installing user.

Suggested-by: Florian Schmaus <flo@geekplace.eu>
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
 tools/lib/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index eca584fb061e..0a344ca4e108 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -231,7 +231,7 @@ endef
 install_lib: all_cmd
 	$(call QUIET_INSTALL, $(LIB_TARGET)) \
 		$(call do_install_mkdir,$(libdir_SQ)); \
-		cp -fpR $(LIB_FILE) $(DESTDIR)$(libdir_SQ)
+		cp -fR --preserve=mode,timestamps $(LIB_FILE) $(DESTDIR)$(libdir_SQ)
 
 SRC_HDRS := bpf.h libbpf.h btf.h libbpf_common.h libbpf_legacy.h	     \
 	    bpf_helpers.h bpf_tracing.h bpf_endian.h bpf_core_read.h	     \
-- 
2.43.7


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-28  8:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-28  7:14 [PATCH] libbpf: don't preserve ownership during install Martin Kaiser
2026-07-28  7:25 ` sashiko-bot
2026-07-28  8:22   ` Martin Kaiser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox