public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] libbpf: fix probe code to return EPERM if encountered
@ 2020-04-30 10:23 Eelco Chaudron
  2020-04-30 10:49 ` Toke Høiland-Jørgensen
  2020-04-30 18:12 ` Andrii Nakryiko
  0 siblings, 2 replies; 6+ messages in thread
From: Eelco Chaudron @ 2020-04-30 10:23 UTC (permalink / raw)
  To: bpf; +Cc: davem, netdev, ast, daniel, kafai, songliubraving, yhs, andriin,
	toke

When the probe code was failing for any reason ENOTSUP was returned, even
if this was due to no having enough lock space. This patch fixes this by
returning EPERM to the user application, so it can respond and increase
the RLIMIT_MEMLOCK size.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
 tools/lib/bpf/libbpf.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 8f480e29a6b0..a62388a151d4 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -3381,8 +3381,13 @@ 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)
+		if (ret < 0) {
 			pr_debug("Probe #%d failed with %d.\n", i, ret);
+			if (ret == -EPERM) {
+				pr_perm_msg(ret);
+				return ret;
+			}
+		}
 	}
 
 	return 0;


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

end of thread, other threads:[~2020-05-04  8:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-30 10:23 [PATCH bpf-next] libbpf: fix probe code to return EPERM if encountered Eelco Chaudron
2020-04-30 10:49 ` Toke Høiland-Jørgensen
2020-04-30 18:12 ` Andrii Nakryiko
2020-05-01  9:56   ` Eelco Chaudron
2020-05-01 19:16     ` Andrii Nakryiko
2020-05-04  8:57       ` Eelco Chaudron

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