From: Leon Hwang <leon.hwang@linux.dev>
To: xu.xin16@zte.com.cn, ast@kernel.org, daniel@iogearbox.net,
john.fastabend@gmail.com, andrii@kernel.org, eddyz87@gmail.com,
memxor@gmail.com, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
leon.hwang@linux.dev
Subject: Re: [PATCH bpf-next v2] bpf: Log error code on trampoline unlink failure
Date: Sun, 26 Jul 2026 23:50:05 +0800 [thread overview]
Message-ID: <31dc8d80-83d6-43fa-8e49-b5b9b3a6c648@linux.dev> (raw)
In-Reply-To: <20260726230724742Z4CDN9ntFInEofAf2YxME@zte.com.cn>
On 2026/7/26 23:07, xu.xin16@zte.com.cn wrote:
> From: xu xin <xu.xin16@zte.com.cn>
>
> Replace silent WARN_ON_ONCE with WARN_ONCE that prints the actual error
> code from bpf_trampoline_unlink_prog(). This aids debugging of race
> conditions during link teardown, while keeping the warning rate limited
> to avoid log flooding.
>
> This will be very helpful for speeding up trouble-shooting of some crash
> UAF due to bpf_trampoline_unlink_prog failures.
>
> No functional change intended.
Is it "No change to unlink behavior"?
>
> Signed-off-by: xu xin <xu.xin16@zte.com.cn>
> ---
> v1->v2:
> 1) clean the subject name by remove 'syscall' suggested by Leon Hwang
> https://lore.kernel.org/all/20a444b2-aeed-4af8-ba76-e994e2c14087@linux.dev/
> 2) Add up the missed case in kernel/bpf/trampoline.c:bpf_shim_tramp_link_release()
>
> kernel/bpf/syscall.c | 9 ++++++---
> kernel/bpf/trampoline.c | 5 ++++-
> 2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 6db306d23b47..2348dc33abf4 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -3626,10 +3626,13 @@ static void bpf_tracing_link_release(struct bpf_link *link)
> {
> struct bpf_tracing_link *tr_link =
> container_of(link, struct bpf_tracing_link, link.link);
> + int err;
>
> - WARN_ON_ONCE(bpf_trampoline_unlink_prog(&tr_link->link.node,
> - tr_link->trampoline,
> - tr_link->tgt_prog));
> + err = bpf_trampoline_unlink_prog(&tr_link->link.node,
> + tr_link->trampoline,
> + tr_link->tgt_prog);
> + if (err)
> + WARN_ONCE(err, "bpf_trampoline_unlink_prog returns error: %d\n", err);
'if (err)' here is unnecessary.
>
> bpf_trampoline_put(tr_link->trampoline);
>
> diff --git a/kernel/bpf/trampoline.c b/kernel/bpf/trampoline.c
> index 1a721fc4bef5..dae3c2104ed4 100644
> --- a/kernel/bpf/trampoline.c
> +++ b/kernel/bpf/trampoline.c
> @@ -997,12 +997,15 @@ static void bpf_shim_tramp_link_release(struct bpf_link *link)
> {
> struct bpf_shim_tramp_link *shim_link =
> container_of(link, struct bpf_shim_tramp_link, link.link);
> + int err;
>
> /* paired with 'shim_link->trampoline = tr' in bpf_trampoline_link_cgroup_shim */
> if (!shim_link->trampoline)
> return;
>
> - WARN_ON_ONCE(bpf_trampoline_unlink_prog(&shim_link->link.node, shim_link->trampoline, NULL));
> + err = bpf_trampoline_unlink_prog(&shim_link->link.node, shim_link->trampoline, NULL);
> + if (err)
> + WARN_ONCE(err, "bpf_trampoline_unlink_prog returns error: %d\n", err);
Ditto.
> bpf_trampoline_put(shim_link->trampoline);
> }
>
Would it be better to include this multi_detach() one?
WARN_ON_ONCE(__bpf_trampoline_unlink_prog(&mnode->node, mnode->trampoline,
NULL, &trampoline_multi_ops, data));
Thanks,
Leon
next prev parent reply other threads:[~2026-07-26 15:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-26 15:07 [PATCH bpf-next v2] bpf: Log error code on trampoline unlink failure xu.xin16
2026-07-26 15:50 ` Leon Hwang [this message]
2026-07-27 2:31 ` xu.xin16
2026-07-27 5:27 ` Leon Hwang
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=31dc8d80-83d6-43fa-8e49-b5b9b3a6c648@linux.dev \
--to=leon.hwang@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--cc=xu.xin16@zte.com.cn \
--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