public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.19 01/73] libbpf: Do not require executable permission for shared libraries
@ 2022-10-09 22:13 Sasha Levin
  2022-10-09 22:13 ` [PATCH AUTOSEL 5.19 05/73] bpftool: Clear errno after libcap's checks Sasha Levin
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Sasha Levin @ 2022-10-09 22:13 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Hengqi Chen, Goro Fuji, Andrii Nakryiko, Sasha Levin, ast, daniel,
	bpf

From: Hengqi Chen <hengqi.chen@gmail.com>

[ Upstream commit 9e32084ef1c33a87a736d6ce3fcb95b60dac9aa1 ]

Currently, resolve_full_path() requires executable permission for both
programs and shared libraries. This causes failures on distos like Debian
since the shared libraries are not installed executable and Linux is not
requiring shared libraries to have executable permissions. Let's remove
executable permission check for shared libraries.

Reported-by: Goro Fuji <goro@fastly.com>
Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220806102021.3867130-1-hengqi.chen@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/lib/bpf/libbpf.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 266357b1dca1..91bfe42e5cf4 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -11206,15 +11206,17 @@ static const char *arch_specific_lib_paths(void)
 static int resolve_full_path(const char *file, char *result, size_t result_sz)
 {
 	const char *search_paths[3] = {};
-	int i;
+	int i, perm;
 
 	if (str_has_sfx(file, ".so") || strstr(file, ".so.")) {
 		search_paths[0] = getenv("LD_LIBRARY_PATH");
 		search_paths[1] = "/usr/lib64:/usr/lib";
 		search_paths[2] = arch_specific_lib_paths();
+		perm = R_OK;
 	} else {
 		search_paths[0] = getenv("PATH");
 		search_paths[1] = "/usr/bin:/usr/sbin";
+		perm = R_OK | X_OK;
 	}
 
 	for (i = 0; i < ARRAY_SIZE(search_paths); i++) {
@@ -11233,8 +11235,8 @@ static int resolve_full_path(const char *file, char *result, size_t result_sz)
 			if (!seg_len)
 				continue;
 			snprintf(result, result_sz, "%.*s/%s", seg_len, s, file);
-			/* ensure it is an executable file/link */
-			if (access(result, R_OK | X_OK) < 0)
+			/* ensure it has required permissions */
+			if (access(result, perm) < 0)
 				continue;
 			pr_debug("resolved '%s' to '%s'\n", file, result);
 			return 0;
-- 
2.35.1


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

end of thread, other threads:[~2022-10-09 22:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-09 22:13 [PATCH AUTOSEL 5.19 01/73] libbpf: Do not require executable permission for shared libraries Sasha Levin
2022-10-09 22:13 ` [PATCH AUTOSEL 5.19 05/73] bpftool: Clear errno after libcap's checks Sasha Levin
2022-10-09 22:14 ` [PATCH AUTOSEL 5.19 56/73] selftests/bpf: Free the allocated resources after test case succeeds Sasha Levin
2022-10-09 22:14 ` [PATCH AUTOSEL 5.19 64/73] net: If sock is dead don't access sock's sk_wq in sk_stream_wait_memory Sasha Levin
2022-10-09 22:14 ` [PATCH AUTOSEL 5.19 65/73] bpf: Adjust kprobe_multi entry_ip for CONFIG_X86_KERNEL_IBT Sasha Levin
2022-10-09 22:14 ` [PATCH AUTOSEL 5.19 66/73] bpf: use bpf_prog_pack for bpf_dispatcher Sasha Levin
2022-10-09 22:14 ` [PATCH AUTOSEL 5.19 69/73] libbpf: Fix overrun in netlink attribute iteration Sasha Levin

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