From: sashiko-bot@kernel.org
To: "Daniel Borkmann" <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 1/6] bpf: Keep fault protection when merging pointer types
Date: Fri, 14 Aug 2026 22:15:02 +0000 [thread overview]
Message-ID: <20260814221502.880C11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260814215301.709827-1-daniel@iogearbox.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] The verifier fails to emit BPF_PROBE_MEM instructions when a safe pointer type (e.g., PTR_TO_STACK or PTR_TO_MAP_VALUE) and an untrusted memory pointer type (PTR_TO_MEM | PTR_UNTRUSTED) reach the same load instruction via different branches. This completely bypasses the newly introduced merge_ptr_types logic.
--
--- Patch [1]: [PATCH bpf-next v2 1/6] bpf: Keep fault protection when merging pointer types ---
commit f6edd0237d3f5f1dd3f7b1e12e20100d5ce150cd
Author: Daniel Borkmann <daniel@iogearbox.net>
bpf: Keep fault protection when merging pointer types
This commit fixes an issue where merging different pointer types in
save_aux_ptr_type() drops flags like PTR_UNTRUSTED. It introduces
merge_ptr_types() to properly normalize and combine pointer types so that the
BPF_PROBE_MEM rewrite remains intact.
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 6ac1afced20bf..ad6ccd5cf51db 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
[ ... ]
> @@ -17092,20 +17097,12 @@ static int save_aux_ptr_type(struct bpf_verifier_env *env, enum bpf_reg_type typ
> is_ptr_to_mem_or_btf_id(*prev_type)) {
> /*
> * Have to support a use case when one path through
> - * the program yields TRUSTED pointer while another
> - * is UNTRUSTED. Fallback to UNTRUSTED to generate
> - * BPF_PROBE_MEM/BPF_PROBE_MEMSX.
> - * Same behavior of MEM_RDONLY flag.
> + * the program yields a TRUSTED pointer while another
> + * is UNTRUSTED. Merge them into a type which keeps
> + * the BPF_PROBE_MEM/BPF_PROBE_MEMSX rewrite when
> + * either side needs it.
> */
> - if (is_ptr_to_mem(type) || is_ptr_to_mem(*prev_type))
> - merged_type = PTR_TO_MEM;
> - else
> - merged_type = PTR_TO_BTF_ID;
> - if ((type & PTR_UNTRUSTED) || (*prev_type & PTR_UNTRUSTED))
> - merged_type |= PTR_UNTRUSTED;
> - if ((type & MEM_RDONLY) || (*prev_type & MEM_RDONLY))
> - merged_type |= MEM_RDONLY;
> - *prev_type = merged_type;
> + *prev_type = merge_ptr_types(type, *prev_type);
[Severity: Critical]
This is a pre-existing issue, but does this bypass conflict resolution
entirely if reg_type_mismatch() returns false for both types?
If one branch provides a safe pointer (like PTR_TO_STACK) and another branch
provides an untrusted pointer (PTR_TO_MEM | PTR_UNTRUSTED), they evaluate as:
kernel/bpf/verifier.c:reg_type_mismatch() {
return src != prev && (!reg_type_mismatch_ok(src) ||
!reg_type_mismatch_ok(prev));
}
Since neither base type is in the reg_type_mismatch_ok() switch statement,
it returns true for both types, causing reg_type_mismatch() to return false.
If the safe pointer reaches save_aux_ptr_type() first, we wouldn't enter
the else if (reg_type_mismatch(type, *prev_type)) block at all.
Does this mean merge_ptr_types() is skipped, the untrusted pointer type is
silently ignored, and we might fail to emit the required BPF_PROBE_MEM
rewrite?
> } else {
> verbose(env, "same insn cannot be used with different pointers\n");
> return -EINVAL;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260814215301.709827-1-daniel@iogearbox.net?part=1
next prev parent reply other threads:[~2026-08-14 22:15 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 21:52 [PATCH bpf-next v2 1/6] bpf: Keep fault protection when merging pointer types Daniel Borkmann
2026-08-14 21:52 ` [PATCH bpf-next v2 2/6] bpf: Treat a fault prone PTR_TO_MEM as a pointer type mismatch Daniel Borkmann
2026-08-16 19:44 ` Eduard Zingerman
2026-08-14 21:52 ` [PATCH bpf-next v2 3/6] bpf: Reject a store through a fault prone pointer Daniel Borkmann
2026-08-14 22:40 ` bot+bpf-ci
2026-08-14 23:26 ` Daniel Borkmann
2026-08-16 19:54 ` Eduard Zingerman
2026-08-16 20:02 ` Eduard Zingerman
2026-08-14 21:52 ` [PATCH bpf-next v2 4/6] bpf: Rewrite any fault prone load out of a mem or btf_id pointer Daniel Borkmann
2026-08-16 20:06 ` Eduard Zingerman
2026-08-14 21:52 ` [PATCH bpf-next v2 5/6] selftests/bpf: Add tests for pointer type merge at a shared load Daniel Borkmann
2026-08-14 22:56 ` bot+bpf-ci
2026-08-14 23:35 ` Daniel Borkmann
2026-08-16 22:24 ` Eduard Zingerman
2026-08-16 22:32 ` Eduard Zingerman
2026-08-14 21:53 ` [PATCH bpf-next v2 6/6] selftests/bpf: Add tests for fault prone loads out of RCU pointers Daniel Borkmann
2026-08-14 22:03 ` sashiko-bot
2026-08-14 22:28 ` Daniel Borkmann
2026-08-16 22:24 ` Eduard Zingerman
2026-08-14 22:15 ` sashiko-bot [this message]
2026-08-14 22:19 ` [PATCH bpf-next v2 1/6] bpf: Keep fault protection when merging pointer types Daniel Borkmann
2026-08-16 19:42 ` 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=20260814221502.880C11F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--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.