BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Alan Maguire" <almagui@kernel.org>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 3/7] selftests/bpf: Test CO-RE relocation of tracing program arguments
Date: Mon, 23 Nov 2026 22:43:45 +0000	[thread overview]
Message-ID: <sashiko-outbox-230159@kernel.org> (raw)
In-Reply-To: <20261123223227.745345-4-almagui@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] selftests/bpf: unfiltered tracing hooks in
  test_func_args_core() race under -j
- [Low] selftests/bpf: multi-line comments in func_args_core.c violate
  BPF comment style
--

commit 0bbc8fc67b8eff90ed517069d0dfc1334363d6c3
Author: Alan Maguire <almagui@kernel.org>

selftests/bpf: Test CO-RE relocation of tracing program arguments

This commit adds BPF selftests covering CO-RE relocation of tracing program
arguments using __bpf_func_args structs and BPF_PROG_CORE() with both libbpf
and light skeletons.

> 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 0000000000000..1516ad13eaa26
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/func_args_core.c
> @@ -0,0 +1,130 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <test_progs.h>
> +#include "func_args_core.skel.h"
> +#include "func_args_core.lskel.h"
> +
> +/* runs bpf_fentry_test1..N() (via a fentry prog), bpf_modify_return_test()
> + * (via a fmod_ret prog) and bpf_testmod's test read
> + */

[Severity: Low]
This isn't a bug, but BPF coding style places the opening /* of a multi-line
comment on its own line, with the comment text starting on the next line.
The same applies to the other multi-line comments in this file and in
progs/func_args_core.c.

> 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 0000000000000..4656a6c642d10
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/func_args_core.c

[ ... ]

> +SEC("fmod_ret/bpf_modify_return_test")
> +int fmod_ret_test(struct modify_return_args *args)
> +{
> +	fm_calls++;
> +	fm_a = args->a;
> +	fm_b_set = args->b != NULL;
> +	fm_ret = args->ret;
> +	fm_ret_exists = bpf_core_field_exists(args->ret);
> +	fm_missing_exists = bpf_core_field_exists(args->missing);
> +	/* don't override the return value */
> +	return 0;
> +}
> +
> +/* fsession on bpf_fentry_test3(char a, int b, u64 c), called as (4, 5, 6) */
> +__u64 fs_entry_c, fs_exit_c;
> +int fs_entry_ret = -1, fs_exit_ret = -1, fs_ret_exists = -1;
> +int fs_entry_calls, fs_exit_calls;
> +
> +SEC("fsession/bpf_fentry_test3")
> +int BPF_PROG_CORE(fsession3, __u64, c, __bpf_func_ret int, ret)
> +{
> +	fs_ret_exists = bpf_func_arg_exists(ret);
> +	if (!bpf_session_is_return(ctx)) {
> +		fs_entry_calls++;
> +		fs_entry_c = c;
> +		fs_entry_ret = ret;
> +	} else {
> +		fs_exit_calls++;
> +		fs_exit_c = c;
> +		fs_exit_ret = ret;
> +	}
> +	return 0;
> +}

[ ... ]

> +SEC("tp_btf/bpf_testmod_test_read")
> +int tp_read(struct test_read_args *args)
> +{
> +	tp_pid = args->task->pid;
> +	tp_len = args->ctx->len;
> +	tp_bad_ptr_exists = bpf_core_field_exists(args->task___bad_ptr);
> +	tp_fwd_exists = bpf_core_field_exists(args->task___fwd);
> +	tp_void_exists = bpf_core_field_exists(args->ctx___void);
> +	tp_void_same = args->ctx___void == (void *)args->ctx;
> +	return 0;
> +}

[ ... ]

> +SEC("tp_btf/bpf_testmod_test_read")
> +int BPF_PROG_CORE(tp_read_macro, struct task_struct *, task)
> +{
> +	mtp_pid = task->pid;
> +	return 0;
> +}

[Severity: Medium]
Can concurrent test_progs workers cause check_results() assertions to fail
when test_progs runs with -j?

test_func_args_core() runs in parallel with other selftests that call
trigger_module_test_read() or invoke bpf_fentry_test3() and
bpf_modify_return_test() via bpf_prog_test_run_opts(). Because these programs
do not filter by the test worker's PID, another worker can increment
fm_calls, fs_entry_calls, and fs_exit_calls past 1, or overwrite tp_pid,
mtp_pid, and tp_len with its own PID and read length before check_results()
runs. In addition, if test_get_func_args_test() runs concurrently, its
fmod_ret program on bpf_modify_return_test() returns 1234 without PID
filtering, causing the trampoline to short-circuit and skip fmod_ret_test().

Filtering events by a target PID (and making the test serial if needed to
avoid fmod_ret short-circuiting from other tests) would avoid this race.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123223227.745345-1-almagui@kernel.org?part=3

  reply	other threads:[~2026-11-23 22:43 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 22:32 [PATCH bpf-next 0/7] libbpf, bpf: Utilize CO-RE for BPF program parameter presence, ordering Alan Maguire
2026-11-23 22:32 ` [PATCH bpf-next 1/7] libbpf: Support CO-RE relocation of tracing program arguments Alan Maguire
2026-11-23 22:53   ` sashiko-bot
2026-11-23 22:32 ` [PATCH bpf-next 2/7] bpf: " Alan Maguire
2026-11-23 22:52   ` sashiko-bot
2026-11-23 22:32 ` [PATCH bpf-next 3/7] selftests/bpf: Test " Alan Maguire
2026-11-23 22:43   ` sashiko-bot [this message]
2026-11-23 22:32 ` [PATCH bpf-next 4/7] selftests/bpf: Test CO-RE relocation of BPF LSM " Alan Maguire
2026-11-23 22:41   ` sashiko-bot
2026-11-23 22:32 ` [PATCH bpf-next 5/7] libbpf: Report function argument relocation support via type existence Alan Maguire
2026-11-23 22:38   ` sashiko-bot
2026-11-23 22:32 ` [PATCH bpf-next 6/7] selftests/bpf: Test detection of function argument relocation support Alan Maguire
2026-11-23 22:36   ` sashiko-bot
2026-11-23 22:32 ` [PATCH bpf-next 7/7] Documentation/bpf: Describe CO-RE relocation of function arguments Alan Maguire

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-230159@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