From: sashiko-bot@kernel.org
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 3/5] bpf: Remove BPF_MAX_TRAMP_LINKS
Date: Thu, 19 Nov 2026 01:39:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-222288@kernel.org> (raw)
In-Reply-To: <20261119012909.3657417-4-alexei.starovoitov@gmail.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] bpf: missing list rollback on error in
bpf_trampoline_add_prog() [1]
--
commit 6cc47d6522f82133a841a876d884e04a65d2d4b1
Author: Alexei Starovoitov <ast@kernel.org>
bpf: Remove BPF_MAX_TRAMP_LINKS
This commit removes the fixed BPF_MAX_TRAMP_LINKS program count limit on
BPF trampolines, relying instead on a 4 KB image size limit
(BPF_TRAMP_IMAGE_MAX_SIZE), dynamically allocating the bpf_tramp_nodes
arrays, and patching s390 skip branches directly.
> diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c
> index 21d460866dfef..4dd4040e784f1 100644
> --- a/kernel/bpf/trampoline.c
> +++ b/kernel/bpf/trampoline.c
[ ... ]
> @@ -889,22 +893,17 @@ static struct bpf_tramp_node *fsession_exit(struct bpf_tramp_node *node)
> }
>
> static int bpf_trampoline_add_prog(struct bpf_trampoline *tr,
> - struct bpf_tramp_node *node,
> - int cnt)
> + struct bpf_tramp_node *node)
> {
> enum bpf_tramp_prog_type kind;
> struct bpf_tramp_node *node_existing, *fexit;
> struct hlist_head *prog_list;
>
> kind = bpf_attach_type_to_tramp(node->link->prog);
> - if (kind == BPF_TRAMP_FSESSION) {
> + if (kind == BPF_TRAMP_FSESSION)
> prog_list = &tr->progs_hlist[BPF_TRAMP_FENTRY];
> - cnt++;
> - } else {
> + else
> prog_list = &tr->progs_hlist[kind];
> - }
> - if (cnt >= BPF_MAX_TRAMP_LINKS)
> - return -E2BIG;
> if (!hlist_unhashed(&node->tramp_hlist))
> /* prog already linked */
> return -EBUSY;
[Severity: Critical]
This problem wasn't introduced by this patch, but can
bpf_trampoline_add_prog() leave a dangling node on prog_list when
fsession_exit() fails [1]?
Later in this function, node->tramp_hlist is linked into prog_list and
tr->progs_cnt[BPF_TRAMP_FENTRY] is incremented before fsession_exit() is
checked:
kernel/bpf/trampoline.c:bpf_trampoline_add_prog() {
...
hlist_add_head(&node->tramp_hlist, prog_list);
node->link->prog->aux->tramp_linked = true;
if (kind == BPF_TRAMP_FSESSION) {
tr->progs_cnt[BPF_TRAMP_FENTRY]++;
fexit = fsession_exit(node);
if (WARN_ON_ONCE(!fexit))
return -EINVAL;
...
}
If a BPF_TRAMP_FSESSION program is attached with a link type other than
BPF_LINK_TYPE_TRACING or BPF_LINK_TYPE_TRACING_MULTI, fsession_exit()
returns NULL and bpf_trampoline_add_prog() returns -EINVAL without
unlinking node->tramp_hlist, decrementing tr->progs_cnt[BPF_TRAMP_FENTRY],
or clearing tramp_linked. Because callers free node on error, subsequent
trampoline accesses will hit a use-after-free on prog_list.
[1] https://sashiko.dev/#/bug/linux-6367ff56-4b7b-447b-bfcf-d5da9ee421e9
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119012909.3657417-1-alexei.starovoitov@gmail.com?part=3
next prev parent reply other threads:[~2026-11-19 1:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 1:29 [PATCH bpf-next 0/5] bpf: Trampolines: the size of the image, the type of the return value Alexei Starovoitov
2026-11-19 1:29 ` [PATCH bpf-next 1/5] bpf, x86: Count the size of a trampoline, do not emit it Alexei Starovoitov
2026-11-19 1:29 ` [PATCH bpf-next 2/5] selftests/bpf: Don't use BPF_MAX_TRAMP_LINKS Alexei Starovoitov
2026-11-19 1:29 ` [PATCH bpf-next 3/5] bpf: Remove BPF_MAX_TRAMP_LINKS Alexei Starovoitov
2026-11-19 1:39 ` sashiko-bot [this message]
2026-11-19 1:45 ` Alexei Starovoitov
2026-11-19 2:08 ` bot+bpf-ci
2026-11-19 1:29 ` [PATCH bpf-next 4/5] bpf, x86, arm64: Fit the return value of a prog to the return type Alexei Starovoitov
2026-11-19 1:29 ` [PATCH bpf-next 5/5] selftests/bpf: Test the width of the value of an fmod_ret program Alexei Starovoitov
2026-11-19 5:10 ` [PATCH bpf-next 0/5] bpf: Trampolines: the size of the image, the type of the return value 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=sashiko-outbox-222288@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