From: sashiko-bot@kernel.org
To: "Xu Kuohai" <xukuohai@huaweicloud.com>
Cc: bpf@vger.kernel.org
Subject: Re: [RFC PATCH bpf-next 10/12] bpf: Support attach and detach for SDT observer program
Date: Sat, 27 Jun 2026 17:12:16 +0000 [thread overview]
Message-ID: <20260627171216.D88391F000E9@smtp.kernel.org> (raw)
In-Reply-To: <1b13b561aae721fec70107256228a77fbc0e8987.1782571533.git.xukuohai@huawei.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Trampoline key space collision between SDT probe offsets and BTF Type IDs leading to verifier bypass and arbitrary memory access.
- [Low] Multi-line comment opening is not on its own line, violating BPF subsystem guidelines.
--
commit b1194a14a242f8613863b3524830be07aca1a7e7
Author: Xu Kuohai <xukuohai@huawei.com>
bpf: Support attach and detach for SDT observer program
This commit adds support to attach an SDT observer program by reusing the
bpf trampoline attach and detach mechanism. The trampoline is keyed by
the target program fd and the offset of the probe. The function prototype
is resolved from prog->aux->sdt_probe.
> diff --git a/include/linux/bpf.h b/include/linux/bpf.h
> index 93c196f38b878..6548a2dd76da6 100644
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -1270,6 +1270,12 @@ struct btf_func_model {
> */
> #define BPF_TRAMP_F_INDIRECT BIT(8)
>
> +/* Trampoline is for an SDT probe site: arguments arrive in
> + * BPF registers recorded by the SDT macro at build time,
> + * described by btf_func_model.arg_regs[] instead of ABI order.
> + */
[Severity: Low]
This isn't a bug, but does this multi-line comment follow the preferred
BPF subsystem style?
The opening block comment normally has the text starting on the next line:
/*
* Trampoline is for an SDT probe site: arguments arrive in
* ...
[ ... ]
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 8b2c73bb6c2a8..53897ff1100fa 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
[ ... ]
> +static int bpf_sdt_link_attach(struct bpf_prog *prog)
> +{
[ ... ]
> + err = bpf_link_prime(&sdt_link->link.link, &primer);
> + if (err) {
> + kfree(sdt_link);
> + return err;
> + }
> +
> + /* use orig_off to compute the key as orig_off is unique for each probe */
> + tr_key = bpf_trampoline_compute_key(tgt_prog, NULL, sdt->val.orig_off);
[Severity: Critical]
Does using sdt->val.orig_off here create a risk of trampoline key collisions
with BTF Type IDs?
Looking at bpf_trampoline_compute_key():
include/linux/bpf_verifier.h:bpf_trampoline_compute_key() {
if (tgt_prog)
return ((u64)tgt_prog->aux->id << 32) | btf_id;
...
}
Because the instruction offset is passed in place of the btf_id, an SDT probe
at an offset could generate the exact same 64-bit key as a subprogram with a
BTF Type ID matching that offset.
If both an SDT observer program and an fentry program attach using this same
key, they would share the same trampoline.
Could this allow the verifier to treat arbitrary scalars from the SDT probe
context as trusted pointers if they are passed into the fentry program?
> + tgt_info.tgt_addr = sdt->probe_ip;
> + tgt_info.tgt_name = sdt->val.name;
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1782571533.git.xukuohai@huawei.com?part=10
next prev parent reply other threads:[~2026-06-27 17:12 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-27 22:51 [RFC PATCH bpf-next 00/12] bpf: Introduce static-defined tracing probe for BPF Xu Kuohai
2026-06-27 20:51 ` [syzbot ci] " syzbot ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 01/12] libbpf: Prepare bpf SDT probe section for the linker Xu Kuohai
2026-06-27 17:05 ` sashiko-bot
2026-06-27 22:51 ` [RFC PATCH bpf-next 02/12] libbpf: Introduce bpf SDT probe macros Xu Kuohai
2026-06-27 15:01 ` sashiko-bot
2026-06-27 22:51 ` [RFC PATCH bpf-next 03/12] libbpf: Add bpf_sdt_notes section parser Xu Kuohai
2026-06-27 15:03 ` sashiko-bot
2026-06-27 22:51 ` [RFC PATCH bpf-next 04/12] bpf: Create insn_array map for bpf SDT probe Xu Kuohai
2026-06-27 15:18 ` sashiko-bot
2026-06-27 15:34 ` bot+bpf-ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 05/12] bpf: Collect SDT probe BTF IDs from BTF decl tags Xu Kuohai
2026-06-27 15:20 ` sashiko-bot
2026-06-27 15:34 ` bot+bpf-ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 06/12] bpf: Add type check for SDT probe site Xu Kuohai
2026-06-27 15:04 ` sashiko-bot
2026-06-27 15:22 ` bot+bpf-ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 07/12] bpf: Record probe name in SDT map Xu Kuohai
2026-06-27 15:06 ` sashiko-bot
2026-06-27 22:51 ` [RFC PATCH bpf-next 08/12] libbpf: Add libbpf support to load SDT observer program Xu Kuohai
2026-06-27 15:12 ` sashiko-bot
2026-06-27 22:51 ` [RFC PATCH bpf-next 09/12] bpf: Add kernel " Xu Kuohai
2026-06-27 15:12 ` sashiko-bot
2026-06-27 15:22 ` bot+bpf-ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 10/12] bpf: Support attach and detach for " Xu Kuohai
2026-06-27 17:12 ` sashiko-bot [this message]
2026-06-27 22:51 ` [RFC PATCH bpf-next 11/12] bpf, x86: Add JIT support SDT for probe Xu Kuohai
2026-06-27 15:13 ` sashiko-bot
2026-06-27 15:22 ` bot+bpf-ci
2026-06-27 22:51 ` [RFC PATCH bpf-next 12/12] selftests/bpf: Add tests for bpf SDT probe Xu Kuohai
2026-06-27 15:25 ` sashiko-bot
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=20260627171216.D88391F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=xukuohai@huaweicloud.com \
/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