BPF List
 help / color / mirror / Atom feed
* [PATCH v2 bpf-next 0/5] libbpf, bpf: Utilize CO-RE for BPF program parameter presence, ordering
@ 2026-11-25 16:58 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
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Alan Maguire @ 2026-11-25 16:58 UTC (permalink / raw)
  To: ast, daniel, andrii
  Cc: andrey.grodzovsky, eddyz87, memxor, martin.lau, song,
	yonghong.song, jolsa, emil, ihor.solodrai, john.fastabend, mason,
	bpf, Alan Maguire

Currently the BPF_PROG() family of macros greatly facilitates
BPF tracing/LSM program writing by allowing specification
of function, tracepoint or LSM hook arguments directly by
name and type.  These are then mapped to a context struct
consisting of a u64 array, with one value for each argument,
with by-value structs larger than 8 bytes taking more than
one slot.

When an attach target gains, loses or reorders parameters
across kernels, programs silently read the wrong argument
or fail verification, and they have no way to check if an
argument actually exists.

To bring a Compile Once - Run Everywhere (CO-RE) experience
to parameters for programs, this series lets programs describe
the parameters they need and any variants via a
struct bpf_func_args___<flavor> which can contain

- parameters in any order, to support cases where a user might
  only use a subset of parameters in the associated program
- parameters that may exist for some kernels, where use is
  guarded by bpf_core_field_exists(ctx->field)
- renamed parameters, allowing the old and new names both to
  be present
- parameters whose type varies across kernels: a pointer can be read
  through the same struct either way, and bpf_core_type_matches() on
  a flavor with just that parameter tells which type it is
- __ret for the return value, for fexit, fmod_ret, fsession and
  LSM programs

For example, a program tracing a function foo() can declare just the
parameters it needs, a, b and c, in any order, irrespective of their
position in foo()'s signature. It can also declare a parameter "notsure"
that only some kernels have, and check whether it exists, and both names
of a parameter renamed from "old" to "new". Parameter "d" is a struct
file * on some kernels and a void * on others: as any two pointers are
compatible, it can be read through the same struct either way, and a
flavor with just that parameter tells which it is. __ret is the return
value.

        struct bpf_func_args___foo {
                __u64 c;
                int b;
                char a;
                long notsure;
                int old;
                int new;
                void *d;
                int __ret;
        } __attribute__((preserve_access_index));

        struct bpf_func_args___foo_d_file {
                struct file *d;
        } __attribute__((preserve_access_index));

        SEC("fexit/foo")
        int fexit_foo(struct bpf_func_args___foo *ctx)
        {
                a = ctx->a;
                b = ctx->b;
                c = ctx->c;
                if (bpf_core_field_exists(ctx->notsure))
                        notsure = ctx->notsure;
                if (bpf_core_field_exists(ctx->new))
                        val = ctx->new;
                else
                        val = ctx->old;
                if (bpf_core_type_matches(struct bpf_func_args___foo_d_file))
                        file = (struct file *)ctx->d;
                ret = ctx->__ret;
                return 0;
        }

Other changes, e.g. a parameter of another integer width or a struct
passed by value becoming a pointer, are covered in the libbpf overview.
See also tools/testing/selftests/bpf/progs/func_args_core.c for more
examples of usage.

Patch 1 allows loads of the low-order bytes of context slots on
big-endian, where arguments smaller than 8 bytes are at the end of their
slot.
Patch 2 adds the libbpf side.
Patch 3 adds the kernel side.
Patch 4 adds selftests.
Patch 5 adds documentation for libbpf/llvm reloc.

Changes since v1 [1]:

- Reworked as suggested by Alexei: rather than matching struct members
  against the attach target's parameters in relo_core.c, libbpf (and,
  for light skeletons, the kernel) builds a struct describing the
  program's context in a split BTF on top of the attach target's BTF,
  with one member per parameter at its context offset, plus __ret. This
  struct is the only CO-RE candidate, so relocations against it are
  ordinary CO-RE, and relo_core.c is unchanged.

- Structs are recognised by name, bpf_func_args___<flavor>, rather than
  by a BTF decl tag. This works the same with clang and GCC, so
  __bpf_func_args, __bpf_func_args_marker and __bpf_func_ret are gone.
  The return value is the member __ret. The flavor is everything after
  the first "___", so any flavor works.

- Dropped BPF_PROG_CORE(): it couldn't express the variants that are
  the main reason to relocate arguments (Alexei). Programs use the
  struct directly instead.

- Dropped bpf_func_args_supported() and the type-existence special
  case: as the candidate is named after the program's struct,
  type-based relocations, including bpf_core_type_exists() and
  bpf_core_type_matches(), work as usual.

- Pointer parameters follow the usual CO-RE rules, where any two
  pointers are compatible, instead of a stricter pointer check.
  bpf_core_type_matches() on a flavor containing just the parameter
  tells which type it points to.

- Big-endian: arguments smaller than 8 bytes are placed at the end of
  their slot, and a new verifier patch (patch 1) allows loads of the
  low-order bytes of context slots there, rather than widening loads
  and poisoning signed ones. The s390x selftest restriction is gone.

- libbpf: an attach target that can't be found no longer fails
  bpf_object__prepare(); the struct just has no candidate, and the
  program fails to load if it is loaded. Once the object is prepared,
  bpf_program__set_type(), bpf_program__set_expected_attach_type() and
  bpf_program__set_attach_target() fail with -EBUSY for programs whose
  relocations depend on them (Andrey).

- Selftests: test the libbpf and light skeleton paths, the LSM test
  folded in, plus renamed and missing parameters, struct and type
  variants, integer resizing, and the prepare-time behaviour above.

- Docs: llvm_reloc.rst describes the relocation for loader
  implementers; the libbpf overview covers common cases (a subset of
  parameters in any order; parameters that are missing, renamed or of
  another type on some kernels) and limitations.

[1] https://lore.kernel.org/bpf/20261123223227.745345-1-almagui@kernel.org/

Alan Maguire (5):
  bpf: Allow loads of the low-order bytes of context slots on big-endian
  libbpf: Support CO-RE relocation of tracing program arguments
  bpf: Support CO-RE relocation of tracing program arguments
  selftests/bpf: Test CO-RE relocation of tracing program arguments
  Documentation/bpf: Describe CO-RE relocation of function arguments

 Documentation/bpf/libbpf/libbpf_overview.rst  | 123 +++++++
 Documentation/bpf/llvm_reloc.rst              |  72 ++++
 include/linux/bpf.h                           |   2 +
 kernel/bpf/btf.c                              | 253 ++++++++++++-
 kernel/bpf/check_btf.c                        |   1 +
 tools/lib/bpf/libbpf.c                        | 333 ++++++++++++++++++
 tools/lib/bpf/libbpf.h                        |  13 +-
 tools/testing/selftests/bpf/Makefile.skel     |   2 +-
 .../selftests/bpf/prog_tests/func_args_core.c | 129 +++++++
 .../selftests/bpf/progs/func_args_core.c      | 178 ++++++++++
 10 files changed, 1099 insertions(+), 7 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/func_args_core.c
 create mode 100644 tools/testing/selftests/bpf/progs/func_args_core.c

-- 
2.56.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v2 bpf-next 1/5] bpf: Allow loads of the low-order bytes of context slots on big-endian
  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 ` Alan Maguire
  2026-11-25 16:58 ` [PATCH v2 bpf-next 2/5] libbpf: Support CO-RE relocation of tracing program arguments Alan Maguire
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Alan Maguire @ 2026-11-25 16:58 UTC (permalink / raw)
  To: ast, daniel, andrii
  Cc: andrey.grodzovsky, eddyz87, memxor, martin.lau, song,
	yonghong.song, jolsa, emil, ihor.solodrai, john.fastabend, mason,
	bpf, Alan Maguire

The context of LSM, struct_ops and tracing programs other than iterators
is an array of u64 slots, and arguments and return values smaller than
8 bytes are in the low-order bytes of theirs. btf_ctx_access() only
allows loads at the start of a slot: on little-endian, a load of fewer
than 8 bytes there reads the argument (truncated to the size of the
load), but on big-endian, it reads the high-order bytes instead, and the
argument can't be loaded on its own.

On big-endian, also allow loads of part of a slot that end at its end,
i.e. that read its low-order bytes. Such a load reads the same bytes as
a load of the same size at the start of the slot does on little-endian,
so the bounds the verifier assumes for it, such as the range of the
return value of LSM programs, which is kept in the 32-bit bounds of
4-byte loads, hold. Loads at other offsets within a slot stay rejected,
as these bounds wouldn't hold for them, and pointers can still only be
loaded as a whole.

Loads at the start of a slot stay allowed, so that no program that loads
today is rejected, and little-endian is unaffected. Iterators are
excluded: their context is a struct whose fields, such as the uid of
struct bpf_iter__tcp, are at the start of their 8 bytes, followed by
padding. As struct_ops programs keep the index of their member in
expected_attach_type, the program type is checked too.

This lets programs that describe their context with a struct, such as
struct bpf_func_args___<flavor>, which places such arguments at the end
of their slot on big-endian, read them there.

Suggested-by: Alexei Starovoitov <ast@kernel.org>
Assisted-by: LLM
Signed-off-by: Alan Maguire <almagui@kernel.org>
---
 kernel/bpf/btf.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index c4386a9a1ad4..04f12225ec08 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -7503,10 +7503,22 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type,
 	u32 nr_args, arg;
 	int i, ret;
 
+	/*
+	 * Loads start at an 8-byte boundary: the start of a u64 slot, or of a
+	 * field of an iterator's context struct. Arguments and return values
+	 * smaller than 8 bytes are in the low-order bytes of their slot, which
+	 * on big-endian are at its end, so loads ending there are allowed too,
+	 * except for iterators, whose fields are followed by padding.
+	 */
 	if (off % 8) {
-		bpf_log(log, "func '%s' offset %d is not multiple of 8\n",
-			tname, off);
-		return false;
+		bool iter = prog->type == BPF_PROG_TYPE_TRACING &&
+			    prog->expected_attach_type == BPF_TRACE_ITER;
+
+		if (!IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) || iter || off % 8 != 8 - size) {
+			bpf_log(log, "func '%s' offset %d is not multiple of 8\n",
+				tname, off);
+			return false;
+		}
 	}
 	arg = btf_ctx_arg_idx(btf, t, off);
 	args = (const struct btf_param *)(t + 1);
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 bpf-next 2/5] libbpf: Support CO-RE relocation of tracing program arguments
  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 ` Alan Maguire
  2026-11-25 17:16   ` sashiko-bot
  2026-11-25 16:58 ` [PATCH v2 bpf-next 3/5] bpf: " Alan Maguire
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Alan Maguire @ 2026-11-25 16:58 UTC (permalink / raw)
  To: ast, daniel, andrii
  Cc: andrey.grodzovsky, eddyz87, memxor, martin.lau, song,
	yonghong.song, jolsa, emil, ihor.solodrai, john.fastabend, mason,
	bpf, Alan Maguire

BPF_PROG() and friends access the arguments of fentry/fexit/tp_btf/LSM
programs by fixed position in the u64 context array. When a traced
function or tracepoint gains, loses or reorders parameters, programs
silently read the wrong argument (or fail verification), and there is
no way to check whether a given argument exists.

Let programs describe the arguments they need as a struct named
bpf_func_args___<flavor>, with members named after the parameters of
the attach target, in any order, and __ret for the return value:

	struct bpf_func_args___unlink {
		struct filename *name;
		int dfd;
		int __ret;
	} __attribute__((preserve_access_index));

	SEC("fexit/filename_unlinkat")
	int handle(struct bpf_func_args___unlink *ctx)
	{
		if (bpf_core_field_exists(ctx->dfd))
			bpf_printk("dfd %d", ctx->dfd);
		...
	}

For relocations against such a struct, libbpf describes the program's
context as a struct of the same name in a split BTF on top of the BTF of
the attach target: one member per parameter, with its name and type, at
its offset in the context as laid out by the kernel's btf_ctx_arg_idx()
(structs passed by value take up multiple slots), followed by __ret for
fexit, fmod_ret, fsession and LSM programs. This struct is the only
candidate, so the relocations themselves are ordinary CO-RE: offsets are
patched, bpf_core_field_exists() reports missing arguments, unguarded
accesses to them are poisoned, and bpf_core_type_matches() on the whole
struct can tell apart variants of a function's signature, e.g. a
parameter changing from struct vm_area_struct * to struct mm_area *.
No changes to relo_core.c are needed. The candidate depends on the
program, so it is kept out of the object-wide candidate cache, and
built for each relocation.

Clang uses the typedef as the root type of relocations against a struct
accessed through one, so typedefs and modifiers are skipped to find the
struct, and an anonymous struct takes its name from its typedef. The
relocation is then made against the struct itself, so that type-based
relocations match the candidate, unless the struct is anonymous, which
relocations can't have as their root type: type-based relocations then
need a named struct.

Unlike for other types, the flavor is everything after the first triple
underscore, so that any flavor works, including ones that start with or
contain underscores, e.g. when generated from a program's name: with the
usual rule, the essential name of such a struct isn't bpf_func_args, so
all of its members would silently appear to be missing. The candidate is
named after the program's struct rather than bpf_func_args, so that the
root type names compared by type-based relocations match whatever the
flavor is.

btf_trace_xxx prototypes carry no parameter names, so for tp_btf
programs the parameters are taken from the identically-typed
__probestub_xxx() function (Linux 6.5+) or, failing that,
__traceiter_xxx() (Linux 5.10+), without their first void *__data
parameter. On older kernels there is no candidate: guarded accesses see
the arguments as missing, and unguarded accesses fail to load.

The struct can only be used in entry programs (or inlined code), as a
shared subprogram has no single attach target, and only with attach
targets in kernel BTF. Its type ID can't be relocated to a kernel type
ID, as it only exists in libbpf. Light skeletons need the kernel to
apply these relocations, which a following patch adds.

The candidate is built from the attach target when the object is
prepared, which for tracing programs was only done when they were
loaded. If the target isn't found, there is no candidate instead of an
error, as the program then fails to load anyway, and might never be
loaded, e.g. if its load strategy is manual, so preparing the object
doesn't fail because of it.
The relocations depend on the type, attach type and attach target of the
program, so once the object is prepared, setting them with
bpf_program__set_type(), bpf_program__set_expected_attach_type() or
bpf_program__set_attach_target() fails with -EBUSY for programs using the
struct, instead of leaving them relocated against another target.

On big-endian targets, arguments smaller than 8 bytes are at the end of
their slot, so their members are placed there. The verifier allows
loads of them from the previous patch on; on older kernels, programs
reading them fail to load.

Suggested-by: Alexei Starovoitov <ast@kernel.org>
Assisted-by: LLM
Signed-off-by: Alan Maguire <almagui@kernel.org>
---
 tools/lib/bpf/libbpf.c | 333 +++++++++++++++++++++++++++++++++++++++++
 tools/lib/bpf/libbpf.h |  13 +-
 2 files changed, 343 insertions(+), 3 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 1efc0dd37b2e..b452bda266da 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -500,6 +500,8 @@ struct bpf_program {
 	/* the program or a function that it calls has callx */
 	bool has_callx;
 	bool mark_btf_static;
+	/* relocations against struct bpf_func_args___xyz were applied */
+	bool func_args_relocated;
 	enum bpf_prog_type type;
 	enum bpf_attach_type expected_attach_type;
 	int exception_cb_idx;
@@ -6256,6 +6258,107 @@ static const struct bpf_core_relo *find_relo_core(struct bpf_program *prog, int
 	return NULL;
 }
 
+#define BPF_FUNC_ARGS "bpf_func_args"
+
+static int bpf_prog_func_args_btf(const struct bpf_program *prog, const char *name,
+				  struct btf **res);
+
+/*
+ * Is the root type of a relocation 'struct bpf_func_args___xyz'? Clang uses
+ * the typedef as the root type of relocations against a struct accessed
+ * through one, so skip typedefs and modifiers, and take the name of an
+ * anonymous struct from its typedef. Returns the root type to relocate
+ * against in *res_id: the struct, unless it is anonymous.
+ *
+ * Unlike for other types, the flavor is everything after the first triple
+ * underscore, so that it can start with or contain underscores, e.g. when
+ * generated from a program's name.
+ */
+static bool bpf_core_is_func_args(const struct btf *btf, __u32 id, __u32 *res_id)
+{
+	const char *name = NULL;
+	const struct btf_type *t;
+	__u32 root_id = id;
+	int depth = 32;
+
+	t = btf__type_by_id(btf, id);
+	while (t && (btf_is_typedef(t) || btf_is_mod(t)) && depth--) {
+		if (btf_is_typedef(t))
+			name = btf__name_by_offset(btf, t->name_off);
+		id = t->type;
+		t = btf__type_by_id(btf, id);
+	}
+	if (!t || !btf_is_struct(t))
+		return false;
+	/* relocations can't have an anonymous root type, keep its typedef */
+	if (t->name_off) {
+		name = btf__name_by_offset(btf, t->name_off);
+		*res_id = id;
+	} else {
+		*res_id = root_id;
+	}
+
+	return name && (strcmp(name, BPF_FUNC_ARGS) == 0 ||
+			str_has_pfx(name, BPF_FUNC_ARGS "___"));
+}
+
+/*
+ * Resolve a relocation against 'struct bpf_func_args___xyz', whose only
+ * candidate is the struct describing the context of the program, see
+ * bpf_prog_func_args_btf(). The candidate depends on the program, so it is
+ * kept out of the object-wide candidate cache.
+ */
+static int bpf_core_resolve_func_args(struct bpf_program *prog,
+				      const struct bpf_core_relo *relo, int relo_idx,
+				      const struct btf *local_btf, const char *local_name,
+				      __u32 struct_id, struct bpf_core_spec *specs_scratch,
+				      struct bpf_core_relo_res *targ_res)
+{
+	struct bpf_core_cand_list cands = {};
+	struct bpf_core_relo struct_relo;
+	struct bpf_core_cand cand;
+	const char *struct_name;
+	struct btf *btf;
+	int err;
+
+	/* the type only exists in libbpf, not in the kernel */
+	if (relo->kind == BPF_CORE_TYPE_ID_TARGET) {
+		pr_warn("prog '%s': relo #%d: no kernel type ID for struct %s\n",
+			prog->name, relo_idx, local_name);
+		return -EOPNOTSUPP;
+	}
+
+	/* the relocations now depend on the program's attach target */
+	prog->func_args_relocated = true;
+
+	/*
+	 * Name the candidate after the program's struct, so that the names
+	 * that type-based relocations compare match whatever its flavor is.
+	 */
+	struct_name = btf__name_by_offset(local_btf,
+					  btf__type_by_id(local_btf, struct_id)->name_off);
+	err = bpf_prog_func_args_btf(prog, struct_name, &btf);
+	if (err) {
+		pr_warn("prog '%s': relo #%d: failed to find the arguments of the attach target for struct %s: %s\n",
+			prog->name, relo_idx, local_name, errstr(err));
+		return err;
+	}
+	if (btf) {
+		cand.btf = btf;
+		cand.id = btf__type_cnt(btf) - 1;
+		cands.cands = &cand;
+		cands.len = 1;
+	}
+
+	/* type-based relocations need the root to be the struct, not a typedef */
+	struct_relo = *relo;
+	struct_relo.type_id = struct_id;
+	err = bpf_core_calc_relo_insn(prog->name, &struct_relo, relo_idx, local_btf, &cands,
+				      specs_scratch, targ_res);
+	btf__free(btf);
+	return err;
+}
+
 static int bpf_core_resolve_relo(struct bpf_program *prog,
 				 const struct bpf_core_relo *relo,
 				 int relo_idx,
@@ -6269,6 +6372,7 @@ static int bpf_core_resolve_relo(struct bpf_program *prog,
 	const struct btf_type *local_type;
 	const char *local_name;
 	__u32 local_id = relo->type_id;
+	__u32 struct_id;
 	int err;
 
 	local_type = btf__type_by_id(local_btf, local_id);
@@ -6279,6 +6383,11 @@ static int bpf_core_resolve_relo(struct bpf_program *prog,
 	if (!local_name)
 		return -EINVAL;
 
+	if (relo->kind != BPF_CORE_TYPE_ID_LOCAL &&
+	    bpf_core_is_func_args(local_btf, local_id, &struct_id))
+		return bpf_core_resolve_func_args(prog, relo, relo_idx, local_btf, local_name,
+						  struct_id, specs_scratch, targ_res);
+
 	if (relo->kind != BPF_CORE_TYPE_ID_LOCAL &&
 	    !hashmap__find(cand_cache, local_id, &cands)) {
 		cands = bpf_core_find_cands(prog->obj, local_btf, local_id);
@@ -10685,10 +10794,26 @@ static struct bpf_sec_def custom_fallback_def;
 static bool has_custom_fallback_def;
 static int last_custom_sec_def_handler_id;
 
+/*
+ * Relocations against struct bpf_func_args___xyz depend on the type, attach
+ * type and attach target of the program, and are applied when the object is
+ * prepared, so these can't change afterwards.
+ */
+static bool prog_func_args_relocated(const struct bpf_program *prog)
+{
+	if (prog->obj->state < OBJ_PREPARED || !prog->func_args_relocated)
+		return false;
+	pr_warn("prog '%s': can't change the attach target of a program using struct %s once the object is prepared\n",
+		prog->name, BPF_FUNC_ARGS);
+	return true;
+}
+
 int bpf_program__set_type(struct bpf_program *prog, enum bpf_prog_type type)
 {
 	if (prog->obj->state >= OBJ_LOADED)
 		return libbpf_err(-EBUSY);
+	if (prog->type != type && prog_func_args_relocated(prog))
+		return libbpf_err(-EBUSY);
 
 	/* if type is not changed, do nothing */
 	if (prog->type == type)
@@ -10720,6 +10845,8 @@ int bpf_program__set_expected_attach_type(struct bpf_program *prog,
 {
 	if (prog->obj->state >= OBJ_LOADED)
 		return libbpf_err(-EBUSY);
+	if (prog->expected_attach_type != type && prog_func_args_relocated(prog))
+		return libbpf_err(-EBUSY);
 
 	prog->expected_attach_type = type;
 	return 0;
@@ -11641,6 +11768,210 @@ static int libbpf_find_attach_btf_id(struct bpf_program *prog, const char *attac
 	return 0;
 }
 
+/* Find the BTF and type ID of the kernel attach target of a program */
+static int bpf_prog_attach_target(const struct bpf_program *prog,
+				  struct btf **btf, int *btf_id)
+{
+	struct bpf_object *obj = prog->obj;
+	int btf_obj_fd = 0, i, err;
+	const char *attach_name;
+
+	if (prog->attach_btf_id) {
+		/* set via bpf_program__set_attach_target() */
+		btf_obj_fd = prog->attach_btf_obj_fd;
+		*btf_id = prog->attach_btf_id;
+	} else {
+		attach_name = strchr(prog->sec_name, '/');
+		if (!prog->sec_def || !(prog->sec_def->cookie & SEC_ATTACH_BTF) ||
+		    !attach_name || !attach_name[1]) {
+			pr_debug("prog '%s': struct %s needs an attach target in kernel BTF\n",
+				 prog->name, BPF_FUNC_ARGS);
+			return -EINVAL;
+		}
+		attach_name++;
+		err = find_kernel_btf_id(obj, attach_name, prog->expected_attach_type,
+					 &btf_obj_fd, btf_id);
+		if (err) {
+			pr_debug("prog '%s': failed to find kernel BTF type ID of '%s': %s\n",
+				 prog->name, attach_name, errstr(err));
+			return err;
+		}
+	}
+
+	*btf = btf_obj_fd ? NULL : obj->btf_vmlinux;
+	for (i = 0; btf_obj_fd && i < obj->btf_module_cnt; i++) {
+		if (obj->btf_modules[i].fd == btf_obj_fd) {
+			*btf = obj->btf_modules[i].btf;
+			break;
+		}
+	}
+	return *btf ? 0 : -ESRCH;
+}
+
+/*
+ * 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);
+	if (sz <= 0)
+		return sz ?: -EINVAL;
+	/* a small argument is in the low bytes of its slot */
+	if (sz < 8 && btf__endianness(targ_btf) == BTF_BIG_ENDIAN)
+		pad = 8 - sz;
+	/* unnamed parameters still take up their slots */
+	if (!str_is_empty(name)) {
+		err = btf__add_field(btf, name, type_id, (*off + pad) * 8, 0);
+		if (err)
+			return err;
+	}
+	*off += roundup(sz, 8);
+	return 0;
+}
+
+/*
+ * The context of tp_btf, fentry, fexit, fmod_ret, fsession and LSM programs
+ * is an array of u64 slots: the arguments of the attach target, then, where
+ * the program can see it, its return value. Describe it as
+ *
+ *	struct bpf_func_args___xyz {
+ *		<type of the parameter> <name of the parameter>;
+ *		...
+ *		<return type> __ret;
+ *	};
+ *
+ * in a split BTF on top of the BTF of the attach target, with the same
+ * name as the program's own struct (the name argument), so that it matches
+ * whatever that struct's flavor is. This struct is then the only CO-RE
+ * candidate for the program's struct, and relocations against it are
+ * ordinary CO-RE.
+ *
+ * Sets *res to NULL, so that there is no candidate, if the attach target is
+ * not found, or is a tracepoint without parameter names in BTF (kernels
+ * before 5.10).
+ */
+static int bpf_prog_func_args_btf(const struct bpf_program *prog, const char *name,
+				  struct btf **res)
+{
+	int i, id, first = 0, err;
+	const struct btf_param *p;
+	const struct btf_type *t;
+	struct btf *targ_btf, *btf;
+	bool has_ret = false;
+	const char *tp_name;
+	__u32 off = 0;
+
+	*res = NULL;
+
+	/* shared subprogs have no single attach target */
+	if (prog_is_subprog(prog->obj, prog)) {
+		pr_warn("prog '%s': struct %s can only be used in entry programs\n",
+			prog->name, BPF_FUNC_ARGS);
+		return -EOPNOTSUPP;
+	}
+	if ((prog->type != BPF_PROG_TYPE_TRACING && prog->type != BPF_PROG_TYPE_LSM) ||
+	    prog->attach_prog_fd) {
+		pr_warn("prog '%s': struct %s needs an attach target in kernel BTF\n",
+			prog->name, BPF_FUNC_ARGS);
+		return -EOPNOTSUPP;
+	}
+
+	switch (prog->expected_attach_type) {
+	case BPF_TRACE_FEXIT:
+	case BPF_MODIFY_RETURN:
+	case BPF_TRACE_FSESSION:
+	case BPF_LSM_MAC:
+	case BPF_LSM_CGROUP:
+		has_ret = true;
+		break;
+	case BPF_TRACE_FENTRY:
+	case BPF_TRACE_RAW_TP:
+		break;
+	default:
+		pr_warn("prog '%s': struct %s is not supported for this attach type\n",
+			prog->name, BPF_FUNC_ARGS);
+		return -EOPNOTSUPP;
+	}
+
+	/*
+	 * A missing attach target fails the load of the program anyway, so
+	 * leave that to it instead of failing to prepare the object, as the
+	 * program might not be loaded at all, e.g. if its load strategy is
+	 * BPF_PROG_LOAD_STRATEGY_MANUAL.
+	 */
+	err = bpf_prog_attach_target(prog, &targ_btf, &id);
+	if (err == -ENOMEM)
+		return err;
+	if (err) {
+		pr_debug("prog '%s': attach target not found, struct %s has no members\n",
+			 prog->name, BPF_FUNC_ARGS);
+		return 0;
+	}
+
+	t = btf__type_by_id(targ_btf, id);
+	if (t && btf_is_typedef(t)) {
+		/*
+		 * btf_trace_xyz has no names of parameters. __probestub_xyz()
+		 * has (6.5+), and __traceiter_xyz() has (5.10+). Both take
+		 * void *__data first, which is not in the context.
+		 */
+		tp_name = btf__name_by_offset(targ_btf, t->name_off);
+		if (!tp_name || !str_has_pfx(tp_name, BTF_TRACE_PREFIX))
+			return -EINVAL;
+		tp_name += sizeof(BTF_TRACE_PREFIX) - 1;
+		id = find_btf_by_prefix_kind(targ_btf, "__probestub_", tp_name, BTF_KIND_FUNC);
+		if (id == -ENOENT)
+			id = find_btf_by_prefix_kind(targ_btf, "__traceiter_", tp_name,
+						     BTF_KIND_FUNC);
+		if (id == -ENOENT) {
+			pr_debug("prog '%s': tracepoint '%s' has no parameter names in BTF, struct %s has no members\n",
+				 prog->name, tp_name, BPF_FUNC_ARGS);
+			return 0;
+		}
+		if (id < 0)
+			return id;
+		t = btf__type_by_id(targ_btf, id);
+		first = 1;
+	}
+	if (!t || !btf_is_func(t))
+		return -EINVAL;
+	t = btf__type_by_id(targ_btf, t->type);
+	if (!t || !btf_is_func_proto(t))
+		return -EINVAL;
+
+	btf = btf__new_empty_split(targ_btf);
+	if (!btf)
+		return -errno;
+
+	id = btf__add_struct(btf, name, 0);
+	err = id < 0 ? id : 0;
+	p = btf_params(t);
+	/* a trailing parameter of type void is '...' */
+	for (i = first; !err && i < btf_vlen(t) && p[i].type; i++)
+		err = func_args_add(btf, targ_btf, btf__name_by_offset(targ_btf, p[i].name_off),
+				    p[i].type, &off);
+	if (!err && has_ret && t->type)
+		err = func_args_add(btf, targ_btf, "__ret", t->type, &off);
+	if (err) {
+		pr_warn("prog '%s': failed to describe the arguments of the attach target: %s\n",
+			prog->name, errstr(err));
+		btf__free(btf);
+		return err;
+	}
+	btf_type_by_id(btf, id)->size = off;
+	*res = btf;
+	return 0;
+}
+
 int libbpf_attach_type_by_name(const char *name,
 			       enum bpf_attach_type *attach_type)
 {
@@ -15658,6 +15989,8 @@ int bpf_program__set_attach_target(struct bpf_program *prog,
 
 	if (prog->obj->state >= OBJ_LOADED)
 		return libbpf_err(-EINVAL);
+	if (prog_func_args_relocated(prog))
+		return libbpf_err(-EBUSY);
 
 	if (attach_prog_fd && !attach_func_name) {
 		/* Store attach_prog_fd. The BTF ID will be resolved later during
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 49f1120f4021..f7dbe49582e8 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -1015,7 +1015,9 @@ LIBBPF_API enum bpf_prog_type bpf_program__type(const struct bpf_program *prog);
  * @param prog BPF program to set the program type for
  * @param type program type to set the BPF map to have
  * @return error code; or 0 if no error. An error occurs
- * if the object is already loaded.
+ * if the object is already loaded, or, with -EBUSY, if it is
+ * prepared and libbpf relocated accesses to the arguments of the
+ * program through struct bpf_func_args___xyz, which depend on it.
  *
  * This must be called before the BPF object is loaded,
  * otherwise it has no effect and an error is returned.
@@ -1033,7 +1035,9 @@ bpf_program__expected_attach_type(const struct bpf_program *prog);
  * @param prog BPF program to set the attach type for
  * @param type attach type to set the BPF map to have
  * @return error code; or 0 if no error. An error occurs
- * if the object is already loaded.
+ * if the object is already loaded, or, with -EBUSY, if it is
+ * prepared and libbpf relocated accesses to the arguments of the
+ * program through struct bpf_func_args___xyz, which depend on it.
  *
  * This must be called before the BPF object is loaded,
  * otherwise it has no effect and an error is returned.
@@ -1127,7 +1131,10 @@ LIBBPF_API __u32 bpf_program__line_info_cnt(const struct bpf_program *prog);
  * attach_prog_fd to find destination BTF type ID in that BPF program, or
  * alone (no attach_prog_fd) to resolve kernel (vmlinux/module) BTF ID.
  * Must be provided if attach_prog_fd is 0.
- * @return error code; or 0 if no error occurred.
+ * @return error code; or 0 if no error occurred. Fails with -EBUSY
+ * if the object is prepared and libbpf relocated accesses to the
+ * arguments of the program through struct bpf_func_args___xyz, which
+ * depend on its attach target.
  */
 LIBBPF_API int
 bpf_program__set_attach_target(struct bpf_program *prog, int attach_prog_fd,
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 bpf-next 3/5] bpf: Support CO-RE relocation of tracing program arguments
  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 16:58 ` Alan Maguire
  2026-11-25 16:58 ` [PATCH v2 bpf-next 4/5] selftests/bpf: Test " Alan Maguire
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Alan Maguire @ 2026-11-25 16:58 UTC (permalink / raw)
  To: ast, daniel, andrii
  Cc: andrey.grodzovsky, eddyz87, memxor, martin.lau, song,
	yonghong.song, jolsa, emil, ihor.solodrai, john.fastabend, mason,
	bpf, Alan Maguire

libbpf relocates accesses to struct bpf_func_args___<flavor> against a
struct of the same name describing the context of tracing programs: one
member per parameter of the attach target, named and typed after it, at
its offset in the context, followed by __ret where the program can see
the return value. Light skeletons leave CO-RE relocations to the kernel,
so do the same here for them.

For relocations against such a struct, bpf_core_apply() builds the
struct in a minimal split BTF on top of the program's attach_btf, laid
out as btf_ctx_arg_idx() expects, and uses it as the only candidate, so
the relocations themselves are ordinary CO-RE and relo_core.c needs no
changes. Member names refer to the strings of the attach target's BTF,
so only the names of the struct and of __ret are added. The candidate
depends on the program, so it bypasses the candidate cache; the program
holds a reference to attach_btf, so cand_cache_mutex isn't needed
either. bpf_core_ctx gains the program for this.

As in libbpf, typedefs and modifiers are skipped to find the struct, an
anonymous struct takes its name from its typedef, and the relocation is
made against the struct itself unless it is anonymous. The flavor is
everything after the first triple underscore, and the candidate is named
after the program's struct, whose name is copied into the candidate's
strings along with __ret.

The rules match libbpf's: __ret is only present for fexit, fmod_ret,
fsession and LSM programs, other attach types and BPF program targets
are rejected, as is relocating the struct's type ID to a kernel type ID,
and on big-endian, arguments smaller than 8 bytes are placed in the high
addresses of their slot. For tp_btf programs, the parameters are those
of __probestub_xxx(), without void *__data, as btf_trace_xxx has no
parameter names; unlike libbpf, which supports older kernels, no
fallback is needed here. As the kernel relocates each program with its
subprograms already appended, accesses from subprograms are relocated
against the program's attach target, where libbpf, which relocates
shared subprogram code once, rejects them.

Suggested-by: Alexei Starovoitov <ast@kernel.org>
Assisted-by: LLM
Signed-off-by: Alan Maguire <almagui@kernel.org>
---
 include/linux/bpf.h    |   2 +
 kernel/bpf/btf.c       | 235 +++++++++++++++++++++++++++++++++++++++++
 kernel/bpf/check_btf.c |   1 +
 3 files changed, 238 insertions(+)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 4e9a4d15af0e..9bec0e6bcfd4 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -3446,6 +3446,8 @@ int bpf_get_kfunc_addr(const struct bpf_prog *prog, u32 func_id,
 struct bpf_core_ctx {
 	struct bpf_verifier_log *log;
 	const struct btf *btf;
+	/* the prog being loaded, if any, for struct bpf_func_args */
+	const struct bpf_prog *prog;
 };
 
 bool btf_nested_type_is_trusted(struct bpf_verifier_log *log,
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index 04f12225ec08..8824da49a0c0 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -10721,14 +10721,223 @@ bpf_core_find_cands(struct bpf_core_ctx *ctx, u32 local_type_id)
 	return populate_cand_cache(cands, module_cand_cache, MODULE_CAND_CACHE_SIZE);
 }
 
+#define BPF_FUNC_ARGS "bpf_func_args"
+#define BTF_TRACE_PREFIX "btf_trace_"
+
+/*
+ * The context of tp_btf, fentry, fexit, fmod_ret, fsession and LSM programs
+ * is an array of u64 slots: the arguments of the attach target, then, where
+ * the program can see it, its return value, see btf_ctx_arg_idx(). Describe
+ * it as
+ *
+ *	struct bpf_func_args {
+ *		<type of the parameter> <name of the parameter>;
+ *		...
+ *		<return type> __ret;
+ *	};
+ *
+ * in a split BTF on top of the BTF of the attach target, named after the
+ * prog's own 'struct bpf_func_args___xyz'. This struct is then the only CO-RE
+ * candidate for it, and relocations against it are ordinary CO-RE. libbpf
+ * does the same, see bpf_prog_func_args_btf() in tools/lib/bpf/libbpf.c.
+ */
+struct func_args_btf {
+	struct btf btf;
+	struct btf_type *types[1];
+	struct bpf_core_cand cand;
+	struct btf_type t;
+	struct btf_member m[MAX_BPF_FUNC_ARGS + 1];
+	/* the names of the struct and of __ret */
+	char strs[];
+};
+
+#define FUNC_ARGS_RET "__ret"
+
+/*
+ * Is the root type of a relocation 'struct bpf_func_args___xyz'? Clang uses
+ * the typedef as the root type of relocations against a struct accessed
+ * through one, so skip typedefs and modifiers, and take the name of an
+ * anonymous struct from its typedef. Returns the root type to relocate
+ * against in *res_id: the struct, unless it is anonymous.
+ *
+ * Unlike for other types, the flavor is everything after the first triple
+ * underscore, so that it can start with or contain underscores, e.g. when
+ * generated from a prog's name.
+ */
+static bool bpf_core_is_func_args(const struct btf *btf, u32 id, u32 *res_id)
+{
+	const struct btf_type *t;
+	const char *name = NULL;
+	int depth = MAX_RESOLVE_DEPTH;
+	u32 root_id = id;
+
+	t = btf_type_by_id(btf, id);
+	while (t && btf_type_is_modifier(t) && depth--) {
+		if (btf_type_is_typedef(t))
+			name = btf_name_by_offset(btf, t->name_off);
+		id = t->type;
+		t = btf_type_by_id(btf, id);
+	}
+	if (!t || !__btf_type_is_struct(t))
+		return false;
+	/* relocations can't have an anonymous root type, keep its typedef */
+	if (t->name_off) {
+		name = btf_name_by_offset(btf, t->name_off);
+		*res_id = id;
+	} else {
+		*res_id = root_id;
+	}
+
+	return name && (!strcmp(name, BPF_FUNC_ARGS) ||
+			str_has_prefix(name, BPF_FUNC_ARGS "___"));
+}
+
+static int func_args_add(struct func_args_btf *a, u32 name_off, u32 type_id)
+{
+	const struct btf_type *t = btf_type_skip_modifiers(&a->btf, type_id, NULL);
+	u32 n = btf_type_vlen(&a->t);
+	u32 sz;
+
+	if (!t)
+		return -EINVAL;
+	sz = btf_type_is_ptr(t) ? 8 : t->size;
+	if (!sz)
+		return -EINVAL;
+	if (n == ARRAY_SIZE(a->m))
+		return -E2BIG;
+
+	/* unnamed parameters still take up their slots */
+	if (name_off) {
+		a->m[n].name_off = name_off;
+		a->m[n].type = type_id;
+		a->m[n].offset = a->t.size * 8;
+		/* a small argument is in the high addresses of its slot */
+		if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) && sz < 8)
+			a->m[n].offset += (8 - sz) * 8;
+		a->t.info = BTF_KIND_STRUCT << 24 | (n + 1);
+	}
+	a->t.size += roundup(sz, 8);
+	return 0;
+}
+
+static struct func_args_btf *bpf_core_func_args_btf(struct bpf_core_ctx *ctx, u32 struct_id)
+{
+	const struct bpf_prog *prog = ctx->prog;
+	struct btf *targ_btf;
+	const struct btf_param *p;
+	const struct btf_type *t;
+	const char *struct_name;
+	struct func_args_btf *a;
+	int i, first = 0, err = 0;
+	size_t name_len;
+	bool has_ret = false;
+	const char *tname;
+	char name[128];
+	s32 id;
+
+	/* the prog holds a reference to attach_btf */
+	if (!prog || !prog->aux->attach_btf || prog->aux->dst_prog ||
+	    (prog->type != BPF_PROG_TYPE_TRACING && prog->type != BPF_PROG_TYPE_LSM)) {
+		bpf_log(ctx->log, "struct %s needs an attach target in kernel BTF\n",
+			BPF_FUNC_ARGS);
+		return ERR_PTR(-EOPNOTSUPP);
+	}
+
+	switch (prog->expected_attach_type) {
+	case BPF_TRACE_FEXIT:
+	case BPF_MODIFY_RETURN:
+	case BPF_TRACE_FSESSION:
+	case BPF_LSM_MAC:
+	case BPF_LSM_CGROUP:
+		has_ret = true;
+		break;
+	case BPF_TRACE_FENTRY:
+	case BPF_TRACE_RAW_TP:
+		break;
+	default:
+		bpf_log(ctx->log, "struct %s is not supported for this attach type\n",
+			BPF_FUNC_ARGS);
+		return ERR_PTR(-EOPNOTSUPP);
+	}
+
+	targ_btf = prog->aux->attach_btf;
+	t = btf_type_by_id(targ_btf, prog->aux->attach_btf_id);
+	if (t && btf_type_is_typedef(t)) {
+		/*
+		 * btf_trace_xyz has no names of parameters, __probestub_xyz()
+		 * has. It takes void *__data first, which is not in the
+		 * context.
+		 */
+		tname = btf_name_by_offset(targ_btf, t->name_off);
+		if (!tname || !str_has_prefix(tname, BTF_TRACE_PREFIX))
+			return ERR_PTR(-EINVAL);
+		if (snprintf(name, sizeof(name), "__probestub_%s",
+			     tname + sizeof(BTF_TRACE_PREFIX) - 1) >= sizeof(name))
+			return ERR_PTR(-ENAMETOOLONG);
+		id = btf_find_by_name_kind(targ_btf, name, BTF_KIND_FUNC);
+		t = id > 0 ? btf_type_by_id(targ_btf, id) : NULL;
+		first = 1;
+	}
+	if (!t || !btf_type_is_func(t)) {
+		bpf_log(ctx->log, "can't find the parameters of the attach target for struct %s\n",
+			BPF_FUNC_ARGS);
+		return ERR_PTR(-EINVAL);
+	}
+	t = btf_type_by_id(targ_btf, t->type);
+	if (!t || !btf_type_is_func_proto(t))
+		return ERR_PTR(-EINVAL);
+
+	/*
+	 * Name the candidate after the prog's struct, so that the names that
+	 * type-based relocations compare match whatever its flavor is.
+	 */
+	struct_name = btf_name_by_offset(ctx->btf, btf_type_by_id(ctx->btf, struct_id)->name_off);
+	name_len = strlen(struct_name) + 1;
+	a = kzalloc_flex(*a, strs, name_len + sizeof(FUNC_ARGS_RET), GFP_KERNEL_ACCOUNT);
+	if (!a)
+		return ERR_PTR(-ENOMEM);
+	memcpy(a->strs, struct_name, name_len);
+	memcpy(a->strs + name_len, FUNC_ARGS_RET, sizeof(FUNC_ARGS_RET));
+
+	a->btf.base_btf = targ_btf;
+	a->btf.start_id = btf_nr_types(targ_btf);
+	a->btf.start_str_off = targ_btf->start_str_off + targ_btf->hdr.str_len;
+	a->btf.strings = a->strs;
+	a->btf.hdr.str_len = name_len + sizeof(FUNC_ARGS_RET);
+	a->btf.types = a->types;
+	a->btf.nr_types = 1;
+	a->types[0] = &a->t;
+	a->t.name_off = a->btf.start_str_off;
+	a->t.info = BTF_KIND_STRUCT << 24;
+	a->cand.btf = &a->btf;
+	a->cand.id = a->btf.start_id;
+
+	p = btf_params(t);
+	/* a trailing parameter of type void is '...' */
+	for (i = first; !err && i < btf_type_vlen(t) && p[i].type; i++)
+		err = func_args_add(a, p[i].name_off, p[i].type);
+	if (!err && has_ret && t->type)
+		err = func_args_add(a, a->t.name_off + name_len, t->type);
+	if (err) {
+		bpf_log(ctx->log, "failed to describe the arguments of the attach target: %d\n",
+			err);
+		kfree(a);
+		return ERR_PTR(err);
+	}
+	return a;
+}
+
 int bpf_core_apply(struct bpf_core_ctx *ctx, const struct bpf_core_relo *relo,
 		   int relo_idx, void *insn)
 {
 	bool need_cands = relo->kind != BPF_CORE_TYPE_ID_LOCAL;
 	struct bpf_core_cand_list cands = {};
+	struct func_args_btf *args = NULL;
+	struct bpf_core_relo struct_relo;
 	struct bpf_core_relo_res targ_res;
 	struct bpf_core_spec *specs;
 	const struct btf_type *type;
+	u32 struct_id;
 	int err;
 
 	/* ~4k of temp memory necessary to convert LLVM spec like "0:1:0:5"
@@ -10746,6 +10955,31 @@ int bpf_core_apply(struct bpf_core_ctx *ctx, const struct bpf_core_relo *relo,
 		return -EINVAL;
 	}
 
+	if (need_cands && bpf_core_is_func_args(ctx->btf, relo->type_id, &struct_id)) {
+		/* the type only exists here, not in the kernel's BTF */
+		if (relo->kind == BPF_CORE_TYPE_ID_TARGET) {
+			bpf_log(ctx->log, "relo #%u: no kernel type ID for struct %s\n",
+				relo_idx, BPF_FUNC_ARGS);
+			need_cands = false;
+			err = -EOPNOTSUPP;
+			goto out;
+		}
+		/* the candidate depends on the prog, keep it out of the cache */
+		need_cands = false;
+		args = bpf_core_func_args_btf(ctx, struct_id);
+		if (IS_ERR(args)) {
+			err = PTR_ERR(args);
+			args = NULL;
+			goto out;
+		}
+		cands.cands = &args->cand;
+		cands.len = 1;
+		/* type-based relocations need the root to be the struct, not a typedef */
+		struct_relo = *relo;
+		struct_relo.type_id = struct_id;
+		relo = &struct_relo;
+	}
+
 	if (need_cands) {
 		struct bpf_cand_cache *cc;
 		int i;
@@ -10791,6 +11025,7 @@ int bpf_core_apply(struct bpf_core_ctx *ctx, const struct bpf_core_relo *relo,
 
 out:
 	kfree(specs);
+	kfree(args);
 	if (need_cands) {
 		kfree(cands.cands);
 		mutex_unlock(&cand_cache_mutex);
diff --git a/kernel/bpf/check_btf.c b/kernel/bpf/check_btf.c
index 79e079e907c9..e302feea9ca9 100644
--- a/kernel/bpf/check_btf.c
+++ b/kernel/bpf/check_btf.c
@@ -352,6 +352,7 @@ int bpf_check_core_relo(struct bpf_verifier_env *env,
 	struct bpf_core_ctx ctx = {
 		.log = &env->log,
 		.btf = btf,
+		.prog = prog,
 	};
 	bpfptr_t u_core_relo;
 	int err;
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 bpf-next 4/5] selftests/bpf: Test CO-RE relocation of tracing program arguments
  2026-11-25 16:58 [PATCH v2 bpf-next 0/5] libbpf, bpf: Utilize CO-RE for BPF program parameter presence, ordering Alan Maguire
                   ` (2 preceding siblings ...)
  2026-11-25 16:58 ` [PATCH v2 bpf-next 3/5] bpf: " Alan Maguire
@ 2026-11-25 16:58 ` 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 22:49 ` [PATCH v2 bpf-next 0/5] libbpf, bpf: Utilize CO-RE for BPF program parameter presence, ordering Andrii Nakryiko
  5 siblings, 0 replies; 10+ messages in thread
From: Alan Maguire @ 2026-11-25 16:58 UTC (permalink / raw)
  To: ast, daniel, andrii
  Cc: andrey.grodzovsky, eddyz87, memxor, martin.lau, song,
	yonghong.song, jolsa, emil, ihor.solodrai, john.fastabend, mason,
	bpf, Alan Maguire

Test struct bpf_func_args___<flavor> with both libbpf and light
skeletons, i.e. with relocations applied by libbpf and by the kernel,
across program types:

- fentry: arguments of bpf_fentry_test3() in a different order, an
  argument that doesn't exist, __ret, which isn't in the context of
  fentry programs, a field variant, reading another argument of the
  same size when one doesn't exist, and a u64 argument read as a __u32,
  as loads of unsigned integers are resized;
- fexit: an argument and __ret, through a typedef'd anonymous struct;
- fmod_ret: arguments of bpf_modify_return_test2() in a different order,
  __ret, and an int argument declared as a long, read with
  BPF_CORE_READ_BITFIELD(), as plain loads of signed integers of another
  size are poisoned;
- tp_btf: an argument of sys_enter, at its offset without void *__data,
  and bpf_core_type_matches() telling apart a matching and a mismatching
  pointer argument type, with the matching struct's flavor starting with
  and containing triple underscores, and a struct variant, reading an
  argument through whichever of two structs matches;
- LSM: dereferencing the struct file * argument of file_open, and __ret.

In the variants, the access that doesn't apply is poisoned, in a branch
the verifier finds dead.
For the field variant, clang turns the two loads into one, from the
context plus an offset set in each branch.

As test_progs runs tests in parallel, the programs only record what
they see in the test's process. fmod_ret uses bpf_modify_return_test2()
rather than bpf_modify_return_test(), as another test's fmod_ret program
returns non-zero for every process there, which skips the following
fmod_ret programs.

Also check that an unguarded access to a missing argument fails to load
(with libbpf only, as light skeletons can't enable a program that is not
loaded by default).

And check, with libbpf, that preparing an object with a manually loaded
program whose attach target doesn't exist succeeds, while loading that
program fails, and that the type, attach type and attach target of a
program using the struct can't be changed once the object is prepared.

bpf_core_type_matches() compares the names of integer types too, and
clang's "long" is "long int" in kernel BTF, so the structs checked with
it only have pointer members.

Assisted-by: LLM
Signed-off-by: Alan Maguire <almagui@kernel.org>
---
 tools/testing/selftests/bpf/Makefile.skel     |   2 +-
 .../selftests/bpf/prog_tests/func_args_core.c | 129 +++++++++++++
 .../selftests/bpf/progs/func_args_core.c      | 178 ++++++++++++++++++
 3 files changed, 308 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/func_args_core.c
 create mode 100644 tools/testing/selftests/bpf/progs/func_args_core.c

diff --git a/tools/testing/selftests/bpf/Makefile.skel b/tools/testing/selftests/bpf/Makefile.skel
index 45e4ce5dca4d..69808d962fc7 100644
--- a/tools/testing/selftests/bpf/Makefile.skel
+++ b/tools/testing/selftests/bpf/Makefile.skel
@@ -40,7 +40,7 @@ LSKELS_SIGNED := fentry_test.c fexit_test.c atomics.c
 
 # Generate both light skeleton and libbpf skeleton for these
 LSKELS_EXTRA := test_ksyms_module.c test_ksyms_weak.c kfunc_call_test.c \
-	kfunc_call_test_subprog.c test_global_percpu_data.c
+	kfunc_call_test_subprog.c test_global_percpu_data.c func_args_core.c
 SKEL_BLACKLIST += $(LSKELS) $(LSKELS_SIGNED)
 
 test_static_linked.skel.h-deps := test_static_linked1.bpf.o test_static_linked2.bpf.o
diff --git a/tools/testing/selftests/bpf/prog_tests/func_args_core.c b/tools/testing/selftests/bpf/prog_tests/func_args_core.c
new file mode 100644
index 000000000000..60caf2756a75
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/func_args_core.c
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <test_progs.h>
+#include "func_args_core.skel.h"
+#include "func_args_core.lskel.h"
+
+/*
+ * Run the programs of a func_args_core skeleton (libbpf or light) and check
+ * what they saw through struct bpf_func_args___xyz.
+ */
+static void check_func_args(struct func_args_core__bss *bss, int fentry_fd, int fmod_ret_fd)
+{
+	LIBBPF_OPTS(bpf_test_run_opts, topts);
+	int fd;
+
+	bss->pid = getpid();
+	bss->tp_nr = __NR_getppid;
+	/* calls bpf_fentry_test3(4, 5, 6) */
+	ASSERT_OK(bpf_prog_test_run_opts(fentry_fd, &topts), "fentry_run");
+	/* calls bpf_modify_return_test2(1, &b, 3, 4, 5, 6, 7) */
+	ASSERT_OK(bpf_prog_test_run_opts(fmod_ret_fd, &topts), "fmod_ret_run");
+	syscall(__NR_getppid);
+	fd = open("/dev/null", O_RDONLY);
+	if (fd >= 0)
+		close(fd);
+
+	ASSERT_EQ(bss->fentry_a, 4, "fentry_a");
+	ASSERT_EQ(bss->fentry_b, 5, "fentry_b");
+	ASSERT_EQ(bss->fentry_c, 6, "fentry_c");
+	ASSERT_EQ(bss->fentry_nope, 0, "fentry_nope_exists");
+	ASSERT_EQ(bss->fentry_ret, 0, "fentry_ret_exists");
+	ASSERT_EQ(bss->fentry_alt, 6, "fentry_field_variant");
+	ASSERT_EQ(bss->fentry_c32, 6, "fentry_unsigned_resized");
+	ASSERT_EQ(bss->fexit_c, 6, "fexit_c");
+	ASSERT_EQ(bss->fexit_ret, 15, "fexit_ret");
+	ASSERT_EQ(bss->fmod_ret_c, 3, "fmod_ret_c");
+	ASSERT_EQ(bss->fmod_ret_d, 4, "fmod_ret_signed_resized");
+	ASSERT_EQ(bss->fmod_ret_f, 6, "fmod_ret_f");
+	ASSERT_EQ(bss->fmod_ret_g, 7, "fmod_ret_g");
+	ASSERT_EQ(bss->fmod_ret_ret, 1, "fmod_ret_ret_exists");
+	ASSERT_GE(bss->tp_hits, 1, "tp_btf_id");
+	ASSERT_EQ(bss->tp_match, 1, "tp_btf_type_matches");
+	ASSERT_EQ(bss->tp_mismatch, 0, "tp_btf_type_mismatch");
+	ASSERT_EQ(bss->tp_variant, 1, "tp_btf_struct_variant");
+	ASSERT_EQ(bss->lsm_inode, 1, "lsm_file");
+	ASSERT_EQ(bss->lsm_ret, 1, "lsm_ret");
+}
+
+static void test_libbpf(void)
+{
+	struct func_args_core *skel;
+
+	skel = func_args_core__open_and_load();
+	if (!ASSERT_OK_PTR(skel, "open_and_load"))
+		return;
+	if (ASSERT_OK(func_args_core__attach(skel), "attach"))
+		check_func_args(skel->bss, bpf_program__fd(skel->progs.fentry),
+				bpf_program__fd(skel->progs.fmod_ret));
+	func_args_core__destroy(skel);
+}
+
+static void test_lskel(void)
+{
+	struct func_args_core_lskel *skel;
+
+	skel = func_args_core_lskel__open_and_load();
+	if (!ASSERT_OK_PTR(skel, "open_and_load"))
+		return;
+	/* not __attach(), which would also attach the unloaded "missing" prog */
+	if (!ASSERT_GT(func_args_core_lskel__fentry__attach(skel), 0, "attach_fentry") ||
+	    !ASSERT_GT(func_args_core_lskel__fexit__attach(skel), 0, "attach_fexit") ||
+	    !ASSERT_GT(func_args_core_lskel__fmod_ret__attach(skel), 0, "attach_fmod_ret") ||
+	    !ASSERT_GT(func_args_core_lskel__tp_btf__attach(skel), 0, "attach_tp_btf") ||
+	    !ASSERT_GT(func_args_core_lskel__lsm__attach(skel), 0, "attach_lsm"))
+		goto out;
+	/* the same .bss as for the libbpf skeleton, under another name */
+	check_func_args((struct func_args_core__bss *)skel->bss,
+			skel->progs.fentry.prog_fd, skel->progs.fmod_ret.prog_fd);
+out:
+	func_args_core_lskel__destroy(skel);
+}
+
+static void test_missing(void)
+{
+	struct func_args_core *skel;
+
+	skel = func_args_core__open();
+	if (!ASSERT_OK_PTR(skel, "open"))
+		return;
+	bpf_program__set_autoload(skel->progs.missing, true);
+	ASSERT_ERR(func_args_core__load(skel), "load");
+	func_args_core__destroy(skel);
+}
+
+static void test_prepare(void)
+{
+	struct bpf_program *fentry;
+	struct func_args_core *skel;
+
+	skel = func_args_core__open();
+	if (!ASSERT_OK_PTR(skel, "open"))
+		return;
+	fentry = skel->progs.fentry;
+	bpf_program__set_load_strategy(skel->progs.no_target, BPF_PROG_LOAD_STRATEGY_MANUAL);
+	if (!ASSERT_OK(bpf_object__prepare(skel->obj), "prepare"))
+		goto out;
+	ASSERT_ERR(bpf_program__load(skel->progs.no_target), "load_no_target");
+
+	/* the relocations depend on the attach target, which is now fixed */
+	ASSERT_EQ(bpf_program__set_attach_target(fentry, 0, "bpf_fentry_test2"), -EBUSY,
+		  "set_attach_target");
+	ASSERT_EQ(bpf_program__set_expected_attach_type(fentry, BPF_TRACE_FEXIT), -EBUSY,
+		  "set_expected_attach_type");
+	ASSERT_EQ(bpf_program__set_type(fentry, BPF_PROG_TYPE_LSM), -EBUSY, "set_type");
+	ASSERT_OK(func_args_core__load(skel), "load");
+out:
+	func_args_core__destroy(skel);
+}
+
+void test_func_args_core(void)
+{
+	if (test__start_subtest("libbpf"))
+		test_libbpf();
+	if (test__start_subtest("lskel"))
+		test_lskel();
+	if (test__start_subtest("missing"))
+		test_missing();
+	if (test__start_subtest("prepare"))
+		test_prepare();
+}
diff --git a/tools/testing/selftests/bpf/progs/func_args_core.c b/tools/testing/selftests/bpf/progs/func_args_core.c
new file mode 100644
index 000000000000..1281d0f47103
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/func_args_core.c
@@ -0,0 +1,178 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "vmlinux.h"
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_core_read.h>
+
+char _license[] SEC("license") = "GPL";
+
+int pid;
+__u64 fentry_a, fentry_b, fentry_c, fentry_nope, fentry_ret, fentry_alt, fentry_c32;
+__u64 fexit_c, fexit_ret;
+__u64 fmod_ret_c, fmod_ret_d, fmod_ret_f, fmod_ret_g, fmod_ret_ret;
+long tp_nr;
+__u64 tp_hits, tp_match, tp_mismatch, tp_variant;
+__u64 lsm_inode, lsm_ret;
+
+/* bpf_fentry_test3(char a, int b, u64 c): reordered, plus a missing one */
+struct bpf_func_args___test3 {
+	__u64 c;
+	int b;
+	char a;
+	long nope;
+	int __ret;
+} __attribute__((preserve_access_index));
+
+/* u64 c as a __u32: loads of unsigned integers are resized to the argument */
+struct bpf_func_args___test3_u32 {
+	__u32 c;
+} __attribute__((preserve_access_index));
+
+SEC("fentry/bpf_fentry_test3")
+int fentry(struct bpf_func_args___test3 *ctx)
+{
+	if ((bpf_get_current_pid_tgid() >> 32) != pid)
+		return 0;
+	fentry_a = ctx->a;
+	fentry_b = ctx->b;
+	fentry_c = ctx->c;
+	fentry_nope = bpf_core_field_exists(ctx->nope);
+	/* the return value is not in the context of fentry */
+	fentry_ret = bpf_core_field_exists(ctx->__ret);
+	/*
+	 * A field variant, as for an argument renamed on another kernel: the
+	 * access to the missing one is poisoned. Clang turns the two loads of
+	 * the same size into one, from ctx plus the offset each branch sets,
+	 * which the verifier allows from Linux 7.1.
+	 */
+	if (bpf_core_field_exists(ctx->nope))
+		fentry_alt = ctx->nope;
+	else
+		fentry_alt = ctx->c;
+	fentry_c32 = ((struct bpf_func_args___test3_u32 *)ctx)->c;
+	return 0;
+}
+
+/* a typedef'd anonymous struct, named after its typedef */
+typedef struct {
+	__u64 c;
+	int __ret;
+} __attribute__((preserve_access_index)) bpf_func_args___test3_t;
+
+SEC("fexit/bpf_fentry_test3")
+int fexit(bpf_func_args___test3_t *ctx)
+{
+	if ((bpf_get_current_pid_tgid() >> 32) != pid)
+		return 0;
+	fexit_c = ctx->c;
+	fexit_ret = ctx->__ret;
+	return 0;
+}
+
+/*
+ * bpf_modify_return_test2(int a, int *b, short c, int d, void *e, char f,
+ * int g). Unlike for bpf_modify_return_test(), other tests' fmod_ret programs
+ * on it only return non-zero for their own process, which would skip this one.
+ */
+struct bpf_func_args___modify2 {
+	int __ret;
+	int g;
+	char f;
+	short c;
+	/* int, as long as on a kernel where it would be wider */
+	long d;
+} __attribute__((preserve_access_index));
+
+SEC("fmod_ret/bpf_modify_return_test2")
+int fmod_ret(struct bpf_func_args___modify2 *ctx)
+{
+	if ((bpf_get_current_pid_tgid() >> 32) != pid)
+		return 0;
+	fmod_ret_c = ctx->c;
+	/* a plain load of a signed integer of another size would be poisoned */
+	fmod_ret_d = BPF_CORE_READ_BITFIELD(ctx, d);
+	fmod_ret_f = ctx->f;
+	fmod_ret_g = ctx->g;
+	fmod_ret_ret = bpf_core_field_exists(ctx->__ret);
+	return 0;
+}
+
+/* sys_enter(struct pt_regs *regs, long id), without void *__data */
+struct bpf_func_args___sys_enter {
+	long id;
+	struct pt_regs *regs;
+} __attribute__((preserve_access_index));
+
+/*
+ * Flavors with just the argument whose type is checked, as for an argument
+ * pointing to another type on another kernel. bpf_core_type_matches() also
+ * compares the names of integer types, and clang's "long" is "long int" in
+ * kernel BTF, so only check pointers here.
+ * The flavor starts with and contains triple underscores, which only
+ * matches as the candidate is named after the struct.
+ */
+struct bpf_func_args____sys_enter___good {
+	struct pt_regs *regs;
+} __attribute__((preserve_access_index));
+
+struct bpf_func_args___sys_enter_bad {
+	struct file *regs;
+} __attribute__((preserve_access_index));
+
+/* a struct variant, as for another kernel where the argument is renamed */
+struct bpf_func_args___sys_enter_old {
+	struct pt_regs *uregs;
+} __attribute__((preserve_access_index));
+
+SEC("tp_btf/sys_enter")
+int tp_btf(struct bpf_func_args___sys_enter *ctx)
+{
+	struct pt_regs *regs;
+
+	if ((bpf_get_current_pid_tgid() >> 32) != pid)
+		return 0;
+	/* other syscalls of this process trigger it too */
+	if (ctx->id == tp_nr)
+		tp_hits++;
+	tp_match = bpf_core_type_matches(struct bpf_func_args____sys_enter___good);
+	tp_mismatch = bpf_core_type_matches(struct bpf_func_args___sys_enter_bad);
+	/* a struct variant: the access through the one not matching is poisoned */
+	if (bpf_core_type_matches(struct bpf_func_args____sys_enter___good))
+		regs = ((struct bpf_func_args____sys_enter___good *)ctx)->regs;
+	else
+		regs = ((struct bpf_func_args___sys_enter_old *)ctx)->uregs;
+	tp_variant = regs && regs == ctx->regs;
+	return 0;
+}
+
+/* file_open(struct file *file) */
+struct bpf_func_args___file_open {
+	struct file *file;
+	int __ret;
+} __attribute__((preserve_access_index));
+
+SEC("lsm/file_open")
+int lsm(struct bpf_func_args___file_open *ctx)
+{
+	if ((bpf_get_current_pid_tgid() >> 32) != pid)
+		return 0;
+	lsm_inode = !!ctx->file->f_inode;
+	lsm_ret = ctx->__ret + 1;
+	return 0;
+}
+
+/* an unguarded access to a missing argument fails to load */
+SEC("?fentry/bpf_fentry_test3")
+int missing(struct bpf_func_args___test3 *ctx)
+{
+	fentry_nope = ctx->nope;
+	return 0;
+}
+
+/* a missing attach target fails the load of the program, not the prepare */
+SEC("?fentry/bpf_fentry_test_nonexistent")
+int no_target(struct bpf_func_args___test3 *ctx)
+{
+	if (bpf_core_field_exists(ctx->a))
+		fentry_a = ctx->a;
+	return 0;
+}
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 bpf-next 5/5] Documentation/bpf: Describe CO-RE relocation of function arguments
  2026-11-25 16:58 [PATCH v2 bpf-next 0/5] libbpf, bpf: Utilize CO-RE for BPF program parameter presence, ordering Alan Maguire
                   ` (3 preceding siblings ...)
  2026-11-25 16:58 ` [PATCH v2 bpf-next 4/5] selftests/bpf: Test " Alan Maguire
@ 2026-11-25 16:58 ` 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
  5 siblings, 1 reply; 10+ messages in thread
From: Alan Maguire @ 2026-11-25 16:58 UTC (permalink / raw)
  To: ast, daniel, andrii
  Cc: andrey.grodzovsky, eddyz87, memxor, martin.lau, song,
	yonghong.song, jolsa, emil, ihor.solodrai, john.fastabend, mason,
	bpf, Alan Maguire

Describe struct bpf_func_args___<flavor> in the libbpf overview: how
programs use it to access the arguments and return value of their attach
target, how to handle common cases, i.e. using only some parameters in
any order, and parameters that are missing, renamed or of another type
on some kernels, and its limitations.

In llvm_reloc.rst, describe for loader implementers how relocations
against such a struct are resolved: which names are recognised, typedef
handling, the candidate named after the program's struct, its layout in
the context, __ret, where tp_btf parameter names come from, and
big-endian placement.

Assisted-by: LLM
Signed-off-by: Alan Maguire <almagui@kernel.org>
---
 Documentation/bpf/libbpf/libbpf_overview.rst | 123 +++++++++++++++++++
 Documentation/bpf/llvm_reloc.rst             |  72 +++++++++++
 2 files changed, 195 insertions(+)

diff --git a/Documentation/bpf/libbpf/libbpf_overview.rst b/Documentation/bpf/libbpf/libbpf_overview.rst
index f4d22f0c62b0..08b633edc9bc 100644
--- a/Documentation/bpf/libbpf/libbpf_overview.rst
+++ b/Documentation/bpf/libbpf/libbpf_overview.rst
@@ -198,6 +198,129 @@ about the field that should be relocated on the target kernel. i.e, if the
 ``struct task_struct`` due to some new field added in front of it, libbpf will
 automatically adjust the actual offset to the proper value.
 
+CO-RE for Function Arguments
+----------------------------
+
+The context of tp_btf, fentry, fexit, fmod_ret, fsession and LSM programs is
+an array of u64 slots holding the arguments of the attach target, followed by
+its return value where the program can see it. ``BPF_PROG()`` accesses them by
+position, so when a traced function or tracepoint gains, loses or reorders
+parameters, programs silently read the wrong argument.
+
+Instead, a program can describe the arguments it needs as a struct named
+``bpf_func_args___<flavor>``, with members named after the parameters of the
+attach target, in any order, and ``__ret`` for the return value:
+
+.. code-block:: C
+
+    struct bpf_func_args___unlink {
+            struct filename *name;
+            int dfd;
+            int __ret;
+    } __attribute__((preserve_access_index));
+
+    SEC("fexit/filename_unlinkat")
+    int handle(struct bpf_func_args___unlink *ctx)
+    {
+            if (bpf_core_field_exists(ctx->dfd))
+                    bpf_printk("dfd %d", ctx->dfd);
+            bpf_printk("%s %d", ctx->name->name, ctx->__ret);
+            return 0;
+    }
+
+libbpf relocates accesses to such a struct against a struct of the same name
+describing the context of the program, with one member per parameter of its
+attach target, followed by ``__ret`` for fexit, fmod_ret, fsession and LSM
+programs. For tp_btf programs, the parameters are those of the tracepoint,
+without its ``void *__data``. Otherwise, these are ordinary CO-RE relocations,
+and the usual CO-RE helpers apply. The struct can be accessed through a
+typedef, and an anonymous struct takes its name from its typedef, but
+type-based relocations such as ``bpf_core_type_exists()`` need a named struct.
+
+Common cases:
+
+- *Only some parameters are needed, regardless of their order.* Declare
+  just those, in any order: each member is relocated to wherever its
+  parameter is, so parameters added, removed or reordered elsewhere in the
+  signature don't matter.
+
+- *A parameter may not exist on every kernel.* ``bpf_core_field_exists()``
+  tells whether it does. Unguarded accesses to a missing parameter fail to
+  load. Likewise, ``__ret`` only exists where the program sees the return
+  value.
+
+- *A parameter is renamed across kernels.* Declare both names in the same
+  struct, and read whichever exists:
+
+  .. code-block:: C
+
+    if (bpf_core_field_exists(ctx->new_name))
+            val = ctx->new_name;
+    else
+            val = ctx->old_name;
+
+- *A parameter's type varies across kernels.* Declare it once, with the
+  same name, and:
+
+  - for an unsigned integer whose width varies, declare it at the widest
+    width and read it as usual: the load is resized to the parameter, and
+    zero-extended;
+  - for a signed integer whose width varies, declare it at the widest width
+    and read it with ``BPF_CORE_READ_BITFIELD(ctx, name)``, which loads it
+    at its size on the running kernel and sign-extends it. A plain access
+    with another size is poisoned, as for other CO-RE relocations;
+  - for a pointer to a type that varies, read it as usual, as any two
+    pointers are compatible, and tell which type it points to with
+    ``bpf_core_type_matches()`` on another flavor of the struct, with just
+    that parameter:
+
+    .. code-block:: C
+
+      struct bpf_func_args___new {
+              struct mm_area *vma;
+      } __attribute__((preserve_access_index));
+
+      if (bpf_core_type_matches(struct bpf_func_args___new))
+              mm = (struct mm_area *)ctx->vma;
+      else
+              vma = (struct vm_area_struct *)ctx->vma;
+
+    ``bpf_core_type_matches()`` also compares the names of integer types,
+    which may differ between the compiler and kernel BTF (e.g., ``long`` and
+    ``long int``), so such flavors should only describe the parameters that
+    differ;
+  - for other changes, e.g. a struct passed by value becoming a pointer,
+    the parameter isn't compatible with one of the declarations, so it
+    appears to be missing from it: declare a flavor of the struct for each
+    variant, and read through the one where ``bpf_core_field_exists()``
+    finds it.
+
+Limitations:
+
+- with libbpf applying the relocations, accesses need to be made from the
+  entry program (or inlined code), as a shared subprogram has no single
+  attach target;
+- the attach target needs to be in kernel BTF: programs attached to BPF
+  programs and multi-attach programs are not supported;
+- with libbpf applying the relocations, the type, attach type and attach
+  target of the program can't be changed once the object is prepared, as
+  the relocations depend on them;
+- ``bpf_core_type_id_kernel()`` can't be used on such a struct, as it only
+  exists in libbpf;
+- tracepoints only have parameter names in kernel BTF from Linux 5.10, so on
+  older kernels all arguments of tp_btf programs appear to be missing;
+- clang can turn loads of members of the same size in alternative branches,
+  e.g. for a renamed parameter, into one load from the context plus an
+  offset set in each branch, and ``BPF_CORE_READ_BITFIELD()`` loads from
+  the context plus an offset too. The verifier only allows such loads from
+  Linux 7.1, so these programs can fail to load on older kernels;
+- on big-endian targets, arguments smaller than 8 bytes are at the end of
+  their slot, where older kernels don't allow context loads, so programs
+  reading them fail to load there;
+- light skeletons need the kernel to support these relocations. Older
+  kernels and older libbpf versions find no candidate, so all arguments
+  appear to be missing.
+
 Getting Started with libbpf
 ===========================
 
diff --git a/Documentation/bpf/llvm_reloc.rst b/Documentation/bpf/llvm_reloc.rst
index 44188e219d32..0da06e29385f 100644
--- a/Documentation/bpf/llvm_reloc.rst
+++ b/Documentation/bpf/llvm_reloc.rst
@@ -544,3 +544,75 @@ Enum-based relocations:
             108:  CO-RE <enumval_value> [16] enum bar::V = 1
     35:     *(u64 *)(r2 + 0x0) = r1
     36:     exit
+
+Relocations Against Function Arguments
+======================================
+
+The context of tp_btf, fentry, fexit, fmod_ret, fsession and LSM programs
+is an array of u64 slots, holding the arguments of the attach target and,
+where the program can see it, its return value. Programs can describe it
+with a struct named ``bpf_func_args___<flavor>`` accessed with
+``preserve_access_index``, with members named after the parameters of the
+attach target and ``__ret`` for the return value. The compiler emits
+ordinary CO-RE relocations for these accesses, e.g.:
+
+.. code-block:: c
+
+  struct bpf_func_args___test3 {
+    unsigned long long c;
+    char a;
+  } __attribute__((preserve_access_index));
+
+  SEC("fentry/bpf_fentry_test3")
+  int prog(struct bpf_func_args___test3 *ctx)
+  {
+    return ctx->a;
+  }
+
+  0000000000000000 <prog>:
+       0:       w0 = *(u8 *)(r1 + 0x8)
+                0000000000000000:  CO-RE <byte_off> [2] struct bpf_func_args___test3::a (0:1)
+       1:       w0 <<= 0x18
+       2:       w0 s>>= 0x18
+       3:       exit
+
+Loaders resolve relocations whose root type is a struct named
+``bpf_func_args``, or ``bpf_func_args___`` followed by any flavor, against a
+single candidate, which they construct from the program's attach target
+rather than look up in kernel BTF. Unlike for other types, the flavor is
+everything after the first triple underscore, so it can start with or contain
+underscores, e.g., when it is generated from the name of a program. The
+compiler uses a typedef as the root type when the struct is accessed through
+one, so loaders skip typedefs and modifiers to find the struct, and take the
+name of an anonymous struct from its typedef. They then relocate against
+the struct itself, unless it is anonymous, and give the candidate the same
+name, so that type-based relocations match it whatever its flavor is:
+
+.. code-block:: c
+
+  struct bpf_func_args___<flavor> {
+    <type of the parameter> <name of the parameter>;
+    ...
+    <return type> __ret;
+  };
+
+- Its members are the parameters of the attach target, with their names and
+  types, at their offsets in the context, as laid out by the kernel's
+  ``btf_ctx_arg_idx()``: each takes up a whole number of 8-byte slots (e.g.,
+  structs larger than 8 bytes passed by value take up two). On big-endian
+  targets, members smaller than 8 bytes are at the end of their slot.
+- ``__ret`` follows the parameters for fexit, fmod_ret, fsession and LSM
+  programs, unless the attach target returns void.
+- For tp_btf programs, the attach target is a ``btf_trace_<name>`` typedef
+  without parameter names, so the parameters are taken from the
+  identically-typed ``__probestub_<name>()`` function (or, on kernels
+  before Linux 6.5, ``__traceiter_<name>()``), without their first
+  ``void *__data`` parameter. If neither exists, libbpf finds no
+  candidate, while the kernel, which only looks for
+  ``__probestub_<name>()``, fails the relocation.
+
+The struct is constructed in BTF split from the BTF of the attach target,
+so that members refer to the target's types, and relocations against it are
+then resolved as usual. ``target_type_id`` relocations against it fail, as
+it doesn't exist in the kernel. libbpf and the kernel, for light skeletons,
+implement this.
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 bpf-next 2/5] libbpf: Support CO-RE relocation of tracing program arguments
  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
  0 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-11-25 17:16 UTC (permalink / raw)
  To: Alan Maguire; +Cc: bpf

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 bpf-next 5/5] Documentation/bpf: Describe CO-RE relocation of function arguments
  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
  0 siblings, 0 replies; 10+ messages in thread
From: bot+bpf-ci @ 2026-11-25 17:37 UTC (permalink / raw)
  To: almagui, ast, daniel, andrii
  Cc: andrey.grodzovsky, eddyz87, memxor, martin.lau, song,
	yonghong.song, jolsa, emil, ihor.solodrai, john.fastabend, mason,
	bpf, almagui, ast, andrii, daniel, martin.lau, eddyz87,
	yonghong.song, mason, ihor.solodrai

[-- Attachment #1: Type: text/plain, Size: 1335 bytes --]

> Documentation/bpf: Describe CO-RE relocation of function arguments

TL;DR: Nit only, in the documentation: the libbpf overview example assigns to
two different undeclared variables (mm and vma) in its branches, so it may not
show how to use the result.

> diff --git a/Documentation/bpf/libbpf/libbpf_overview.rst b/Documentation/bpf/libbpf/libbpf_overview.rst
> --- a/Documentation/bpf/libbpf/libbpf_overview.rst
> +++ b/Documentation/bpf/libbpf/libbpf_overview.rst

[ ... ]

> +    .. code-block:: C
> +
> +      struct bpf_func_args___new {
> +              struct mm_area *vma;
> +      } __attribute__((preserve_access_index));
> +
> +      if (bpf_core_type_matches(struct bpf_func_args___new))
> +              mm = (struct mm_area *)ctx->vma;
> +      else
> +              vma = (struct vm_area_struct *)ctx->vma;
> +

This isn't a bug, but the two branches of this example assign to different
variables, mm and vma, and neither is declared.

Should both branches assign to the same variable, or should each use its
own typed pointer, so the snippet shows how to consume the result?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/45664233836

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 bpf-next 0/5] libbpf, bpf: Utilize CO-RE for BPF program parameter presence, ordering
  2026-11-25 16:58 [PATCH v2 bpf-next 0/5] libbpf, bpf: Utilize CO-RE for BPF program parameter presence, ordering Alan Maguire
                   ` (4 preceding siblings ...)
  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 22:49 ` Andrii Nakryiko
  2026-11-26  4:02   ` Alexei Starovoitov
  5 siblings, 1 reply; 10+ messages in thread
From: Andrii Nakryiko @ 2026-11-25 22:49 UTC (permalink / raw)
  To: Alan Maguire
  Cc: ast, daniel, andrii, andrey.grodzovsky, eddyz87, memxor,
	martin.lau, song, yonghong.song, jolsa, emil, ihor.solodrai,
	john.fastabend, mason, bpf

On Wed, Nov 25, 2026 at 8:58 AM Alan Maguire <almagui@kernel.org> wrote:
>
> Currently the BPF_PROG() family of macros greatly facilitates
> BPF tracing/LSM program writing by allowing specification
> of function, tracepoint or LSM hook arguments directly by
> name and type.  These are then mapped to a context struct
> consisting of a u64 array, with one value for each argument,
> with by-value structs larger than 8 bytes taking more than
> one slot.
>
> When an attach target gains, loses or reorders parameters
> across kernels, programs silently read the wrong argument
> or fail verification, and they have no way to check if an
> argument actually exists.
>
> To bring a Compile Once - Run Everywhere (CO-RE) experience
> to parameters for programs, this series lets programs describe
> the parameters they need and any variants via a
> struct bpf_func_args___<flavor> which can contain
>
> - parameters in any order, to support cases where a user might
>   only use a subset of parameters in the associated program
> - parameters that may exist for some kernels, where use is
>   guarded by bpf_core_field_exists(ctx->field)
> - renamed parameters, allowing the old and new names both to
>   be present
> - parameters whose type varies across kernels: a pointer can be read
>   through the same struct either way, and bpf_core_type_matches() on
>   a flavor with just that parameter tells which type it is
> - __ret for the return value, for fexit, fmod_ret, fsession and
>   LSM programs
>
> For example, a program tracing a function foo() can declare just the
> parameters it needs, a, b and c, in any order, irrespective of their
> position in foo()'s signature. It can also declare a parameter "notsure"
> that only some kernels have, and check whether it exists, and both names
> of a parameter renamed from "old" to "new". Parameter "d" is a struct
> file * on some kernels and a void * on others: as any two pointers are
> compatible, it can be read through the same struct either way, and a
> flavor with just that parameter tells which it is. __ret is the return
> value.
>
>         struct bpf_func_args___foo {
>                 __u64 c;
>                 int b;
>                 char a;
>                 long notsure;
>                 int old;
>                 int new;
>                 void *d;
>                 int __ret;
>         } __attribute__((preserve_access_index));
>
>         struct bpf_func_args___foo_d_file {
>                 struct file *d;
>         } __attribute__((preserve_access_index));
>

to make this work reliably and not get screwed over by compiler
generating context access like this:

r2 = <offset> ; CO-RE relocated
r1 += r2      ; verifier doesn't like this
r3 = *(u64 *)(r1 + 0); /* ctx access */

we need to make sure that we can use
__attribute__((preserve_static_offset)) together with
__attribute__((preserve_access_index))

This was pointed out in [0] (which, coincidentally perhaps, also
mentioned explicit bpf_func_args___xxx struct idea), we might not need
to block on that support given user defines this struct and bears
responsibility for this to work, but still, should be addressed
soon-ish in Clang/GCC.


And I'm actually wondering if the better name for this would be
"bpf_ctx___<flavor>" or "bpf_ctx_args___<flavor>", because it's not
always *function* arguments (tracepoint, BPF program, etc). Keeping it
more generic as "context arguments" or just "context" seems more
future-proof.


Also (I only skimmed patches, haven't gone through them completely,
will get back to this next week after holidays, sorry), I saw you
mentioned the limitation that this context access can be only done
from entry program code, right?  I think this can be lifted if we
apply these relocations after subprogs are appended to their
respective main programs. Not sure how ugly that will be, but you can
try that and see how it works (please do it as a separate patch to
distract less from the main logic change).

Overall I like it, thanks.


  [0] https://lore.kernel.org/bpf/CAEf4BzYNo54oz12C+s51KG5yWozDHGsQHYqdqHfqpSJ8=QPmyQ@mail.gmail.com/



>         SEC("fexit/foo")
>         int fexit_foo(struct bpf_func_args___foo *ctx)
>         {
>                 a = ctx->a;
>                 b = ctx->b;
>                 c = ctx->c;
>                 if (bpf_core_field_exists(ctx->notsure))
>                         notsure = ctx->notsure;
>                 if (bpf_core_field_exists(ctx->new))
>                         val = ctx->new;
>                 else
>                         val = ctx->old;
>                 if (bpf_core_type_matches(struct bpf_func_args___foo_d_file))
>                         file = (struct file *)ctx->d;
>                 ret = ctx->__ret;
>                 return 0;
>         }
>
> Other changes, e.g. a parameter of another integer width or a struct
> passed by value becoming a pointer, are covered in the libbpf overview.
> See also tools/testing/selftests/bpf/progs/func_args_core.c for more
> examples of usage.
>
> Patch 1 allows loads of the low-order bytes of context slots on
> big-endian, where arguments smaller than 8 bytes are at the end of their
> slot.
> Patch 2 adds the libbpf side.
> Patch 3 adds the kernel side.
> Patch 4 adds selftests.
> Patch 5 adds documentation for libbpf/llvm reloc.
>
> Changes since v1 [1]:
>
> - Reworked as suggested by Alexei: rather than matching struct members
>   against the attach target's parameters in relo_core.c, libbpf (and,
>   for light skeletons, the kernel) builds a struct describing the
>   program's context in a split BTF on top of the attach target's BTF,
>   with one member per parameter at its context offset, plus __ret. This
>   struct is the only CO-RE candidate, so relocations against it are
>   ordinary CO-RE, and relo_core.c is unchanged.
>
> - Structs are recognised by name, bpf_func_args___<flavor>, rather than
>   by a BTF decl tag. This works the same with clang and GCC, so
>   __bpf_func_args, __bpf_func_args_marker and __bpf_func_ret are gone.
>   The return value is the member __ret. The flavor is everything after
>   the first "___", so any flavor works.
>
> - Dropped BPF_PROG_CORE(): it couldn't express the variants that are
>   the main reason to relocate arguments (Alexei). Programs use the
>   struct directly instead.
>
> - Dropped bpf_func_args_supported() and the type-existence special
>   case: as the candidate is named after the program's struct,
>   type-based relocations, including bpf_core_type_exists() and
>   bpf_core_type_matches(), work as usual.
>
> - Pointer parameters follow the usual CO-RE rules, where any two
>   pointers are compatible, instead of a stricter pointer check.
>   bpf_core_type_matches() on a flavor containing just the parameter
>   tells which type it points to.
>
> - Big-endian: arguments smaller than 8 bytes are placed at the end of
>   their slot, and a new verifier patch (patch 1) allows loads of the
>   low-order bytes of context slots there, rather than widening loads
>   and poisoning signed ones. The s390x selftest restriction is gone.
>
> - libbpf: an attach target that can't be found no longer fails
>   bpf_object__prepare(); the struct just has no candidate, and the
>   program fails to load if it is loaded. Once the object is prepared,
>   bpf_program__set_type(), bpf_program__set_expected_attach_type() and
>   bpf_program__set_attach_target() fail with -EBUSY for programs whose
>   relocations depend on them (Andrey).
>
> - Selftests: test the libbpf and light skeleton paths, the LSM test
>   folded in, plus renamed and missing parameters, struct and type
>   variants, integer resizing, and the prepare-time behaviour above.
>
> - Docs: llvm_reloc.rst describes the relocation for loader
>   implementers; the libbpf overview covers common cases (a subset of
>   parameters in any order; parameters that are missing, renamed or of
>   another type on some kernels) and limitations.
>
> [1] https://lore.kernel.org/bpf/20261123223227.745345-1-almagui@kernel.org/
>
> Alan Maguire (5):
>   bpf: Allow loads of the low-order bytes of context slots on big-endian
>   libbpf: Support CO-RE relocation of tracing program arguments
>   bpf: Support CO-RE relocation of tracing program arguments
>   selftests/bpf: Test CO-RE relocation of tracing program arguments
>   Documentation/bpf: Describe CO-RE relocation of function arguments
>
>  Documentation/bpf/libbpf/libbpf_overview.rst  | 123 +++++++
>  Documentation/bpf/llvm_reloc.rst              |  72 ++++
>  include/linux/bpf.h                           |   2 +
>  kernel/bpf/btf.c                              | 253 ++++++++++++-
>  kernel/bpf/check_btf.c                        |   1 +
>  tools/lib/bpf/libbpf.c                        | 333 ++++++++++++++++++
>  tools/lib/bpf/libbpf.h                        |  13 +-
>  tools/testing/selftests/bpf/Makefile.skel     |   2 +-
>  .../selftests/bpf/prog_tests/func_args_core.c | 129 +++++++
>  .../selftests/bpf/progs/func_args_core.c      | 178 ++++++++++
>  10 files changed, 1099 insertions(+), 7 deletions(-)
>  create mode 100644 tools/testing/selftests/bpf/prog_tests/func_args_core.c
>  create mode 100644 tools/testing/selftests/bpf/progs/func_args_core.c
>
> --
> 2.56.0
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 bpf-next 0/5] libbpf, bpf: Utilize CO-RE for BPF program parameter presence, ordering
  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
  0 siblings, 0 replies; 10+ messages in thread
From: Alexei Starovoitov @ 2026-11-26  4:02 UTC (permalink / raw)
  To: Andrii Nakryiko, Alan Maguire
  Cc: daniel, andrii, andrey.grodzovsky, eddyz87, memxor, martin.lau,
	song, yonghong.song, jolsa, emil, ihor.solodrai, john.fastabend,
	mason, bpf

On Wed, Nov 25, 2026 at 02:49 PM Andrii Nakryiko <andrii.nakryiko@gmail.com> wrote:
> we need to make sure that we can use
> __attribute__((preserve_static_offset)) together with
> __attribute__((preserve_access_index))

Yes, but pls remind me, did we make it work in the most recent LLVM ?
So some sort of __BPF_FEATURE guard is necessary?
I don't recall whether we added one.

> And I'm actually wondering if the better name for this would be
> "bpf_ctx___<flavor>" or "bpf_ctx_args___<flavor>", because it's not
> always *function* arguments (tracepoint, BPF program, etc). Keeping it
> more generic as "context arguments" or just "context" seems more
> future-proof.

I'd keep bpf_func_args___ to match existing bpf_get_func_arg() helper
that reads the same slots and works for tp_btf (which is not a *function*
in your definition).

bpf_ctx* sounds like it works for every prog type,
but that is not the case.

> Also (I only skimmed patches, haven't gone through them completely,
> will get back to this next week after holidays, sorry), I saw you
> mentioned the limitation that this context access can be only done
> from entry program code, right?  I think this can be lifted if we
> apply these relocations after subprogs are appended to their
> respective main programs. Not sure how ugly that will be, but you can
> try that and see how it works (please do it as a separate patch to
> distract less from the main logic change).

Agree. good idea.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-26  4:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox