Re: [PATCH bpf-next v1 01/14] bpf: Correct verifier diagnostic attribution for stack reads

Eduard Zingerman <[email protected]>
Newsgroups org.kernel.vger.bpf
Message-ID <[email protected]>
On Sun, 2026-08-16 at 03:57 +0200, Kumar Kartikeya Dwivedi wrote:

...

> @@ -4079,13 +4106,13 @@ static int check_stack_read(struct bpf_verifier_env *env,
>  		tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);
>  		verbose(env, "variable offset stack pointer cannot be passed into helper function; var_off=%s off=%d size=%d\n",
>  			tn_buf, off, size);
> -		reason = bpf_diag_fmt(env,
> -				      "The helper would access the stack through variable offset %s plus fixed offset %d and size %d. "
> -			"Helper stack memory arguments require a constant stack offset and a precise initialized range.",
> +		reason = bpf_diag_fmt(
> +			env, "The atomic operation would access the stack through variable offset %s plus fixed offset %d and size %d. "
> +			"Atomic stack operations require a constant stack offset and a precise initialized range.",

Relying on value_regno being -1 only for atomic operations is very fragile.
Let's at-least make a comment. Or make the wording neutral,
like "instruction variable offset access ..." (best).
Or check the actual instruction and vary wording.

>  			tn_buf, off, size);
>  		bpf_diag_memory(
> -			env, env->insn_idx, "variable stack access", reason,
> -			"Use a fixed stack offset for helper memory arguments, or copy the needed bytes into a fixed stack slot first.");
> +			env, env->insn_idx, "variable-offset atomic stack access", reason,
> +			"Use a fixed stack offset for the atomic operation, selecting the target stack slot on separate control-flow paths if necessary.");
>  		return -EACCES;
>  	}
>  	/* Variable offset is prohibited for unprivileged mode for simplicity
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.