From: "Florent Revest" <florent.revest@linux.dev>
To: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>,
<bot+bpf-ci@kernel.org>, <bpf@vger.kernel.org>,
<daniel@iogearbox.net>, <andrii@kernel.org>
Cc: <martin.lau@linux.dev>, <eddyz87@gmail.com>, <memxor@gmail.com>,
<song@kernel.org>, <yonghong.song@linux.dev>, <jolsa@kernel.org>,
<kpsingh@kernel.org>, <john.fastabend@gmail.com>,
<leon.hwang@linux.dev>, <zirajs7@gmail.com>,
<rhkrqnwk98@gmail.com>, <puranjay@kernel.org>,
<xukuohai@huaweicloud.com>, <iii@linux.ibm.com>,
<hbathini@linux.ibm.com>, <chleroy@kernel.org>,
<naveen@kernel.org>, <bjorn@kernel.org>, <pulehui@huawei.com>,
<yangtiezhu@loongson.cn>, <hengqi.chen@gmail.com>,
<linux-kernel@vger.kernel.org>, <martin.lau@kernel.org>,
<mason@kernel.org>, <ihor.solodrai@linux.dev>
Subject: Re: [PATCH bpf v4 2/3] bpf: Skip detached progs in trampoline images that are still in use
Date: Sat, 26 Sep 2026 13:52:35 +0000 [thread overview]
Message-ID: <DLPAQECUALBD.2J6OV9FK2MA87@linux.dev> (raw)
In-Reply-To: <DLP46AE97EYD.1I2HDPGBR8GME@gmail.com>
On Sat Sep 26, 2026 at 8:44 AM UTC, Alexei Starovoitov wrote:
> On Fri, Sep 25, 2026 at 10:47 AM bot+bpf-ci@kernel.org <bot+bpf-ci@kernel.org> wrote:
> >> + /* nops for move_imm+jirl, patched to skip this prog when it is detached */
> >> + for (i = 0; i < LOONGARCH_LONG_JUMP_NINSNS; i++)
> >> + emit_insn(ctx, nop);
> >
> > Can a task preempted inside the skip sled resume into half of the new jump
> > sequence and jump to a garbage address?
>
> [...]
>
> > Could the LoongArch skip site use a single instruction instead? For
> > example, a 'b' to the skip target, which is always within the +/-128MB
> > range of the same image, patched from nop to 'b'. The rest of the sled
> > would then be unnecessary.
>
> Seems like a real bug. Same issue on riscv.
>
> ip_after_call was patched in bpf_tramp_image_put() when the image was
> already unreachable. Now bpf_trampoline_remove_prog() patches cur_image
> before bpf_trampoline_update() replaces it, so every call of the traced
> function goes through the sled while it is rewritten. stop_machine
> doesn't help the task that it preempted in the middle of the sled.
>
> Pls fix and respin.
> Everything else looks good.
Ok. In v5, on riscv and loongarch, it will emit single nops at skip sites and
patch them with jal or b instructions. They can always reach their target since
they are in the same image. This requires a new arch_bpf_trampoline_skip() hook
that defaults to bpf_arch_text_poke() on other archs. I tested it in QEMU.
next prev parent reply other threads:[~2026-09-26 13:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 10:03 [PATCH bpf v4 0/3] bpf: Fix use-after-free of progs detached from busy trampolines Florent Revest (Anthropic)
2026-09-25 10:03 ` [PATCH bpf v4 1/3] bpf: Wait for an RCU tasks grace period before freeing trampoline progs Florent Revest (Anthropic)
2026-09-25 10:47 ` bot+bpf-ci
2026-09-26 13:54 ` Florent Revest
2026-09-25 10:03 ` [PATCH bpf v4 2/3] bpf: Skip detached progs in trampoline images that are still in use Florent Revest (Anthropic)
2026-09-25 10:47 ` bot+bpf-ci
2026-09-26 8:44 ` Alexei Starovoitov
2026-09-26 13:52 ` Florent Revest [this message]
2026-09-26 13:54 ` Florent Revest
2026-09-25 10:03 ` [PATCH bpf v4 3/3] selftests/bpf: Detach a trampoline prog while a task sleeps before it Florent Revest (Anthropic)
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=DLPAQECUALBD.2J6OV9FK2MA87@linux.dev \
--to=florent.revest@linux.dev \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bjorn@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chleroy@kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=hbathini@linux.ibm.com \
--cc=hengqi.chen@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=iii@linux.ibm.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=leon.hwang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=mason@kernel.org \
--cc=memxor@gmail.com \
--cc=naveen@kernel.org \
--cc=pulehui@huawei.com \
--cc=puranjay@kernel.org \
--cc=rhkrqnwk98@gmail.com \
--cc=song@kernel.org \
--cc=xukuohai@huaweicloud.com \
--cc=yangtiezhu@loongson.cn \
--cc=yonghong.song@linux.dev \
--cc=zirajs7@gmail.com \
/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.