Skip to content

Commit bfa2bb9

Browse files
kkdwivediAlexei Starovoitov
authored andcommitted
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 <[email protected]> Reported-by: Randy Dunlap <[email protected]> Fixes: d7c431c ("bpf: Add dump_stack() analogue to print to BPF stderr") Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]> Acked-by: Randy Dunlap <[email protected]> Tested-by: Randy Dunlap <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 116c8f4 commit bfa2bb9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/bpf/stream.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,11 @@ static bool dump_stack_cb(void *cookie, u64 ip, u64 sp, u64 bp)
498498
if (ret < 0)
499499
goto end;
500500
ctxp->err = bpf_stream_stage_printk(ctxp->ss, "%pS\n %s @ %s:%d\n",
501-
(void *)ip, line, file, num);
501+
(void *)(long)ip, line, file, num);
502502
return !ctxp->err;
503503
}
504504
end:
505-
ctxp->err = bpf_stream_stage_printk(ctxp->ss, "%pS\n", (void *)ip);
505+
ctxp->err = bpf_stream_stage_printk(ctxp->ss, "%pS\n", (void *)(long)ip);
506506
return !ctxp->err;
507507
}
508508

0 commit comments

Comments
 (0)