All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nuoqi Gui" <gnq25@mails.tsinghua.edu.cn>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 1/2] bpf, verifier: fold reg->var_off into PTR_TO_FLOW_KEYS bounds check
Date: Sat, 06 Jun 2026 11:05:15 +0000	[thread overview]
Message-ID: <20260606110515.F03FF1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260606-c3-01-v3-v3-1-97c51f592f15@mails.tsinghua.edu.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The patch introduces undeclared identifiers (`argno_t`, `argno`, and `reg_arg_name()`), which will cause a fatal compilation error.
--

commit c76d52d074593085f56551ce421dd163632b1f9d
Author: Nuoqi Gui <gnq25@mails.tsinghua.edu.cn>

bpf, verifier: fold reg->var_off into PTR_TO_FLOW_KEYS bounds check

This patch modifies check_flow_keys_access() to fold the constant
reg->var_off.value into the offset before bounds checking, mirroring the
behavior of other pointer types. It also rejects non-constant variable
offsets to prevent out-of-bounds memory accesses.

> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 7fb88e1cd7c4d..28b83a91720c5 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -4997,9 +4997,21 @@ static int check_ctx_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
>  	return err;
>  }
>  
> -static int check_flow_keys_access(struct bpf_verifier_env *env, int off,
> -				  int size)
> +static int check_flow_keys_access(struct bpf_verifier_env *env,
> +				  struct bpf_reg_state *reg, argno_t argno,
> +				  int off, int size)
>  {

[Severity: Low]
Is argno_t a valid type here? I couldn't find a definition for it in the
tree, so this looks like it might cause a build failure.

> +	/* Only a constant offset is allowed here; fold it into off. */
> +	if (!tnum_is_const(reg->var_off)) {
> +		char tn_buf[48];
> +
> +		tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);
> +		verbose(env, "%s invalid variable offset to flow keys: off=%d, var_off=%s\n",
> +			reg_arg_name(env, argno), off, tn_buf);

[Severity: Low]
Does the reg_arg_name() function exist? This seems to reference an undeclared
function which could also prevent the kernel from compiling.

> +		return -EACCES;
> +	}
> +	off += reg->var_off.value;
> +
>  	if (size < 0 || off < 0 ||
>  	    (u64)off + size > sizeof(struct bpf_flow_keys)) {
>  		verbose(env, "invalid access to flow keys off=%d size=%d\n",

[ ... ]

> @@ -6514,7 +6526,7 @@ static int check_mem_access(struct bpf_verifier_env *env, int insn_idx, u32 regn
>  			return -EACCES;
>  		}
>  
> -		err = check_flow_keys_access(env, off, size);
> +		err = check_flow_keys_access(env, reg, argno, off, size);

[Severity: Low]
Is argno declared in the scope of check_mem_access()? Could this be a typo
for regno?

>  		if (!err && t == BPF_READ && value_regno >= 0)
>  			mark_reg_unknown(env, regs, value_regno);
>  	} else if (type_is_sk_pointer(reg->type)) {

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260606-c3-01-v3-v3-0-97c51f592f15@mails.tsinghua.edu.cn?part=1

  reply	other threads:[~2026-06-06 11:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-06 10:50 [PATCH bpf-next v3 0/2] bpf, verifier: fix PTR_TO_FLOW_KEYS constant-offset OOB Nuoqi Gui
2026-06-06 10:50 ` [PATCH bpf-next v3 1/2] bpf, verifier: fold reg->var_off into PTR_TO_FLOW_KEYS bounds check Nuoqi Gui
2026-06-06 11:05   ` sashiko-bot [this message]
2026-06-06 20:33   ` Eduard Zingerman
2026-06-06 10:50 ` [PATCH bpf-next v3 2/2] selftests/bpf: add tests for PTR_TO_FLOW_KEYS offset bounds Nuoqi Gui
2026-06-06 10:57   ` sashiko-bot
2026-06-06 11:32   ` bot+bpf-ci
2026-06-06 20:34   ` Eduard Zingerman
2026-06-07  0:00 ` [PATCH bpf-next v3 0/2] bpf, verifier: fix PTR_TO_FLOW_KEYS constant-offset OOB patchwork-bot+netdevbpf

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=20260606110515.F03FF1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=gnq25@mails.tsinghua.edu.cn \
    --cc=sashiko-reviews@lists.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.