From: sashiko-bot@kernel.org
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 21/21] selftests/bpf: Test limits of the load with raw programs
Date: Mon, 16 Nov 2026 06:39:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-216288@kernel.org> (raw)
In-Reply-To: <20261116055638.4171529-22-alexei.starovoitov@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] selftests/bpf: unguarded JIT-only xlated imm check in
test_subprogs()
- [Low] selftests/bpf: pipe write fd leak on error path in
test_freezer()
--
commit 3c3d567efb107d402bf1f0ddb12c0e6adeace271
Author: Alexei Starovoitov <ast@kernel.org>
selftests/bpf: Test limits of the load with raw programs
This commit adds a no_limits selftest suite covering BPF program and BTF
loading edge cases such as signals, cgroup freezer, memory cgroup limits,
syscall program contexts, large numbers of subprogs, kfuncs, and light
skeletons.
> diff --git a/tools/testing/selftests/bpf/prog_tests/no_limits.c b/tools/testing/selftests/bpf/prog_tests/no_limits.c
> new file mode 100644
> index 0000000000000..2c9e5855f306a
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/no_limits.c
[ ... ]
> +/* The freezer does not wait for the end of the load. The load starts again after it. */
> +static void test_freezer(void)
> +{
> + LIBBPF_OPTS(bpf_prog_load_opts, opts, .attempts = 1);
> + struct bpf_insn *insns = straight_code(200000);
> + int cg = -1, pipes[2] = { -1, -1 }, fd;
> + char buf[64] = "";
> + pid_t pid;
> +
> + if (!insns || !ASSERT_OK(setup_cgroup_environment(), "setup") ||
> + !ASSERT_OK(pipe(pipes), "pipe"))
> + goto out;
> + cg = create_and_get_cgroup("/no_limits");
> + if (!ASSERT_OK_FD(cg, "cgroup"))
> + goto out;
> + pid = fork();
> + if (!pid) {
> + /* the fd that the prog gets */
> + if (join_parent_cgroup("/no_limits"))
> + _exit(1);
> + fd = dup(pipes[0]);
> + close(fd);
> + if (write(pipes[1], &fd, sizeof(fd)) != sizeof(fd))
> + _exit(2);
> + _exit(bpf_prog_load(BPF_PROG_TYPE_SCHED_CLS, NULL, "GPL", insns, 200000,
> + &opts) != fd ? 3 : 0);
> + }
> + close(pipes[1]);
> + if (ASSERT_EQ(read(pipes[0], &fd, sizeof(fd)), sizeof(fd), "read")) {
> + usleep(10000);
> + ASSERT_OK(write_cgroup_file("/no_limits", "cgroup.freeze", "1"), "freeze");
> + while (!strstr(buf, "frozen 1") &&
> + !read_cgroup_file("/no_limits", "cgroup.events", buf, sizeof(buf)))
> + usleep(1000);
> + snprintf(buf, sizeof(buf), "/proc/%d/fd/%d", pid, fd);
> + ASSERT_ERR(faccessat(AT_FDCWD, buf, F_OK, AT_SYMLINK_NOFOLLOW), "no prog yet");
> + ASSERT_OK(write_cgroup_file("/no_limits", "cgroup.freeze", "0"), "thaw");
> + }
> + ASSERT_OK(exit_code(pid), "load");
> +out:
> + close(pipes[0]);
> + if (cg >= 0)
> + close(cg);
> + cleanup_cgroup_environment();
> + free(insns);
> +}
[Severity: Low]
Does the out path leak pipes[1] if create_and_get_cgroup() fails? That
error jump happens after pipe(pipes) succeeds and before close(pipes[1]),
leaving pipes[1] open in the test_progs runner across later tests, and
earlier failures also call close(-1) on pipes[0].
[ ... ]
> +/* The number of a subprog does not fit into s16 */
> +static void test_subprogs(void)
> +{
> + const int funcs = 33000, cnt = 4 * funcs + 1;
> + struct bpf_insn *insns = many_funcs(funcs);
> + struct bpf_prog_info info = {};
> + __u32 len = sizeof(info);
> + int fd;
> +
> + if (!insns)
> + return;
> + fd = load(insns, cnt);
> + if (!ASSERT_OK_FD(fd, "load"))
> + goto out;
> + ASSERT_EQ(run(fd), funcs - 1, "retval");
> + info.xlated_prog_len = cnt * sizeof(*insns);
> + info.xlated_prog_insns = ptr_to_u64(insns);
> + if (ASSERT_OK(bpf_prog_get_info_by_fd(fd, &info, &len), "dump"))
> + ASSERT_EQ(insns[funcs - 1].imm, funcs, "subprog");
[Severity: Medium]
Will this assertion fail when BPF JIT is disabled or unavailable?
When a program is not JIT-compiled, bpf_fixup_call_args() rewrites
pseudo-calls to BPF_JMP | BPF_CALL_ARGS for the interpreter, so
prepare_dump_pseudo_call() dumps bpf_call_args_imm(insn->off) instead of
the subprogram index:
kernel/bpf/syscall.c:prepare_dump_pseudo_call() {
...
if (insn->code == (BPF_JMP | BPF_CALL_ARGS))
insn->imm = bpf_call_args_imm(insn->off);
else
insn->imm = bpf_prog_find_func(prog, idx + call_off + 1);
...
}
Guarding this check on env.jit_enabled (or info.jited_prog_len) would
avoid false test failures on interpreter runs.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116055638.4171529-1-alexei.starovoitov@gmail.com?part=21
prev parent reply other threads:[~2026-11-16 6:39 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 5:56 [PATCH bpf-next 00/21] bpf: Remove the limits on maps, kfuncs, subprogs and special fields Alexei Starovoitov
2026-11-16 5:56 ` [PATCH bpf-next 01/21] bpf: Stop a load only when the loader is killed or has to freeze Alexei Starovoitov
2026-11-16 6:39 ` bot+bpf-ci
2026-11-16 6:49 ` sashiko-bot
2026-11-16 5:56 ` [PATCH bpf-next 02/21] bpf: Fail the load when there is no memory Alexei Starovoitov
2026-11-16 6:29 ` sashiko-bot
2026-11-16 5:56 ` [PATCH bpf-next 03/21] bpf: Give a syscall program the largest context when it does tail calls Alexei Starovoitov
2026-11-16 5:56 ` [PATCH bpf-next 04/21] bpf: Do not inline bpf_loop() when its callback is dead code Alexei Starovoitov
2026-11-16 5:56 ` [PATCH bpf-next 05/21] bpf: Dump programs that have more than 524288 insns Alexei Starovoitov
2026-11-16 5:56 ` [PATCH bpf-next 06/21] bpf: Resolve BTF structs and arrays first Alexei Starovoitov
2026-11-16 6:13 ` sashiko-bot
2026-11-16 5:56 ` [PATCH bpf-next 07/21] bpf: Remove the limits on maps, BTFs and fd_array of a program Alexei Starovoitov
2026-11-16 6:39 ` bot+bpf-ci
2026-11-16 5:56 ` [PATCH bpf-next 08/21] bpf: Do not scan all maps for each insn and each subprog Alexei Starovoitov
2026-11-16 6:16 ` sashiko-bot
2026-11-16 5:56 ` [PATCH bpf-next 09/21] bpf: Remove the limits on kfuncs of a program Alexei Starovoitov
2026-11-16 6:39 ` bot+bpf-ci
2026-11-16 5:56 ` [PATCH bpf-next 10/21] bpf: Remove the limits on tables of functions Alexei Starovoitov
2026-11-16 6:14 ` sashiko-bot
2026-11-16 5:56 ` [PATCH bpf-next 11/21] libbpf: Size the tables of the loader program from the object Alexei Starovoitov
2026-11-16 6:20 ` sashiko-bot
2026-11-16 5:56 ` [PATCH bpf-next 12/21] bpf: Relax jumps that patches push out of range Alexei Starovoitov
2026-11-16 6:52 ` bot+bpf-ci
2026-11-16 5:56 ` [PATCH bpf-next 13/21] bpf: Keep the call graph in lists of edges Alexei Starovoitov
2026-11-16 6:39 ` sashiko-bot
2026-11-16 5:56 ` [PATCH bpf-next 14/21] bpf: Find the effects of callees on the call graph Alexei Starovoitov
2026-11-16 5:56 ` [PATCH bpf-next 15/21] bpf: Link the decl tags of a type Alexei Starovoitov
2026-11-16 5:56 ` [PATCH bpf-next 16/21] bpf: Remove BPF_MAX_SUBPROGS Alexei Starovoitov
2026-11-16 5:56 ` [PATCH bpf-next 17/21] bpf: Walk each type once when looking for special fields Alexei Starovoitov
2026-11-16 5:56 ` [PATCH bpf-next 18/21] bpf: Raise the limit on the length of BTF names Alexei Starovoitov
2026-11-16 5:56 ` [PATCH bpf-next 19/21] bpf: Find dominators in O(n log n) Alexei Starovoitov
2026-11-16 5:56 ` [PATCH bpf-next 20/21] selftests/bpf: Test programs above the old limits Alexei Starovoitov
2026-11-16 6:33 ` sashiko-bot
2026-11-16 6:39 ` bot+bpf-ci
2026-11-16 5:56 ` [PATCH bpf-next 21/21] selftests/bpf: Test limits of the load with raw programs Alexei Starovoitov
2026-11-16 6:39 ` sashiko-bot [this message]
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-216288@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox