From: sashiko-bot@kernel.org
To: "Eduard Zingerman" <eddyz87@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf 01/10] bpf: mark a NULL call argument precise
Date: Sat, 05 Sep 2026 00:21:31 +0000 [thread overview]
Message-ID: <20260905002131.DFEAF1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904-register-is-null-precise-fixes-v1-1-0f5a360ff15d@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] This problem wasn't introduced by this patch, but the patch and the series fail to fix it while fixing identical vulnerabilities elsewhere. Missing precision tracking for nullable arguments was fixed in `check_func_arg()`, `check_helper_call()`, `check_kfunc_args()`, and `btf_check_func_arg_match()`. However, the exact same vulnerability remains in `check_map_kptr_access()`. When storing a NULL value into a kptr map field via `BPF_STX`, `check_map_kptr_access()` checks `bpf_register_is_null(val_reg)` to bypass pointer type validation. Because it skips validation on a NULL scalar without calling `mark_chain_precision()`, a checkpoint created with a NULL scalar in `val_reg` will incorrectly prune a subsequent path where `val_reg` holds an arbitrary, unconstrained scalar value. At runtime, this pruned path will execute and write an invalid scalar into the kptr field. When the map is later freed, the kernel will attempt to drop the kptr by treating the invalid scalar as a valid pointer, resulting in arbitrary kernel memory corruption.
--
commit a287fdd95b87b267c8cbd45bc11d4088d9532eb9
Author: Eduard Zingerman <eddyz87@gmail.com>
bpf: mark a NULL call argument precise
This commit fixes verifier pruning logic by marking NULL call arguments precise
in check_func_arg() and check_helper_call(). This prevents the verifier from
incorrectly pruning paths with unconstrained scalars against checkpoints with
NULL scalars.
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 9c6ad157a61ec..ca362a7ea58c3 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -8752,11 +8752,15 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg,
> return err;
> }
>
> - if (bpf_register_is_null(reg) && type_may_be_null(arg_type))
> + if (bpf_register_is_null(reg) && type_may_be_null(arg_type)) {
> /* A NULL register has a SCALAR_VALUE type, so skip
> * type checking.
> */
> + err = mark_chain_precision(env, regno);
> + if (err)
> + return err;
> goto skip_type_check;
> + }
[Severity: Critical]
This isn't a bug introduced by this patch, but the series appears to miss
an identical vulnerability in check_map_kptr_access().
When storing a NULL value into a kptr map field via BPF_STX,
check_map_kptr_access() checks bpf_register_is_null(val_reg) to bypass
pointer type validation:
kernel/bpf/verifier.c:check_map_kptr_access()
} else if (class == BPF_STX) {
val_reg = reg_state(env, value_regno);
if (!bpf_register_is_null(val_reg) &&
map_kptr_match_type(env, kptr_field, val_reg, value_regno))
return -EACCES;
}
Because it skips validation on a NULL scalar without calling
mark_chain_precision(), a checkpoint created with a NULL scalar in val_reg
could incorrectly prune a subsequent path where val_reg holds an arbitrary,
unconstrained scalar value.
At runtime, this pruned path could execute and write an invalid scalar into
the kptr field. When the map is later freed, the kernel would attempt to drop
the kptr by treating the invalid scalar as a valid pointer.
Could this lead to arbitrary kernel memory corruption? Should
mark_chain_precision() be called on value_regno when
bpf_register_is_null(val_reg) is true here as well?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-register-is-null-precise-fixes-v1-0-0f5a360ff15d@gmail.com?part=1
next prev parent reply other threads:[~2026-09-05 0:21 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 [this message]
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
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=20260905002131.DFEAF1F00A3D@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