public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Eelco Chaudron <echaudro@redhat.com>
To: bpf@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, ast@kernel.org,
	daniel@iogearbox.net, kafai@fb.com, songliubraving@fb.com,
	yhs@fb.com, andriin@fb.com, toke@redhat.com
Subject: [PATCH bpf-next] libbpf: fix probe code to return EPERM if encountered
Date: Thu, 30 Apr 2020 12:23:34 +0200	[thread overview]
Message-ID: <158824221003.2338.9700507405752328930.stgit@ebuild> (raw)

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;


             reply	other threads:[~2020-04-30 10:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-30 10:23 Eelco Chaudron [this message]
2020-04-30 10:49 ` [PATCH bpf-next] libbpf: fix probe code to return EPERM if encountered 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=158824221003.2338.9700507405752328930.stgit@ebuild \
    --to=echaudro@redhat.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=toke@redhat.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox