All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Lehner <dev@der-flo.net>
To: bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
	yonghong.song@linux.dev, john.fastabend@gmail.com,
	kpsingh@kernel.org, sdf@google.com, haoluo@google.com,
	jolsa@kernel.org, Florian Lehner <dev@der-flo.net>
Subject: [PATCH bpf-next] bpf: Return EINVAL instead of NULL for map_lookup_elem of queue
Date: Sat,  8 Jun 2024 11:29:12 +0200	[thread overview]
Message-ID: <20240608092912.11615-1-dev@der-flo.net> (raw)

Programs should use map_peek_elem over map_lookup_elem for queues. NULL is
also not a valid queue return nor a proper error, that could be handled.

Signed-off-by: Florian Lehner <dev@der-flo.net>
---
 kernel/bpf/queue_stack_maps.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/bpf/queue_stack_maps.c b/kernel/bpf/queue_stack_maps.c
index d869f51ea93a..85bead55024d 100644
--- a/kernel/bpf/queue_stack_maps.c
+++ b/kernel/bpf/queue_stack_maps.c
@@ -234,7 +234,8 @@ static long queue_stack_map_push_elem(struct bpf_map *map, void *value,
 /* Called from syscall or from eBPF program */
 static void *queue_stack_map_lookup_elem(struct bpf_map *map, void *key)
 {
-	return NULL;
+	/* The eBPF program should use map_peek_elem instead */
+	return ERR_PTR(-EINVAL);
 }
 
 /* Called from syscall or from eBPF program */
-- 
2.45.2


             reply	other threads:[~2024-06-08  9:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-08  9:29 Florian Lehner [this message]
2024-06-10  5:32 ` [PATCH bpf-next] bpf: Return EINVAL instead of NULL for map_lookup_elem of queue Yonghong Song
2024-06-11 19:14 ` Alexei Starovoitov

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=20240608092912.11615-1-dev@der-flo.net \
    --to=dev@der-flo.net \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.