From: sashiko-bot@kernel.org
To: "Alan Maguire" <almagui@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v2 bpf-next 2/5] libbpf: Support CO-RE relocation of tracing program arguments
Date: Wed, 25 Nov 2026 17:16:29 +0000 [thread overview]
Message-ID: <sashiko-outbox-233822@kernel.org> (raw)
In-Reply-To: <20261125165845.45806-3-almagui@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] libbpf: missing 8-byte pointer size on split BTF in
bpf_prog_func_args_btf()
--
commit 48b370da5eb67f95ec57705bfbaef14039ba87cd
Author: Alan Maguire <almagui@kernel.org>
libbpf: Support CO-RE relocation of tracing program arguments
This commit adds CO-RE relocation support for tracing and LSM program
arguments described through a struct bpf_func_args___<flavor> context type
by synthesizing a matching candidate struct in a split BTF on top of the
attach target's BTF.
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 1efc0dd37b2e6..b452bda266da6 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
[ ... ]
> @@ -11641,6 +11768,210 @@ static int libbpf_find_attach_btf_id(struct bpf_program *prog, const char *attac
> return 0;
> }
>
[ ... ]
> +/*
> + * Add a member for an argument or the return value to the struct being built.
> + * Each takes up a whole number of u64 slots in the context, as laid out by
> + * btf_ctx_arg_idx() in the kernel.
> + */
> +static int func_args_add(struct btf *btf, const struct btf *targ_btf,
> + const char *name, __u32 type_id, __u32 *off)
> +{
> + const struct btf_type *t;
> + __u32 pad = 0;
> + __s64 sz;
> + int err;
> +
> + t = skip_mods_and_typedefs(targ_btf, type_id, NULL);
> + sz = t && btf_is_ptr(t) ? 8 : btf__resolve_size(targ_btf, type_id);
[ ... ]
> +static int bpf_prog_func_args_btf(const struct bpf_program *prog, const char *name,
> + struct btf **res)
> +{
[ ... ]
> + btf = btf__new_empty_split(targ_btf);
> + if (!btf)
> + return -errno;
[Severity: Medium]
Should bpf_prog_func_args_btf() call btf__set_pointer_size(btf, 8) on the
split BTF?
btf__new_empty_split() initializes btf->ptr_sz to sizeof(void *), which is
4 on 32-bit hosts. While func_args_add() hardcodes pointer sizes to 8 when
laying out context slots, bpf_core_calc_field_relo() later calls
btf__resolve_size() on the candidate split BTF and resolves BTF_KIND_PTR
fields to 4 bytes. That causes bpf_core_patch_insn() to downsize 8-byte
BPF_DW context pointer loads to 4-byte BPF_W loads, which the kernel
verifier rejects in btf_ctx_access() because pointer loads from the u64
context array must be 8 bytes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125165845.45806-1-almagui@kernel.org?part=2
next prev parent reply other threads:[~2026-11-25 17:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 16:58 [PATCH v2 bpf-next 0/5] libbpf, bpf: Utilize CO-RE for BPF program parameter presence, ordering Alan Maguire
2026-11-25 16:58 ` [PATCH v2 bpf-next 1/5] bpf: Allow loads of the low-order bytes of context slots on big-endian Alan Maguire
2026-11-25 16:58 ` [PATCH v2 bpf-next 2/5] libbpf: Support CO-RE relocation of tracing program arguments Alan Maguire
2026-11-25 17:16 ` sashiko-bot [this message]
2026-11-25 16:58 ` [PATCH v2 bpf-next 3/5] bpf: " Alan Maguire
2026-11-25 16:58 ` [PATCH v2 bpf-next 4/5] selftests/bpf: Test " Alan Maguire
2026-11-25 16:58 ` [PATCH v2 bpf-next 5/5] Documentation/bpf: Describe CO-RE relocation of function arguments Alan Maguire
2026-11-25 17:37 ` bot+bpf-ci
2026-11-25 22:49 ` [PATCH v2 bpf-next 0/5] libbpf, bpf: Utilize CO-RE for BPF program parameter presence, ordering Andrii Nakryiko
2026-11-26 4:02 ` Alexei Starovoitov
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=sashiko-outbox-233822@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=almagui@kernel.org \
--cc=bpf@vger.kernel.org \
--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