BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: Philo Lu <lulie@linux.alibaba.com>, 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, kpsingh@kernel.org, sdf@google.com,
	haoluo@google.com, jolsa@kernel.org, mykolal@fb.com,
	shuah@kernel.org, xuanzhuo@linux.alibaba.com
Subject: Re: [PATCH bpf-next 2/3] bpf: allow invoking bpf_for_each_map_elem with different maps
Date: Thu, 4 Apr 2024 15:15:06 -0700	[thread overview]
Message-ID: <2814f3b7-1254-4031-8c57-682963f1e6d1@linux.dev> (raw)
In-Reply-To: <20240402061615.48894-3-lulie@linux.alibaba.com>


On 4/1/24 11:16 PM, Philo Lu wrote:
> 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 */

Maybe change comments to below?
	/* valid map_ptr and poison value does not matter */

>   	map = insn_aux->map_ptr_state.map_ptr;
>   	if (!map->ops->map_set_for_each_callback_args ||
>   	    !map->ops->map_for_each_callback) {

  reply	other threads:[~2024-04-04 22:15 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 ` [PATCH bpf-next 2/3] bpf: allow invoking bpf_for_each_map_elem with different maps Philo Lu
2024-04-04 22:15   ` Yonghong Song [this message]
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=2814f3b7-1254-4031-8c57-682963f1e6d1@linux.dev \
    --to=yonghong.song@linux.dev \
    --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=lulie@linux.alibaba.com \
    --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 \
    /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