cgroup: Use %p for pointer formatting

Since ad67b74d24 ("printk: hash addresses printed with %p") %p is hashed
by default, which is also what %pK prints under the default kptr_restrict=0.
Converting the remaining %pK users makes it possible to remove its handling
from vsprintf.

Documentation/process/deprecated.rst asks that no new %p uses be added, but
these pointers are what makes the css_set debug output useful, and debug.c
already prints css pointers with %p. Keep the pointer output and use %p.

Under kptr_restrict=1 and 2 the files now show the same hashed values as any
other %p output: unprivileged readers see hashes instead of zeros, and a
CAP_SYSLOG reader under kptr_restrict=1 no longer gets raw addresses.
Booting with hash_pointers=never is the remaining way to see them.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
Sebastian Andrzej Siewior 2026-09-18 12:48:52 +02:00 committed by Tejun Heo
parent e8f69fe59a
commit a408c6d27f

View File

@ -51,7 +51,7 @@ static int current_css_set_read(struct seq_file *seq, void *v)
spin_lock_irq(&css_set_lock);
cset = task_css_set(current);
refcnt = refcount_read(&cset->refcount);
seq_printf(seq, "css_set %pK %d", cset, refcnt);
seq_printf(seq, "css_set %p %d", cset, refcnt);
if (refcnt > cset->nr_tasks)
seq_printf(seq, " +%d", refcnt - cset->nr_tasks);
seq_puts(seq, "\n");
@ -125,10 +125,10 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
* Print out the proc_cset and threaded_cset relationship
* and highlight difference between refcount and task_count.
*/
seq_printf(seq, "css_set %pK", cset);
seq_printf(seq, "css_set %p", cset);
if (rcu_dereference_protected(cset->dom_cset, 1) != cset) {
threaded_csets++;
seq_printf(seq, "=>%pK", cset->dom_cset);
seq_printf(seq, "=>%p", cset->dom_cset);
}
if (!list_empty(&cset->threaded_csets)) {
struct css_set *tcset;
@ -137,7 +137,7 @@ static int cgroup_css_links_read(struct seq_file *seq, void *v)
list_for_each_entry(tcset, &cset->threaded_csets,
threaded_csets_node) {
seq_puts(seq, idx ? "," : "<=");
seq_printf(seq, "%pK", tcset);
seq_printf(seq, "%p", tcset);
idx++;
}
} else {