From: sashiko-bot@kernel.org
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 15/15] selftests/bpf: Add test for global data of a program in Rust
Date: Sat, 03 Oct 2026 01:33:05 +0000 [thread overview]
Message-ID: <20261003013306.493601F0089A@smtp.kernel.org> (raw)
In-Reply-To: <20261002124714.180012-16-alexei.starovoitov@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] bpf: missing ASSERT_OK_PTR for bpf_object__find_program_by_name
--
commit 3ad0a944f5e1d8b874c6e4579bc0bb7941f6ed67
Author: Alexei Starovoitov <ast@kernel.org>
selftests/bpf: Add test for global data of a program in Rust
This commit adds a test to verify how libbpf handles global data (.data,
.bss, .rodata) of a Rust BPF program within an arena. It introduces a
new Rust program and dynamically loads the resulting object file using
manual libbpf APIs in data_in_arena.c.
> diff --git a/tools/testing/selftests/bpf/prog_tests/data_in_arena.c b/tools/testing/selftests/bpf/prog_tests/data_in_arena.c
> index 86dc6798bbdef..cb1023507c017 100644
> --- a/tools/testing/selftests/bpf/prog_tests/data_in_arena.c
> +++ b/tools/testing/selftests/bpf/prog_tests/data_in_arena.c
[ ... ]
> +/* The object is there if rustc and clang can build it, see Makefile.buildvars */
> +static void test_rust(void)
> +{
> + const char *file = "./data_in_arena_rust.bpf.o";
> + struct bpf_object *obj;
> +
> + if (access(file, R_OK)) {
> + test__skip();
> + return;
> + }
> + obj = bpf_object__open_file(file, NULL);
> + if (!ASSERT_OK_PTR(obj, "open"))
> + return;
> + if (!ASSERT_OK(bpf_object__load(obj), "load"))
> + goto out;
> + /* libbpf goes on without BTF when the kernel doesn't take it */
> + ASSERT_GE(bpf_object__btf_fd(obj), 0, "btf_fd");
> + ASSERT_EQ(run_prog(bpf_object__find_program_by_name(obj, "list_in_data")),
> + 100 + 20 + 3, "retval");
[Severity: Medium]
Could this result in a crash if the program is not found in the object file?
bpf_object__find_program_by_name() returns NULL if the specified program is
not found. Passing this result directly into run_prog() without prior
validation via ASSERT_OK_PTR violates the BPF selftest guidelines for
manual lookup APIs, and might cause the test to crash instead of failing
cleanly.
> +out:
> + bpf_object__close(obj);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261002124714.180012-1-alexei.starovoitov@gmail.com?part=15
next prev parent reply other threads:[~2026-10-03 1:33 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 12:46 [PATCH bpf-next v2 00/15] bpf: Support programs compiled by rust-bpf Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 01/15] bpf: Allow bitwise ops, shifts and mul/div on pointers with CAP_PERFMON Alexei Starovoitov
2026-10-02 13:49 ` bot+bpf-ci
2026-10-02 12:47 ` [PATCH bpf-next v2 02/15] selftests/bpf: Add tests for ALU " Alexei Starovoitov
2026-10-02 13:08 ` sashiko-bot
2026-10-03 11:48 ` Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 03/15] bpf: Treat load and store through a number as arena access Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 04/15] selftests/bpf: Add tests for arena access through numbers Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 05/15] bpf: Allow names of Rust types and functions in BTF Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 06/15] selftests/bpf: Add tests for " Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 07/15] bpf: Allow arguments without names in static " Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 08/15] selftests/bpf: Add test for arguments without names in static functions Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 09/15] bpf: Allow a variable in DATASEC that is smaller than its type Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 10/15] bpftool: Skip pieces of variables in DATASEC Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 11/15] selftests/bpf: Add tests for a variable that is smaller than its type Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 12/15] libbpf: Keep global data in arena when the object has .arena.data Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 13/15] libbpf: Keep format strings of bpf_printk() in .rodata.str Alexei Starovoitov
2026-10-02 12:47 ` [PATCH bpf-next v2 14/15] selftests/bpf: Add test for global data in arena Alexei Starovoitov
2026-10-02 13:49 ` bot+bpf-ci
2026-10-02 12:47 ` [PATCH bpf-next v2 15/15] selftests/bpf: Add test for global data of a program in Rust Alexei Starovoitov
2026-10-03 1:33 ` sashiko-bot [this message]
2026-10-03 11:47 ` Alexei Starovoitov
2026-10-03 14:20 ` [PATCH bpf-next v2 00/15] bpf: Support programs compiled by rust-bpf patchwork-bot+netdevbpf
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=20261003013306.493601F0089A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexei.starovoitov@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.