Skip to content

Commit 4bb69d5

Browse files
t-8chmaddy-kerneldev
authored andcommitted
powerpc: 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 ad67b74 ("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. Link: https://lore.kernel.org/lkml/20250113171731-dc10e3c1-da64-4af0-b767-7c7070468023@linutronix.de/ Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Christophe Leroy <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Link: https://patch.msgid.link/20250718-restricted-pointers-powerpc-v2-1-fd7bddd809f3@linutronix.de
1 parent 75cd37c commit 4bb69d5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

arch/powerpc/kernel/eeh_driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ void eeh_handle_normal_event(struct eeh_pe *pe)
907907
/* FIXME: Use the same format as dump_stack() */
908908
pr_err("EEH: Call Trace:\n");
909909
for (i = 0; i < pe->trace_entries; i++)
910-
pr_err("EEH: [%pK] %pS\n", ptrs[i], ptrs[i]);
910+
pr_err("EEH: [%p] %pS\n", ptrs[i], ptrs[i]);
911911

912912
pe->trace_entries = 0;
913913
}

arch/powerpc/perf/hv-24x7.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,27 +713,27 @@ static ssize_t catalog_event_len_validate(struct hv_24x7_event_data *event,
713713
ev_len = be16_to_cpu(event->length);
714714

715715
if (ev_len % 16)
716-
pr_info("event %zu has length %zu not divisible by 16: event=%pK\n",
716+
pr_info("event %zu has length %zu not divisible by 16: event=%p\n",
717717
event_idx, ev_len, event);
718718

719719
ev_end = (__u8 *)event + ev_len;
720720
if (ev_end > end) {
721-
pr_warn("event %zu has .length=%zu, ends after buffer end: ev_end=%pK > end=%pK, offset=%zu\n",
721+
pr_warn("event %zu has .length=%zu, ends after buffer end: ev_end=%p > end=%p, offset=%zu\n",
722722
event_idx, ev_len, ev_end, end,
723723
offset);
724724
return -1;
725725
}
726726

727727
calc_ev_end = event_end(event, end);
728728
if (!calc_ev_end) {
729-
pr_warn("event %zu has a calculated length which exceeds buffer length %zu: event=%pK end=%pK, offset=%zu\n",
729+
pr_warn("event %zu has a calculated length which exceeds buffer length %zu: event=%p end=%p, offset=%zu\n",
730730
event_idx, event_data_bytes, event, end,
731731
offset);
732732
return -1;
733733
}
734734

735735
if (calc_ev_end > ev_end) {
736-
pr_warn("event %zu exceeds its own length: event=%pK, end=%pK, offset=%zu, calc_ev_end=%pK\n",
736+
pr_warn("event %zu exceeds its own length: event=%p, end=%p, offset=%zu, calc_ev_end=%p\n",
737737
event_idx, event, ev_end, offset, calc_ev_end);
738738
return -1;
739739
}

0 commit comments

Comments
 (0)