All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bpf: fix dump_stack() type cast
@ 2025-07-08 16:07 Arnd Bergmann
  2025-07-08 19:07 ` Eduard Zingerman
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2025-07-08 16:07 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Kumar Kartikeya Dwivedi, Emil Tsalapatis
  Cc: Arnd Bergmann, Martin KaFai Lau, Eduard Zingerman, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, bpf, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

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@arndb.de>
---
 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


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

end of thread, other threads:[~2025-07-08 19:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-08 16:07 [PATCH] bpf: fix dump_stack() type cast Arnd Bergmann
2025-07-08 19:07 ` Eduard Zingerman

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.