BPF List
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>, bpf@vger.kernel.org
Cc: kkd@meta.com, Manu Bretelle <chantra@meta.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@kernel.org>,
	 kernel-team@fb.com
Subject: Re: [PATCH bpf v2 1/2] bpf: Suppress warning for non-zero off raw_tp arg NULL check
Date: Thu, 05 Dec 2024 16:00:21 -0800	[thread overview]
Message-ID: <e991f994d9e24b146526b57ae038d7abd5fa1239.camel@gmail.com> (raw)
In-Reply-To: <20241205223152.2434683-2-memxor@gmail.com>

On Thu, 2024-12-05 at 14:31 -0800, Kumar Kartikeya Dwivedi wrote:

[...]

> Fixes: cb4158ce8ec8 ("bpf: Mark raw_tp arguments with PTR_MAYBE_NULL")
> Reported-by: Manu Bretelle <chantra@meta.com>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> ---

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

I think this should work.
Although, I'm not sure if we should delay generic fix and do this in two steps.

>  kernel/bpf/verifier.c | 38 ++++++++++++++++++++++++++++++--------
>  1 file changed, 30 insertions(+), 8 deletions(-)
> 
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 2fd35465d650..dea92cac2522 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -15340,7 +15340,8 @@ static int reg_set_min_max(struct bpf_verifier_env *env,
>  	return err;
>  }
>  
> -static void mark_ptr_or_null_reg(struct bpf_func_state *state,
> +static void mark_ptr_or_null_reg(struct bpf_verifier_env *env,
> +				 struct bpf_func_state *state,
>  				 struct bpf_reg_state *reg, u32 id,
>  				 bool is_null)
>  {
> @@ -15357,8 +15358,8 @@ static void mark_ptr_or_null_reg(struct bpf_func_state *state,
>  		 */
>  		if (WARN_ON_ONCE(reg->smin_value || reg->smax_value || !tnum_equals_const(reg->var_off, 0)))
>  			return;
> -		if (!(type_is_ptr_alloc_obj(reg->type) || type_is_non_owning_ref(reg->type)) &&
> -		    WARN_ON_ONCE(reg->off))
> +		if (!(type_is_ptr_alloc_obj(reg->type) || type_is_non_owning_ref(reg->type) ||
> +		    mask_raw_tp_reg_cond(env, reg)) && WARN_ON_ONCE(reg->off))

Nit: the condition is a bit hard to read, maybe rewrite it as follows:

		if (!type_is_ptr_alloc_obj(reg->type) &&
		    !type_is_non_owning_ref(reg->type) &&
		    !mask_raw_tp_reg_cond(env, reg) &&
		    WARN_ON_ONCE(reg->off))
			return;

     ?

>  			return;
>  
>  		if (is_null) {

[...]


  reply	other threads:[~2024-12-06  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-05 22:31 [PATCH bpf v2 0/2] Fix for raw_tp PTR_MAYBE_NULL unmarking Kumar Kartikeya Dwivedi
2024-12-05 22:31 ` [PATCH bpf v2 1/2] bpf: Suppress warning for non-zero off raw_tp arg NULL check Kumar Kartikeya Dwivedi
2024-12-06  0:00   ` Eduard Zingerman [this message]
2024-12-05 22:31 ` [PATCH bpf v2 2/2] selftests/bpf: Add raw_tp tests for PTR_MAYBE_NULL marking Kumar Kartikeya Dwivedi
2024-12-06  0:08   ` Eduard Zingerman

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=e991f994d9e24b146526b57ae038d7abd5fa1239.camel@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chantra@meta.com \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=kkd@meta.com \
    --cc=martin.lau@kernel.org \
    --cc=memxor@gmail.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