diff mbox series

[bpf] libbpf: don't fail when feature probing fails

Message ID 20190515033849.62059-1-sdf@google.com
State Accepted
Delegated to: BPF Maintainers
Headers show
Series [bpf] libbpf: don't fail when feature probing fails | expand

Commit Message

Stanislav Fomichev May 15, 2019, 3:38 a.m. UTC
Otherwise libbpf is unusable from unprivileged process with
kernel.kernel.unprivileged_bpf_disabled=1.
All I get is EPERM from the probes, even if I just want to
open an ELF object and look at what progs/maps it has.

Instead of dying on probes, let's just pr_debug the error and
try to continue.

Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel Borkmann May 15, 2019, 11:42 p.m. UTC | #1
On 05/15/2019 05:38 AM, Stanislav Fomichev wrote:
> Otherwise libbpf is unusable from unprivileged process with
> kernel.kernel.unprivileged_bpf_disabled=1.
> All I get is EPERM from the probes, even if I just want to
> open an ELF object and look at what progs/maps it has.
> 
> Instead of dying on probes, let's just pr_debug the error and
> try to continue.
> 
> Signed-off-by: Stanislav Fomichev <sdf@google.com>

Good catch, applied, thanks!
diff mbox series

Patch

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 7e3b79d7c25f..3562b6ef5fdc 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -1696,7 +1696,7 @@  bpf_object__probe_caps(struct bpf_object *obj)
 	for (i = 0; i < ARRAY_SIZE(probe_fn); i++) {
 		ret = probe_fn[i](obj);
 		if (ret < 0)
-			return ret;
+			pr_debug("Probe #%d failed with %d.\n", i, ret);
 	}
 
 	return 0;