net: Don't use %pK through printk
Subsystems (5)
v3 cover net: 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.
---
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 printk or 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: 52da431bf03b5506203bca27fe14a97895c80faf
change-id: 20250404-restricted-pointers-net-a8cddd03e5d1
Best regards,
Signature · 1 line
Thomas Weißschuh <[email protected]>
PATCH v3 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
@@ -9168,7 +9168,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.49.0
Re: [PATCH net-next v3 1/2] ice: Don't use %pK through printk or tracepoints
Quoted 8 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.
Quoted 8 lines
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.Signed-off-by Thomas Weißschuh <[email protected]>Acked-by Przemek Kitszel <[email protected]>Reviewed-by Aleksandr Loktionov <[email protected]>
PATCH v3 2/2 net/mlx5: Don't use %pK through printk or 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.49.0
Re: [PATCH net-next v3 2/2] net/mlx5: Don't use %pK through printk or tracepoints
Quoted 8 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 through tracepoints. They can still unintentionally leak raw pointers or acquire sleeping locks in atomic contexts.
Quoted 8 lines
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.Signed-off-by Thomas Weißschuh <[email protected]>Reviewed-by Aleksandr Loktionov <[email protected]>Reviewed-by Tariq Toukan <[email protected]>