From: Kumar Kartikeya Dwivedi Date: Sat, 5 Jul 2025 05:30:35 +0000 (-0700) Subject: bpf: Fix improper int-to-ptr cast in dump_stack_cb X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfa2bb9abd99beff078eaf9d9b59dbd4eb726040;p=thirdparty%2Flinux.git bpf: Fix improper int-to-ptr cast in dump_stack_cb On 32-bit platforms, we'll try to convert a u64 directly to a pointer type which is 32-bit, which causes the compiler to complain about cast from an integer of a different size to a pointer type. Cast to long before casting to the pointer type to match the pointer width. Reported-by: kernelci.org bot Reported-by: Randy Dunlap Fixes: d7c431cafcb4 ("bpf: Add dump_stack() analogue to print to BPF stderr") Signed-off-by: Kumar Kartikeya Dwivedi Acked-by: Randy Dunlap Tested-by: Randy Dunlap Link: https://lore.kernel.org/r/20250705053035.3020320-3-memxor@gmail.com Signed-off-by: Alexei Starovoitov --- diff --git a/kernel/bpf/stream.c b/kernel/bpf/stream.c index 8c842f845245a..ab592db4a4bf6 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 *)(long)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 *)(long)ip); return !ctxp->err; }