]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bpf: Don't use %pK through printk
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Mon, 11 Aug 2025 12:08:04 +0000 (14:08 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:02 +0000 (15:34 -0500)
[ Upstream commit 2caa6b88e0ba0231fb4ff0ba8e73cedd5fb81fc8 ]

In the past %pK was preferable to %p as it would not leak raw pointer
values into the kernel log.
Since commit ad67b74d2469 ("printk: hash addresses printed with %p")
the regular %p has been improved to avoid this issue.
Furthermore, restricted pointers ("%pK") were never meant to be used
through printk(). They can still unintentionally leak raw pointers or
acquire sleeping locks in atomic contexts.

Switch to the regular pointer formatting which is safer and
easier to reason about.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250811-restricted-pointers-bpf-v1-1-a1d7cc3cb9e7@linutronix.de
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/filter.h

index 0477254bc2d30f3b48a6097258889584f49d1475..aef18f0e9450e4800c193a4e87041cc59420ceeb 100644 (file)
@@ -1263,7 +1263,7 @@ void bpf_jit_prog_release_other(struct bpf_prog *fp, struct bpf_prog *fp_other);
 static inline void bpf_jit_dump(unsigned int flen, unsigned int proglen,
                                u32 pass, void *image)
 {
-       pr_err("flen=%u proglen=%u pass=%u image=%pK from=%s pid=%d\n", flen,
+       pr_err("flen=%u proglen=%u pass=%u image=%p from=%s pid=%d\n", flen,
               proglen, pass, image, current->comm, task_pid_nr(current));
 
        if (image)