[PATCH] bpf: fix dump_stack() type cast

From: Arnd Bergmann
Date: Tue Jul 08 2025 - 12:08:01 EST


From: Arnd Bergmann <arnd@xxxxxxxx>

Passing a pointer as a 'u64' variable requires a double cast when
converting it back to a pointer:

kernel/bpf/stream.c: In function 'dump_stack_cb':
kernel/bpf/stream.c:505:64: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
505 | ctxp->err = bpf_stream_stage_printk(ctxp->ss, "%pS\n", (void *)ip);
| ^

Fixes: d7c431cafcb4 ("bpf: Add dump_stack() analogue to print to BPF stderr")
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---
kernel/bpf/stream.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/bpf/stream.c b/kernel/bpf/stream.c
index 8c842f845245..24433cdf6ede 100644
--- a/kernel/bpf/stream.c
+++ b/kernel/bpf/stream.c
@@ -498,11 +498,11 @@ static bool dump_stack_cb(void *cookie, u64 ip, u64 sp, u64 bp)
if (ret < 0)
goto end;
ctxp->err = bpf_stream_stage_printk(ctxp->ss, "%pS\n %s @ %s:%d\n",
- (void *)ip, line, file, num);
+ (void *)(uintptr_t)ip, line, file, num);
return !ctxp->err;
}
end:
- ctxp->err = bpf_stream_stage_printk(ctxp->ss, "%pS\n", (void *)ip);
+ ctxp->err = bpf_stream_stage_printk(ctxp->ss, "%pS\n", (void *)(uintptr_t)ip);
return !ctxp->err;
}

--
2.39.5