Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

binder: don't use %pK through printk

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.

There are still a few users of %pK left, but these use it through
seq_file, for which its usage is safe.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Carlos Llamas <cmllamas@google.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260107-restricted-pointers-binder-v1-1-181018bf3812@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Thomas Weißschuh and committed by
Greg Kroah-Hartman
56d21267 68aabb29

+4 -4
+1 -1
drivers/android/binder.c
··· 4510 4510 } 4511 4511 } 4512 4512 binder_debug(BINDER_DEBUG_DEAD_BINDER, 4513 - "%d:%d BC_DEAD_BINDER_DONE %016llx found %pK\n", 4513 + "%d:%d BC_DEAD_BINDER_DONE %016llx found %p\n", 4514 4514 proc->pid, thread->pid, (u64)cookie, 4515 4515 death); 4516 4516 if (death == NULL) {
+3 -3
drivers/android/binder_alloc.c
··· 81 81 new_buffer_size = binder_alloc_buffer_size(alloc, new_buffer); 82 82 83 83 binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC, 84 - "%d: add free buffer, size %zd, at %pK\n", 84 + "%d: add free buffer, size %zd, at %p\n", 85 85 alloc->pid, new_buffer_size, new_buffer); 86 86 87 87 while (*p) { ··· 572 572 } 573 573 574 574 binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC, 575 - "%d: binder_alloc_buf size %zd got buffer %pK size %zd\n", 575 + "%d: binder_alloc_buf size %zd got buffer %p size %zd\n", 576 576 alloc->pid, size, buffer, buffer_size); 577 577 578 578 /* ··· 748 748 ALIGN(buffer->extra_buffers_size, sizeof(void *)); 749 749 750 750 binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC, 751 - "%d: binder_free_buf %pK size %zd buffer_size %zd\n", 751 + "%d: binder_free_buf %p size %zd buffer_size %zd\n", 752 752 alloc->pid, buffer, size, buffer_size); 753 753 754 754 BUG_ON(buffer->free);