From: Menglong Dong <menglong.dong@linux.dev>
To: ast@kernel.org
Cc: Andreas Schwab <schwab@linux-m68k.org>,
Menglong Dong <menglong8.dong@gmail.com>,
rostedt@goodmis.org, daniel@iogearbox.net,
john.fastabend@gmail.com, andrii@kernel.org,
martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
yonghong.song@linux.dev, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, mhiramat@kernel.org,
mark.rutland@arm.com, mathieu.desnoyers@efficios.com,
jiang.biao@linux.dev, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org
Subject: Re: [PATCH bpf-next v3 3/6] bpf: fix the usage of BPF_TRAMP_F_SKIP_FRAME
Date: Fri, 19 Dec 2025 21:31:13 +0800 [thread overview]
Message-ID: <1948844.tdWV9SEqCh@7950hx> (raw)
In-Reply-To: <5070743.31r3eYUQgx@7950hx>
On 2025/12/19 20:27, Menglong Dong wrote:
> On 2025/12/19 19:41, Andreas Schwab wrote:
> > On Dez 19 2025, Menglong Dong wrote:
> >
> > > BPF_TRAMP_F_ORIG_STACK
> >
> > How can that ever be set?
>
> Oops, my bad! It should be BPF_TRAMP_F_CALL_ORIG here. I think
> it is some kind of copy-paste mistake. I'll send a fix for it.
I sent the following patch twice, but I didn't see it in the
mail list. I suspect there is something wrong with my gmail.
Hi, Alexei. Can you see my patch?
-->patch<--
From 5dbae5dcba3aa7fa10e506e9fd1a28a6802d9b00 Mon Sep 17 00:00:00 2001
From: Menglong Dong <dongml2@chinatelecom.cn>
Date: Fri, 19 Dec 2025 20:33:10 +0800
Subject: [PATCH RESEND bpf] riscv, bpf: fix incorrect usage of BPF_TRAMP_F_ORIG_STACK
The usage of BPF_TRAMP_F_ORIG_STACK in __arch_prepare_bpf_trampoline() is
wrong, and it should be BPF_TRAMP_F_CALL_ORIG, which caused crash as
Andreas reported:
Insufficient stack space to handle exception!
Task stack: [0xff20000000010000..0xff20000000014000]
Overflow stack: [0xff600000ffdad070..0xff600000ffdae070]
CPU: 1 UID: 0 PID: 1 Comm: systemd Not tainted 6.18.0-rc5+ #15 PREEMPT(voluntary)
Hardware name: riscv-virtio qemu/qemu, BIOS 2025.10 10/01/2025
epc : copy_from_kernel_nofault+0xa/0x198
ra : bpf_probe_read_kernel+0x20/0x60
epc : ffffffff802b732a ra : ffffffff801e6070 sp : ff2000000000ffe0
gp : ffffffff82262ed0 tp : 0000000000000000 t0 : ffffffff80022320
t1 : ffffffff801e6056 t2 : 0000000000000000 s0 : ff20000000010040
s1 : 0000000000000008 a0 : ff20000000010050 a1 : ff60000083b3d320
a2 : 0000000000000008 a3 : 0000000000000097 a4 : 0000000000000000
a5 : 0000000000000000 a6 : 0000000000000021 a7 : 0000000000000003
s2 : ff20000000010050 s3 : ff6000008459fc18 s4 : ff60000083b3d340
s5 : ff20000000010060 s6 : 0000000000000000 s7 : ff20000000013aa8
s8 : 0000000000000000 s9 : 0000000000008000 s10: 000000000058dcb0
s11: 000000000058dca7 t3 : 000000006925116d t4 : ff6000008090f026
t5 : 00007fff9b0cbaa8 t6 : 0000000000000016
status: 0000000200000120 badaddr: 0000000000000000 cause: 8000000000000005
Kernel panic - not syncing: Kernel stack overflow
CPU: 1 UID: 0 PID: 1 Comm: systemd Not tainted 6.18.0-rc5+ #15 PREEMPT(voluntary)
Hardware name: riscv-virtio qemu/qemu, BIOS 2025.10 10/01/2025
Call Trace:
[<ffffffff8001a1f8>] dump_backtrace+0x28/0x38
[<ffffffff80002502>] show_stack+0x3a/0x50
[<ffffffff800122be>] dump_stack_lvl+0x56/0x80
[<ffffffff80012300>] dump_stack+0x18/0x22
[<ffffffff80002abe>] vpanic+0xf6/0x328
[<ffffffff80002d2e>] panic+0x3e/0x40
[<ffffffff80019ef0>] handle_bad_stack+0x98/0xa0
[<ffffffff801e6070>] bpf_probe_read_kernel+0x20/0x60
Just fix it.
Fixes: 47c9214dcbea ("bpf: fix the usage of BPF_TRAMP_F_SKIP_FRAME")
Reported-by: Andreas Schwab <schwab@linux-m68k.org>
Closes: https://lore.kernel.org/bpf/874ipnkfvt.fsf@igel.home/
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
---
arch/riscv/net/bpf_jit_comp64.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
index 5f9457e910e8..09b70bf362d3 100644
--- a/arch/riscv/net/bpf_jit_comp64.c
+++ b/arch/riscv/net/bpf_jit_comp64.c
@@ -1134,7 +1134,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
store_args(nr_arg_slots, args_off, ctx);
/* skip to actual body of traced function */
- if (flags & BPF_TRAMP_F_ORIG_STACK)
+ if (flags & BPF_TRAMP_F_CALL_ORIG)
orig_call += RV_FENTRY_NINSNS * 4;
if (flags & BPF_TRAMP_F_CALL_ORIG) {
--
2.52.0
--<patch>--
>
> Thanks!
> Menglong Dong
>
> >
> > if (flags & (BPF_TRAMP_F_ORIG_STACK | BPF_TRAMP_F_SHARE_IPMODIFY))
> > return -ENOTSUPP;
> >
> >
>
>
>
>
>
>
WARNING: multiple messages have this Message-ID (diff)
From: Menglong Dong <menglong.dong@linux.dev>
To: ast@kernel.org
Cc: Andreas Schwab <schwab@linux-m68k.org>,
Menglong Dong <menglong8.dong@gmail.com>,
rostedt@goodmis.org, daniel@iogearbox.net,
john.fastabend@gmail.com, andrii@kernel.org,
martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
yonghong.song@linux.dev, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, mhiramat@kernel.org,
mark.rutland@arm.com, mathieu.desnoyers@efficios.com,
jiang.biao@linux.dev, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org
Subject: Re: [PATCH bpf-next v3 3/6] bpf: fix the usage of BPF_TRAMP_F_SKIP_FRAME
Date: Fri, 19 Dec 2025 21:31:13 +0800 [thread overview]
Message-ID: <1948844.tdWV9SEqCh@7950hx> (raw)
In-Reply-To: <5070743.31r3eYUQgx@7950hx>
On 2025/12/19 20:27, Menglong Dong wrote:
> On 2025/12/19 19:41, Andreas Schwab wrote:
> > On Dez 19 2025, Menglong Dong wrote:
> >
> > > BPF_TRAMP_F_ORIG_STACK
> >
> > How can that ever be set?
>
> Oops, my bad! It should be BPF_TRAMP_F_CALL_ORIG here. I think
> it is some kind of copy-paste mistake. I'll send a fix for it.
I sent the following patch twice, but I didn't see it in the
mail list. I suspect there is something wrong with my gmail.
Hi, Alexei. Can you see my patch?
-->patch<--
From 5dbae5dcba3aa7fa10e506e9fd1a28a6802d9b00 Mon Sep 17 00:00:00 2001
From: Menglong Dong <dongml2@chinatelecom.cn>
Date: Fri, 19 Dec 2025 20:33:10 +0800
Subject: [PATCH RESEND bpf] riscv, bpf: fix incorrect usage of BPF_TRAMP_F_ORIG_STACK
The usage of BPF_TRAMP_F_ORIG_STACK in __arch_prepare_bpf_trampoline() is
wrong, and it should be BPF_TRAMP_F_CALL_ORIG, which caused crash as
Andreas reported:
Insufficient stack space to handle exception!
Task stack: [0xff20000000010000..0xff20000000014000]
Overflow stack: [0xff600000ffdad070..0xff600000ffdae070]
CPU: 1 UID: 0 PID: 1 Comm: systemd Not tainted 6.18.0-rc5+ #15 PREEMPT(voluntary)
Hardware name: riscv-virtio qemu/qemu, BIOS 2025.10 10/01/2025
epc : copy_from_kernel_nofault+0xa/0x198
ra : bpf_probe_read_kernel+0x20/0x60
epc : ffffffff802b732a ra : ffffffff801e6070 sp : ff2000000000ffe0
gp : ffffffff82262ed0 tp : 0000000000000000 t0 : ffffffff80022320
t1 : ffffffff801e6056 t2 : 0000000000000000 s0 : ff20000000010040
s1 : 0000000000000008 a0 : ff20000000010050 a1 : ff60000083b3d320
a2 : 0000000000000008 a3 : 0000000000000097 a4 : 0000000000000000
a5 : 0000000000000000 a6 : 0000000000000021 a7 : 0000000000000003
s2 : ff20000000010050 s3 : ff6000008459fc18 s4 : ff60000083b3d340
s5 : ff20000000010060 s6 : 0000000000000000 s7 : ff20000000013aa8
s8 : 0000000000000000 s9 : 0000000000008000 s10: 000000000058dcb0
s11: 000000000058dca7 t3 : 000000006925116d t4 : ff6000008090f026
t5 : 00007fff9b0cbaa8 t6 : 0000000000000016
status: 0000000200000120 badaddr: 0000000000000000 cause: 8000000000000005
Kernel panic - not syncing: Kernel stack overflow
CPU: 1 UID: 0 PID: 1 Comm: systemd Not tainted 6.18.0-rc5+ #15 PREEMPT(voluntary)
Hardware name: riscv-virtio qemu/qemu, BIOS 2025.10 10/01/2025
Call Trace:
[<ffffffff8001a1f8>] dump_backtrace+0x28/0x38
[<ffffffff80002502>] show_stack+0x3a/0x50
[<ffffffff800122be>] dump_stack_lvl+0x56/0x80
[<ffffffff80012300>] dump_stack+0x18/0x22
[<ffffffff80002abe>] vpanic+0xf6/0x328
[<ffffffff80002d2e>] panic+0x3e/0x40
[<ffffffff80019ef0>] handle_bad_stack+0x98/0xa0
[<ffffffff801e6070>] bpf_probe_read_kernel+0x20/0x60
Just fix it.
Fixes: 47c9214dcbea ("bpf: fix the usage of BPF_TRAMP_F_SKIP_FRAME")
Reported-by: Andreas Schwab <schwab@linux-m68k.org>
Closes: https://lore.kernel.org/bpf/874ipnkfvt.fsf@igel.home/
Signed-off-by: Menglong Dong <dongml2@chinatelecom.cn>
---
arch/riscv/net/bpf_jit_comp64.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
index 5f9457e910e8..09b70bf362d3 100644
--- a/arch/riscv/net/bpf_jit_comp64.c
+++ b/arch/riscv/net/bpf_jit_comp64.c
@@ -1134,7 +1134,7 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,
store_args(nr_arg_slots, args_off, ctx);
/* skip to actual body of traced function */
- if (flags & BPF_TRAMP_F_ORIG_STACK)
+ if (flags & BPF_TRAMP_F_CALL_ORIG)
orig_call += RV_FENTRY_NINSNS * 4;
if (flags & BPF_TRAMP_F_CALL_ORIG) {
--
2.52.0
--<patch>--
>
> Thanks!
> Menglong Dong
>
> >
> > if (flags & (BPF_TRAMP_F_ORIG_STACK | BPF_TRAMP_F_SHARE_IPMODIFY))
> > return -ENOTSUPP;
> >
> >
>
>
>
>
>
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-12-19 13:31 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-18 12:36 [PATCH bpf-next v3 0/6] bpf trampoline support "jmp" mode Menglong Dong
2025-11-18 12:36 ` [PATCH bpf-next v3 1/6] ftrace: introduce FTRACE_OPS_FL_JMP Menglong Dong
2025-11-18 13:25 ` bot+bpf-ci
2025-11-18 13:51 ` Steven Rostedt
2025-11-18 12:36 ` [PATCH bpf-next v3 2/6] x86/ftrace: implement DYNAMIC_FTRACE_WITH_JMP Menglong Dong
2025-11-18 22:01 ` Jiri Olsa
2025-11-19 1:05 ` Menglong Dong
2025-11-18 12:36 ` [PATCH bpf-next v3 3/6] bpf: fix the usage of BPF_TRAMP_F_SKIP_FRAME Menglong Dong
2025-12-18 14:45 ` Andreas Schwab
2025-12-18 14:45 ` Andreas Schwab
2025-12-18 15:05 ` Menglong Dong
2025-12-18 15:05 ` Menglong Dong
2025-12-19 2:22 ` Menglong Dong
2025-12-19 2:22 ` Menglong Dong
2025-12-19 11:41 ` Andreas Schwab
2025-12-19 11:41 ` Andreas Schwab
2025-12-19 12:27 ` Menglong Dong
2025-12-19 12:27 ` Menglong Dong
2025-12-19 13:31 ` Menglong Dong [this message]
2025-12-19 13:31 ` Menglong Dong
2025-12-19 13:48 ` Andreas Schwab
2025-12-19 13:48 ` Andreas Schwab
2025-12-19 14:04 ` Menglong Dong
2025-12-19 14:04 ` Menglong Dong
2025-12-19 14:50 ` Andreas Schwab
2025-12-19 14:50 ` Andreas Schwab
2025-12-19 14:54 ` Menglong Dong
2025-12-19 14:54 ` Menglong Dong
2025-11-18 12:36 ` [PATCH bpf-next v3 4/6] bpf,x86: adjust the "jmp" mode for bpf trampoline Menglong Dong
2025-11-18 12:36 ` [PATCH bpf-next v3 5/6] bpf: specify the old and new poke_type for bpf_arch_text_poke Menglong Dong
2025-11-18 12:36 ` [PATCH bpf-next v3 6/6] bpf: implement "jmp" mode for trampoline Menglong Dong
2025-11-19 0:59 ` Alexei Starovoitov
2025-11-19 1:03 ` Steven Rostedt
2025-11-22 2:37 ` Alexei Starovoitov
2025-11-24 14:50 ` Steven Rostedt
2025-11-19 0:28 ` [PATCH bpf-next v3 0/6] bpf trampoline support "jmp" mode Alexei Starovoitov
2025-11-19 2:47 ` Menglong Dong
2025-11-19 2:55 ` Leon Hwang
2025-11-19 12:36 ` Xu Kuohai
2025-11-20 2:07 ` Leon Hwang
2025-11-20 3:24 ` Xu Kuohai
2025-11-24 18:00 ` patchwork-bot+netdevbpf
2026-04-02 6:12 ` Leon Hwang
2026-04-02 7:51 ` Menglong Dong
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=1948844.tdWV9SEqCh@7950hx \
--to=menglong.dong@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=jiang.biao@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=martin.lau@linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=menglong8.dong@gmail.com \
--cc=mhiramat@kernel.org \
--cc=rostedt@goodmis.org \
--cc=schwab@linux-m68k.org \
--cc=sdf@fomichev.me \
--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 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.