Skip to contentSkip to conversation

mm/vmalloc: Use %p for pointer formatting

PATCH Applied Sebastian Andrzej Siewior 4 participants 5 messages Sep 18 – Sep 19

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/vmalloc: Use %p for pointer formatting

Commit 45ec16908e84e ("mm: use %pK for /proc/vmallocinfo") introduced the %pK in order not to leak kernel pointers.
Since commit ad67b74d2469d ("printk: hash addresses printed with %p") pointers are hashed by default and the behaviour can be controller by `hash_pointers' boot argument.
The policy on %p is to not introduce new ones.
Removing %pK makes it possible to remove its handling from the library.

Looking at the output, having the pointer in the output makes it possible to distinguish the individual entries.

Use %p instead %pK.

---
 mm/vmalloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
mm/vmalloc.c +3 -3
index bea9f76ed7e74..6461336f899bc 100644
@@ -5308,7 +5308,7 @@ static void show_purge_info(struct seq_file *m)
 	for_each_vmap_node(vn) {
 		spin_lock(&vn->lazy.lock);
 		list_for_each_entry(va, &vn->lazy.head, list) {
-			seq_printf(m, "0x%pK-0x%pK %7ld unpurged vm_area\n",
+			seq_printf(m, "0x%p-0x%p %7ld unpurged vm_area\n",
 				(void *)va->va_start, (void *)va->va_end,
 				va_size(va));
 		}
@@ -5331,7 +5331,7 @@ static int vmalloc_info_show(struct seq_file *m, void *p)
 		list_for_each_entry(va, &vn->busy.head, list) {
 			if (!va->vm) {
 				if (va->flags & VMAP_RAM)
-					seq_printf(m, "0x%pK-0x%pK %7ld vm_map_ram\n",
+					seq_printf(m, "0x%p-0x%p %7ld vm_map_ram\n",
 						(void *)va->va_start, (void *)va->va_end,
 						va_size(va));
 
@@ -5345,7 +5345,7 @@ static int vmalloc_info_show(struct seq_file *m, void *p)
 			/* Pair with smp_wmb() in clear_vm_uninitialized_flag() */
 			smp_rmb();
 
-			seq_printf(m, "0x%pK-0x%pK %7ld",
+			seq_printf(m, "0x%p-0x%p %7ld",
 				v->addr, v->addr + v->size, v->size);
 
 			if (v->caller)
Signature · 1 line
2.55.0
maintainer
#1 lore raw
Quoted 8 lines · On Fri, 18 Sep 2026 12:50:13 +0200 Sebastian Andrzej Siewior…

Commit 45ec16908e84e ("mm: use %pK for /proc/vmallocinfo") introduced the %pK in order not to leak kernel pointers.
Since commit ad67b74d2469d ("printk: hash addresses printed with %p") pointers are hashed by default and the behaviour can be controller by `hash_pointers' boot argument.
The policy on %p is to not introduce new ones.
Removing %pK makes it possible to remove its handling from the library.

Quoted 4 lines

Looking at the output, having the pointer in the output makes it possible to distinguish the individual entries.

Use %p instead %pK.

Fair enough.

I added this (important) info to the changelog. Please confirm its accurary.

: /proc/vmallocinfo has mode 0400, so this change doesn't make kernel : pointer information available to unprivileged userspace.

#2 lore raw
Quoted 15 lines · Andrew Morton
Quoted 8 lines · On Fri, 18 Sep 2026 12:50:13 +0200 Sebastian Andrzej Siewior…

Commit 45ec16908e84e ("mm: use %pK for /proc/vmallocinfo") introduced the %pK in order not to leak kernel pointers.
Since commit ad67b74d2469d ("printk: hash addresses printed with %p") pointers are hashed by default and the behaviour can be controller by `hash_pointers' boot argument.
The policy on %p is to not introduce new ones.
Removing %pK makes it possible to remove its handling from the library.

Quoted 4 lines

Looking at the output, having the pointer in the output makes it possible to distinguish the individual entries.

Use %p instead %pK.

Quoted 7 lines

Fair enough.

I added this (important) info to the changelog. Please confirm its accurary.

: /proc/vmallocinfo has mode 0400, so this change doesn't make kernel : pointer information available to unprivileged userspace.

Confirmed.
[%p is hashed by default so things shouldn't change here.]

Sebastian

Reviewed-by on v1 1/1
#3 lore raw
In reply to Sebastian Andrzej Siewior
Quoted 4 lines · On Fri, 18 Sep 2026 12:50:13 +0200 Sebastian Andrzej Siewior…

Commit 45ec16908e84e ("mm: use %pK for /proc/vmallocinfo") introduced the %pK in order not to leak kernel pointers.
Since commit ad67b74d2469d ("printk: hash addresses printed with %p") pointers are hashed by default and the behaviour can be controller

s/controller/controlled/ ?

Quoted 8 lines

by `hash_pointers' boot argument.
The policy on %p is to not introduce new ones.
Removing %pK makes it possible to remove its handling from the library.

Looking at the output, having the pointer in the output makes it possible to distinguish the individual entries.

Use %p instead %pK.

Makes sense to me.

Quoted 2 lines

Thanks,
SJ

[...]

maintainer Reviewed-by
#4 lore raw
Quoted 16 lines · SJ Park
Quoted 4 lines · On Fri, 18 Sep 2026 12:50:13 +0200 Sebastian Andrzej Siewior…

Commit 45ec16908e84e ("mm: use %pK for /proc/vmallocinfo") introduced the %pK in order not to leak kernel pointers.
Since commit ad67b74d2469d ("printk: hash addresses printed with %p") pointers are hashed by default and the behaviour can be controller

s/controller/controlled/ ?

Quoted 7 lines

by `hash_pointers' boot argument.
The policy on %p is to not introduce new ones.
Removing %pK makes it possible to remove its handling from the library.

Looking at the output, having the pointer in the output makes it possible to distinguish the individual entries.

Quoted 9 lines
Quoted 1 line

Use %p instead %pK.

Makes sense to me.

Quoted 2 lines

--
Uladzislau Rezki