BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Eduard Zingerman" <eddyz87@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf 03/10] bpf: mark a NULL memory argument of a call precise
Date: Sat, 05 Sep 2026 00:23:57 +0000	[thread overview]
Message-ID: <20260905002358.04E2E1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904-register-is-null-precise-fixes-v1-3-0f5a360ff15d@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Uninitialized variable `known_memory` is read on the error path in `check_kfunc_args` when handling NULL memory arguments.
--

commit 00db4f1dea6ce217e9633f69c742a410441956c2
Author: Eduard Zingerman <eddyz87@gmail.com>

bpf: mark a NULL memory argument of a call precise

This commit ensures that a NULL memory argument is correctly marked precise 
to prevent pruning against arbitrary scalar values. It also introduces a new
mark_arg_precision() helper to handle arguments that reside on the stack.

> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index ca362a7ea58c3..b758f28227540 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c

[ ... ]

> @@ -7168,7 +7177,7 @@ static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg
>  	int size, err = 0;
>  
>  	if (bpf_register_is_null(reg))
> -		return 0;
> +		return mark_arg_precision(env, argno);

[Severity: Medium]
Does this early return path leave the `known_memory` pointer uninitialized 
if `mark_arg_precision()` fails?

Looking at its caller in `check_kfunc_args()`, `known_memory` is declared
without initialization:

kernel/bpf/verifier.c:check_kfunc_args() {
	...
	bool known_memory;
	...
	ret = check_mem_reg(env, reg, argno, type_size, BPF_READ | BPF_WRITE,
			    meta, &known_memory);
	if (ret < 0) {
		...
		if (known_memory)
			verbose(env, "...");
		else
			verbose(env, "...");
		return ret;
	}
	...
}

If `mark_arg_precision()` returns a negative error code (like `-EFAULT` from 
backtracking depth limits), `check_mem_reg()` will propagate it immediately 
before reaching the `if (known_memory) *known_memory = true;` block. 

Could this cause `check_kfunc_args()` to evaluate an uninitialized boolean 
variable when deciding which diagnostic message to print on the error path?

>  	if (known_memory)
>  		*known_memory = true;
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-register-is-null-precise-fixes-v1-0-0f5a360ff15d@gmail.com?part=3

  reply	other threads:[~2026-09-05  0:23 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-05  0:05 [PATCH bpf 00/10] bpf: add missing precision propagation after bpf_register_is_null calls Eduard Zingerman
2026-09-05  0:05 ` [PATCH bpf 01/10] bpf: mark a NULL call argument precise Eduard Zingerman
2026-09-05  0:21   ` sashiko-bot
2026-09-05  0:05 ` [PATCH bpf 02/10] selftests/bpf: precision of a NULL helper argument Eduard Zingerman
2026-09-05  0:05 ` [PATCH bpf 03/10] bpf: mark a NULL memory argument of a call precise Eduard Zingerman
2026-09-05  0:23   ` sashiko-bot [this message]
2026-09-05  0:51   ` bot+bpf-ci
2026-09-05  0:05 ` [PATCH bpf 04/10] selftests/bpf: precision of a NULL global subprogram memory argument Eduard Zingerman
2026-09-05  0:51   ` bot+bpf-ci
2026-09-05  0:05 ` [PATCH bpf 05/10] bpf: mark a NULL kfunc argument precise Eduard Zingerman
2026-09-05  0:51   ` bot+bpf-ci
2026-09-05  0:05 ` [PATCH bpf 06/10] selftests/bpf: precision of a NULL kfunc argument Eduard Zingerman
2026-09-05  0:05 ` [PATCH bpf 07/10] bpf: mark a NULL BTF_ID argument of a global subprogram precise Eduard Zingerman
2026-09-05  0:19   ` sashiko-bot
2026-09-05  0:05 ` [PATCH bpf 08/10] selftests/bpf: precision of a NULL global subprogram BTF_ID argument Eduard Zingerman
2026-09-05  0:06 ` [PATCH bpf 09/10] bpf: propagate mark_chain_precision() errors out of loop_flag_is_zero() Eduard Zingerman
2026-09-05  0:06 ` [PATCH bpf 10/10] bpf: use mark_arg_precision() in check_mem_size_reg() Eduard Zingerman
2026-09-05  0:51   ` bot+bpf-ci
2026-09-05  1:20 ` [PATCH bpf 00/10] bpf: add missing precision propagation after bpf_register_is_null calls 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=20260905002358.04E2E1F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox