From: Jiri Olsa <olsajiri@gmail.com>
To: chenyuan_fl@163.com
Cc: alexei.starovoitov@gmail.com, ast@kernel.org,
leon.hwang@linux.dev, bpf@vger.kernel.org, daniel@iogearbox.net,
andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com,
martin.lau@linux.dev, yonghong.song@linux.dev,
john.fastabend@gmail.com, song@kernel.org,
ihor.solodrai@linux.dev, Yuan Chen <chenyuan@kylinos.cn>
Subject: Re: [PATCH bpf-next v2 0/2] bpf: Keep target extended until its last freplace link detaches
Date: Thu, 24 Sep 2026 10:42:02 +0200 [thread overview]
Message-ID: <arTiWpZ_pWsEMQa_@krava> (raw)
In-Reply-To: <20260924023737.1140521-1-chenyuan_fl@163.com>
On Thu, Sep 24, 2026 at 10:37:35AM +0800, chenyuan_fl@163.com wrote:
> From: Yuan Chen <chenyuan@kylinos.cn>
>
> is_extended is a plain boolean, but one target prog can carry several
> freplace links at the same time, one on its entry and one on a global
> subprogram. __bpf_trampoline_unlink_prog() cleared it whenever *any*
> of them detached, so with two links on one target, detaching one of
> them re-armed the unbounded tail call loop closed by commit
> d6083f040d5d ("bpf: Prevent tailcall infinite loop caused by freplace"):
> a single BPF_PROG_TEST_RUN on the tail-called target then panics the
> kernel, reproduced on both bpf-next and master.
>
> Patch 1 replaces the boolean with a count of the freplace links
> attached to each target prog, so the target stays extended until its
> last link detaches. Patch 2 adds a selftest covering the sequence.
>
> Changes since v1:
>
> - freplace_link_cnt is u16 instead of u64, per Alexei's review: it is
> bounded by BPF_MAX_SUBPROGS, which counts the entry function too, so
> up to 256 links, one past u8, and it sits in the padding next to
> stack_arg_sp_adjust, so bpf_prog_aux does not grow
> - dropped the separate is_extended boolean, deriving the extended state
> from the count itself
> - renamed bpf_freplace_check_tgt_prog() to bpf_freplace_link_tgt_prog(),
> it reserves the target on success
> - dropped the WARN_ON_ONCE() on detach, per Leon's review: the count is
> paired by the link lifetime and the sibling prog_array_member_cnt
> decrement is not guarded either
>
> Yuan Chen (2):
> bpf: Keep target extended until its last freplace link detaches
> selftests/bpf: Verify is_extended with multiple freplace links
Acked-by: Jiri Olsa <jolsa@kernel.org>
jirka
>
> include/linux/bpf.h | 4 +-
> kernel/bpf/arraymap.c | 2 +-
> kernel/bpf/trampoline.c | 8 +-
> .../selftests/bpf/prog_tests/tailcalls.c | 74 +++++++++++++++++++
> .../bpf/progs/tailcall_freplace_multi.c | 27 +++++++
> 5 files changed, 108 insertions(+), 7 deletions(-)
> create mode 100644 tools/testing/selftests/bpf/progs/tailcall_freplace_multi.c
>
> --
> 2.54.0
>
>
next prev parent reply other threads:[~2026-09-24 8:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 2:37 [PATCH bpf-next v2 0/2] bpf: Keep target extended until its last freplace link detaches chenyuan_fl
2026-09-24 2:37 ` [PATCH bpf-next v2 1/2] " chenyuan_fl
2026-09-24 7:06 ` Leon Hwang
2026-09-24 9:48 ` Jiri Olsa
2026-09-24 9:58 ` chenyuan
2026-09-25 4:35 ` [PATCH bpf-next] bpf: Roll back freplace link state when bpf_arch_text_poke() fails chenyuan_fl
2026-09-25 5:18 ` bot+bpf-ci
2026-09-25 6:05 ` Leon Hwang
2026-09-28 9:08 ` chenyuan
2026-09-24 2:37 ` [PATCH bpf-next v2 2/2] selftests/bpf: Verify is_extended with multiple freplace links chenyuan_fl
2026-09-24 7:06 ` Leon Hwang
2026-09-24 8:42 ` Jiri Olsa [this message]
2026-09-24 9:00 ` [PATCH bpf-next v2 0/2] bpf: Keep target extended until its last freplace link detaches 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=arTiWpZ_pWsEMQa_@krava \
--to=olsajiri@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenyuan@kylinos.cn \
--cc=chenyuan_fl@163.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=leon.hwang@linux.dev \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--cc=yonghong.song@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