net: Don't use %pK through printk or tracepoints
Subsystems (5)
v5 cover net: Don't use %pK through printk or tracepoints
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.
---
Changes in v5:
- Rebase on v6.17-rc1
- Bick up Reviewed-by from Paul
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Pick up Reviewed-by from Simon
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Fix typo in commit messages
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Drop wifi/ath patches, they are submitted on their own now
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Thomas Weißschuh (2):
ice: Don't use %pK through printk or tracepoints net/mlx5: Don't use %pK through tracepoints
drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_trace.h | 10 +++++----- .../ethernet/mellanox/mlx5/core/sf/dev/diag/dev_tracepoint.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250404-restricted-pointers-net-a8cddd03e5d1
Best regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
PATCH v5 1/2 ice: Don't use %pK through printk or tracepoints
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.
--- drivers/net/ethernet/intel/ice/ice_main.c | 2 +- drivers/net/ethernet/intel/ice/ice_trace.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +1 -1
@@ -9117,7 +9117,7 @@ static int ice_create_q_channels(struct ice_vsi *vsi)list_add_tail (&ch->list, &vsi->ch_list); vsi->tc_map_vsi[i] = ch->ch_vsi;dev_dbg (ice_pf_to_dev (pf), -"successfully created channel: VSI %pK\n" , ch->ch_vsi); +"successfully created channel: VSI %p\n" , ch->ch_vsi); }return 0 ;
drivers/net/ethernet/intel/ice/ice_trace.h +5 -5
@@ -130,7 +130,7 @@ DECLARE_EVENT_CLASS(ice_tx_template, __entry->buf = buf; __assign_str(devname);), -TP_printk ("netdev: %s ring: %pK desc: %pK buf %pK" ,__get_str (devname), +TP_printk ("netdev: %s ring: %p desc: %p buf %p" ,__get_str (devname), __entry->ring, __entry->desc, __entry->buf) );
@@ -158,7 +158,7 @@ DECLARE_EVENT_CLASS(ice_rx_template, __entry->desc = desc; __assign_str(devname);), -TP_printk ("netdev: %s ring: %pK desc: %pK" ,__get_str (devname), +TP_printk ("netdev: %s ring: %p desc: %p" ,__get_str (devname), __entry->ring, __entry->desc) ); DEFINE_EVENT(ice_rx_template, ice_clean_rx_irq,
@@ -182,7 +182,7 @@ DECLARE_EVENT_CLASS(ice_rx_indicate_template, __entry->skb = skb; __assign_str(devname);), -TP_printk ("netdev: %s ring: %pK desc: %pK skb %pK" ,__get_str (devname), +TP_printk ("netdev: %s ring: %p desc: %p skb %p" ,__get_str (devname), __entry->ring, __entry->desc, __entry->skb) );
@@ -205,7 +205,7 @@ DECLARE_EVENT_CLASS(ice_xmit_template, __entry->skb = skb; __assign_str(devname);), -TP_printk ("netdev: %s skb: %pK ring: %pK" ,__get_str (devname), +TP_printk ("netdev: %s skb: %p ring: %p" ,__get_str (devname), __entry->skb, __entry->ring) );
@@ -228,7 +228,7 @@ DECLARE_EVENT_CLASS(ice_tx_tstamp_template, TP_fast_assign(__entry->skb = skb; __entry->idx = idx;), -TP_printk ("skb %pK idx %d" , +TP_printk ("skb %p idx %d" , __entry->skb, __entry->idx) );#define DEFINE_TX_TSTAMP_OP_EVENT (name) \
Signature · 1 line
2.50.1
PATCH v5 2/2 net/mlx5: Don't use %pK through tracepoints
In reply to Thomas WeißschuhIn 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 tracepoints. 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.
--- drivers/net/ethernet/mellanox/mlx5/core/sf/dev/diag/dev_tracepoint.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/sf/dev/diag/dev_tracepoint.h +1 -1
@@ -28,7 +28,7 @@ DECLARE_EVENT_CLASS(mlx5_sf_dev_template, __entry->hw_fn_id = sfdev->fn_id; __entry->sfnum = sfdev->sfnum; ), -TP_printk ("(%s) sfdev=%pK aux_id=%d hw_id=0x%x sfnum=%u\n" , +TP_printk ("(%s) sfdev=%p aux_id=%d hw_id=0x%x sfnum=%u\n" ,__get_str (devname), __entry->sfdev, __entry->aux_id, __entry->hw_fn_id, __entry->sfnum)
Signature · 1 line
2.50.1
Quoted 13 lines · Thomas Weißschuh
In the past %pK was preferable to %p as it would not leak raw pointer values into the kernel log.
Since commitad67b74d2469("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 throughprintk(). 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 throughseq_file, for which its usage is safe.
Quoted 7 lines
Signed-off-by Thomas Weißschuh <[email protected]>---
Changes in v5:
- Rebase on v6.17-rc1
- Bick up Reviewed-by from Paul
- Link to v4: https://lore.kernel.org/r/[email protected]
Thanks for fixing these up!
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 11 Aug 2025 11:43:17 +0200 you wrote:
In the past %pK was preferable to %p as it would not leak raw pointer values into the kernel log.
Since commitad67b74d2469("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 throughprintk(). They can still unintentionally leak raw pointers or acquire sleeping locks in atomic contexts.[...]
Here is the summary with links:
- [net-next,v5,1/2] ice: Don't use %pK through printk or tracepoints
https://git.kernel.org/netdev/net-next/c/66ceb45b7d7e - [net-next,v5,2/2] net/mlx5: Don't use %pK through tracepoints https://git.kernel.org/netdev/net-next/c/e2068f74b976
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html