From: Philo Lu <lulie@linux.alibaba.com>
To: bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com,
song@kernel.org, yonghong.song@linux.dev, kpsingh@kernel.org,
sdf@google.com, haoluo@google.com, jolsa@kernel.org,
mykolal@fb.com, shuah@kernel.org, xuanzhuo@linux.alibaba.com
Subject: [PATCH bpf-next 2/3] bpf: allow invoking bpf_for_each_map_elem with different maps
Date: Tue, 2 Apr 2024 14:16:14 +0800 [thread overview]
Message-ID: <20240402061615.48894-3-lulie@linux.alibaba.com> (raw)
In-Reply-To: <20240402061615.48894-1-lulie@linux.alibaba.com>
Taking different maps within a single bpf_for_each_map_elem call is not
allowed before, because from the second map,
bpf_insn_aux_data->map_ptr_state will be marked as *poison*. In fact
both map_ptr and state are needed to support this use case: map_ptr is
used by set_map_elem_callback_state() while poison state is needed to
determine whether to use direct call.
Signed-off-by: Philo Lu <lulie@linux.alibaba.com>
---
kernel/bpf/verifier.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 515ac6165ab1..f0a33f7c2604 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -9649,11 +9649,7 @@ static int set_map_elem_callback_state(struct bpf_verifier_env *env,
struct bpf_map *map;
int err;
- if (bpf_map_ptr_poisoned(insn_aux)) {
- verbose(env, "tail_call abusing map_ptr\n");
- return -EINVAL;
- }
-
+ /* should not check poison */
map = insn_aux->map_ptr_state.map_ptr;
if (!map->ops->map_set_for_each_callback_args ||
!map->ops->map_for_each_callback) {
--
2.32.0.3.g01195cf9f
next prev parent reply other threads:[~2024-04-02 6:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-02 6:16 [PATCH bpf-next 0/3] bpf: allow bpf_for_each_map_elem() helper with different input maps Philo Lu
2024-04-02 6:16 ` [PATCH bpf-next 1/3] bpf: store both map ptr and state in bpf_insn_aux_data Philo Lu
2024-04-04 22:08 ` Yonghong Song
2024-04-02 6:16 ` Philo Lu [this message]
2024-04-04 22:15 ` [PATCH bpf-next 2/3] bpf: allow invoking bpf_for_each_map_elem with different maps Yonghong Song
2024-04-02 6:16 ` [PATCH bpf-next 3/3] selftests/bpf: add test for bpf_for_each_map_elem() " Philo Lu
2024-04-04 22:35 ` Yonghong Song
2024-04-05 2:05 ` Philo Lu
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=20240402061615.48894-3-lulie@linux.alibaba.com \
--to=lulie@linux.alibaba.com \
--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=mykolal@fb.com \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=xuanzhuo@linux.alibaba.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox