The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf:syscall: Log error code on trampoline unlink failure
@ 2026-07-16  3:34 xu.xin16
  2026-07-16  4:58 ` Leon Hwang
  0 siblings, 1 reply; 8+ messages in thread
From: xu.xin16 @ 2026-07-16  3:34 UTC (permalink / raw)
  To: ast, daniel, john.fastabend, andrii, eddyz87, memxor, martin.lau,
	song, yonghong.song, jolsa, emil, bpf, linux-kernel
  Cc: xu.xin16, xu.xin

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.

Signed-off-by: xu xin <xu.xin16@zte.com.cn>
---
 kernel/bpf/syscall.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 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);

 	bpf_trampoline_put(tr_link->trampoline);

-- 
2.25.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH bpf-next] bpf:syscall: Log error code on trampoline unlink failure
  2026-07-16  3:34 [PATCH bpf-next] bpf:syscall: Log error code on trampoline unlink failure xu.xin16
@ 2026-07-16  4:58 ` Leon Hwang
  2026-07-16  5:55   ` xu.xin16
  0 siblings, 1 reply; 8+ messages in thread
From: Leon Hwang @ 2026-07-16  4:58 UTC (permalink / raw)
  To: xu.xin16, ast, daniel, john.fastabend, andrii, eddyz87, memxor,
	martin.lau, song, yonghong.song, jolsa, emil, bpf, linux-kernel
  Cc: xu.xin

In subject, 'bpf:' is enough, 'syscall:' can be dropped.

On 16/7/26 11:34, 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.


Have you tried to trace bpf_trampoline_unlink_prog() with fexit?

bpftrace -lv 'fexit:bpf_trampoline_unlink_prog'
kretfunc:vmlinux:bpf_trampoline_unlink_prog
    struct bpf_tramp_node * node
    struct bpf_trampoline * tr
    struct bpf_prog * tgt_prog
    int retval

Since bpf_trampoline_unlink_prog() can be traced with fexit, it seems
unnecessary for this change?

Thanks,
Leon

> [...]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH bpf-next] bpf:syscall: Log error code on trampoline unlink failure
  2026-07-16  4:58 ` Leon Hwang
@ 2026-07-16  5:55   ` xu.xin16
  2026-07-16  6:09     ` Leon Hwang
  0 siblings, 1 reply; 8+ messages in thread
From: xu.xin16 @ 2026-07-16  5:55 UTC (permalink / raw)
  To: leon.hwang
  Cc: ast, daniel, john.fastabend, andrii, eddyz87, memxor, martin.lau,
	song, yonghong.song, jolsa, emil, bpf, linux-kernel, xu.xin

> In subject, 'bpf:' is enough, 'syscall:' can be dropped.

Ok, thanks.

> 
> On 16/7/26 11:34, 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.
> 
> 
> Have you tried to trace bpf_trampoline_unlink_prog() with fexit?
> 
> bpftrace -lv 'fexit:bpf_trampoline_unlink_prog'
> kretfunc:vmlinux:bpf_trampoline_unlink_prog
>     struct bpf_tramp_node * node
>     struct bpf_trampoline * tr
>     struct bpf_prog * tgt_prog
>     int retval
> 
> Since bpf_trampoline_unlink_prog() can be traced with fexit, it seems
> unnecessary for this change?

Well, the crash may happen when the kernel is booting, or too hard to reproduce,
in which case, bpftrace does not work.

So this change will be more helpful, I believe.

Thanks,
xu xin

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH bpf-next] bpf:syscall: Log error code on trampoline unlink failure
  2026-07-16  5:55   ` xu.xin16
@ 2026-07-16  6:09     ` Leon Hwang
  2026-07-16  6:26       ` xu.xin16
  0 siblings, 1 reply; 8+ messages in thread
From: Leon Hwang @ 2026-07-16  6:09 UTC (permalink / raw)
  To: xu.xin16, leon.hwang
  Cc: ast, daniel, john.fastabend, andrii, eddyz87, memxor, martin.lau,
	song, yonghong.song, jolsa, emil, bpf, linux-kernel, xu.xin

On 16/7/26 13:55, xu.xin16@zte.com.cn wrote:
>> In subject, 'bpf:' is enough, 'syscall:' can be dropped.
> 
> Ok, thanks.
> 
>>
>> On 16/7/26 11:34, 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.
>>
>>
>> Have you tried to trace bpf_trampoline_unlink_prog() with fexit?
>>
>> bpftrace -lv 'fexit:bpf_trampoline_unlink_prog'
>> kretfunc:vmlinux:bpf_trampoline_unlink_prog
>>     struct bpf_tramp_node * node
>>     struct bpf_trampoline * tr
>>     struct bpf_prog * tgt_prog
>>     int retval
>>
>> Since bpf_trampoline_unlink_prog() can be traced with fexit, it seems
>> unnecessary for this change?
> 
> Well, the crash may happen when the kernel is booting, or too hard to reproduce,
> in which case, bpftrace does not work.


Do you enable kernel.panic_on_warn sysctl?

If it's not enabled, the kernel won't crash, I think.

Thanks,
Leon

> 
> So this change will be more helpful, I believe.
> 
> Thanks,
> xu xin
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH bpf-next] bpf:syscall: Log error code on trampoline unlink failure
  2026-07-16  6:09     ` Leon Hwang
@ 2026-07-16  6:26       ` xu.xin16
  2026-07-16  6:56         ` Leon Hwang
  0 siblings, 1 reply; 8+ messages in thread
From: xu.xin16 @ 2026-07-16  6:26 UTC (permalink / raw)
  To: leon.hwang
  Cc: leon.hwang, ast, daniel, john.fastabend, andrii, eddyz87, memxor,
	martin.lau, song, yonghong.song, jolsa, emil, bpf, linux-kernel,
	xu.xin

> > Well, the crash may happen when the kernel is booting, or too hard to reproduce,
> > in which case, bpftrace does not work.
> 
> 
> Do you enable kernel.panic_on_warn sysctl?
> 
> If it's not enabled, the kernel won't crash, I think.

I'd like to clarify that the panic in our case is not triggered by the WARN itself.
Instead, the real crash is a use‑after‑free (UAF) that happens when one CPU is
executing a trampoline while another CPU is concurrently freeing it. This results
in an illegal instruction (or page fault) at the PC, which is fatal and will panic
the kernel regardless of panic_on_warn – because it's an Oops with Fatal exception
in interrupt.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH bpf-next] bpf:syscall: Log error code on trampoline unlink failure
  2026-07-16  6:26       ` xu.xin16
@ 2026-07-16  6:56         ` Leon Hwang
  2026-07-16  7:03           ` xu.xin16
  0 siblings, 1 reply; 8+ messages in thread
From: Leon Hwang @ 2026-07-16  6:56 UTC (permalink / raw)
  To: xu.xin16
  Cc: ast, daniel, john.fastabend, andrii, eddyz87, memxor, martin.lau,
	song, yonghong.song, jolsa, emil, bpf, linux-kernel, xu.xin

On 16/7/26 14:26, xu.xin16@zte.com.cn wrote:
>>> Well, the crash may happen when the kernel is booting, or too hard to reproduce,
>>> in which case, bpftrace does not work.
>>
>>
>> Do you enable kernel.panic_on_warn sysctl?
>>
>> If it's not enabled, the kernel won't crash, I think.
> 
> I'd like to clarify that the panic in our case is not triggered by the WARN itself.
> Instead, the real crash is a use‑after‑free (UAF) that happens when one CPU is
> executing a trampoline while another CPU is concurrently freeing it. This results
> in an illegal instruction (or page fault) at the PC, which is fatal and will panic
> the kernel regardless of panic_on_warn – because it's an Oops with Fatal exception
> in interrupt.


Why not fix the root cause instead?

If you want some help from upstream to fix the root cause, pls provide
the crash dmesg and the reproducing demo.

Thanks,
Leon


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH bpf-next] bpf:syscall: Log error code on trampoline unlink failure
  2026-07-16  6:56         ` Leon Hwang
@ 2026-07-16  7:03           ` xu.xin16
  2026-07-16  8:01             ` Leon Hwang
  0 siblings, 1 reply; 8+ messages in thread
From: xu.xin16 @ 2026-07-16  7:03 UTC (permalink / raw)
  To: leon.hwang
  Cc: ast, daniel, john.fastabend, andrii, eddyz87, memxor, martin.lau,
	song, yonghong.song, jolsa, emil, bpf, linux-kernel, xu.xin

> >>> Well, the crash may happen when the kernel is booting, or too hard to reproduce,
> >>> in which case, bpftrace does not work.
> >>
> >>
> >> Do you enable kernel.panic_on_warn sysctl?
> >>
> >> If it's not enabled, the kernel won't crash, I think.
> > 
> > I'd like to clarify that the panic in our case is not triggered by the WARN itself.
> > Instead, the real crash is a use‑after‑free (UAF) that happens when one CPU is
> > executing a trampoline while another CPU is concurrently freeing it. This results
> > in an illegal instruction (or page fault) at the PC, which is fatal and will panic
> > the kernel regardless of panic_on_warn – because it's an Oops with Fatal exception
> > in interrupt.
> 
> 
> Why not fix the root cause instead?
> 
> If you want some help from upstream to fix the root cause, pls provide
> the crash dmesg and the reproducing demo.

It's already fixed due to some OOT drivers.

I think if we have this patch, it can speed up trouble-shooting.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH bpf-next] bpf:syscall: Log error code on trampoline unlink failure
  2026-07-16  7:03           ` xu.xin16
@ 2026-07-16  8:01             ` Leon Hwang
  0 siblings, 0 replies; 8+ messages in thread
From: Leon Hwang @ 2026-07-16  8:01 UTC (permalink / raw)
  To: xu.xin16
  Cc: ast, daniel, john.fastabend, andrii, eddyz87, memxor, martin.lau,
	song, yonghong.song, jolsa, emil, bpf, linux-kernel, xu.xin

On 16/7/26 15:03, xu.xin16@zte.com.cn wrote:
>>>>> Well, the crash may happen when the kernel is booting, or too hard to reproduce,
>>>>> in which case, bpftrace does not work.
>>>>
>>>>
>>>> Do you enable kernel.panic_on_warn sysctl?
>>>>
>>>> If it's not enabled, the kernel won't crash, I think.
>>>
>>> I'd like to clarify that the panic in our case is not triggered by the WARN itself.
>>> Instead, the real crash is a use‑after‑free (UAF) that happens when one CPU is
>>> executing a trampoline while another CPU is concurrently freeing it. This results
>>> in an illegal instruction (or page fault) at the PC, which is fatal and will panic
>>> the kernel regardless of panic_on_warn – because it's an Oops with Fatal exception
>>> in interrupt.
>>
>>
>> Why not fix the root cause instead?
>>
>> If you want some help from upstream to fix the root cause, pls provide
>> the crash dmesg and the reproducing demo.
> 
> It's already fixed due to some OOT drivers.
> 
> I think if we have this patch, it can speed up trouble-shooting.

OK. Let's wait for Jiri's opinion.

Thanks,
Leon


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-07-16  8:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-16  3:34 [PATCH bpf-next] bpf:syscall: Log error code on trampoline unlink failure xu.xin16
2026-07-16  4:58 ` Leon Hwang
2026-07-16  5:55   ` xu.xin16
2026-07-16  6:09     ` Leon Hwang
2026-07-16  6:26       ` xu.xin16
2026-07-16  6:56         ` Leon Hwang
2026-07-16  7:03           ` xu.xin16
2026-07-16  8:01             ` Leon Hwang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox