mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] net: Don't use %pK through printk
@ 2025-04-17 13:24 Thomas Weißschuh
  2025-04-17 13:24 ` [PATCH net-next v2 1/2] ice: Don't use %pK through printk or tracepoints Thomas Weißschuh
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2025-04-17 13:24 UTC (permalink / raw)
  To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Saeed Mahameed,
	Leon Romanovsky, Tariq Toukan
  Cc: intel-wired-lan, netdev, linux-kernel, linux-rdma,
	Thomas Weißschuh, Aleksandr Loktionov

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 looks 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.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Changes in v2:
- Drop wifi/ath patches, they are submitted on their own now
- Link to v1: https://lore.kernel.org/r/20250414-restricted-pointers-net-v1-0-12af0ce46cdd@linutronix.de

---
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: cfb2e2c57aef75a414c0f18445c7441df5bc13be
change-id: 20250404-restricted-pointers-net-a8cddd03e5d1

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh@linutronix.de>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 1/2] ice: Don't use %pK through printk or tracepoints
  2025-04-17 13:24 [PATCH net-next v2 0/2] net: Don't use %pK through printk Thomas Weißschuh
@ 2025-04-17 13:24 ` Thomas Weißschuh
  2025-04-17 13:24 ` [PATCH net-next v2 2/2] net/mlx5: Don't use %pK through tracepoints Thomas Weißschuh
  2025-04-17 13:39 ` [Intel-wired-lan] [PATCH net-next v2 0/2] net: Don't use %pK through printk Dawid Osuchowski
  2 siblings, 0 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2025-04-17 13:24 UTC (permalink / raw)
  To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Saeed Mahameed,
	Leon Romanovsky, Tariq Toukan
  Cc: intel-wired-lan, netdev, linux-kernel, linux-rdma,
	Thomas Weißschuh, Aleksandr Loktionov

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 looks 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.

Acked-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
---
 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(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index d390157b59fe1873ddab78323cdc0bbaea6ad0c5..d27e8816a48fef5014148cae27e52c1801eaaada 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -9118,7 +9118,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;
 
diff --git a/drivers/net/ethernet/intel/ice/ice_trace.h b/drivers/net/ethernet/intel/ice/ice_trace.h
index 07aab6e130cd553fa1fcaa2feac9d14f0433239a..4f35ef8d6b299b4acd6c85992c2c93b164a88372 100644
--- a/drivers/net/ethernet/intel/ice/ice_trace.h
+++ b/drivers/net/ethernet/intel/ice/ice_trace.h
@@ -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) \

-- 
2.49.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next v2 2/2] net/mlx5: Don't use %pK through tracepoints
  2025-04-17 13:24 [PATCH net-next v2 0/2] net: Don't use %pK through printk Thomas Weißschuh
  2025-04-17 13:24 ` [PATCH net-next v2 1/2] ice: Don't use %pK through printk or tracepoints Thomas Weißschuh
@ 2025-04-17 13:24 ` Thomas Weißschuh
  2025-04-17 13:39 ` [Intel-wired-lan] [PATCH net-next v2 0/2] net: Don't use %pK through printk Dawid Osuchowski
  2 siblings, 0 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2025-04-17 13:24 UTC (permalink / raw)
  To: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Saeed Mahameed,
	Leon Romanovsky, Tariq Toukan
  Cc: intel-wired-lan, netdev, linux-kernel, linux-rdma,
	Thomas Weißschuh, Aleksandr Loktionov

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 tracepoints. They can still unintentionally leak raw pointers or
acquire sleeping looks 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.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/sf/dev/diag/dev_tracepoint.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/diag/dev_tracepoint.h b/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/diag/dev_tracepoint.h
index 0537de86f9817dc80bd897688c539135b1ad37ac..9b0f44253f332aa602a84a1f6d7532a500dd4f55 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/diag/dev_tracepoint.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/diag/dev_tracepoint.h
@@ -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)

-- 
2.49.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Intel-wired-lan] [PATCH net-next v2 0/2] net: Don't use %pK through printk
  2025-04-17 13:24 [PATCH net-next v2 0/2] net: Don't use %pK through printk Thomas Weißschuh
  2025-04-17 13:24 ` [PATCH net-next v2 1/2] ice: Don't use %pK through printk or tracepoints Thomas Weißschuh
  2025-04-17 13:24 ` [PATCH net-next v2 2/2] net/mlx5: Don't use %pK through tracepoints Thomas Weißschuh
@ 2025-04-17 13:39 ` Dawid Osuchowski
  2025-04-23 10:24   ` Thomas Weißschuh
  2 siblings, 1 reply; 5+ messages in thread
From: Dawid Osuchowski @ 2025-04-17 13:39 UTC (permalink / raw)
  To: Thomas Weißschuh, Tony Nguyen, Przemek Kitszel, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Saeed Mahameed, Leon Romanovsky, Tariq Toukan
  Cc: intel-wired-lan, netdev, linux-kernel, linux-rdma, Aleksandr Loktionov

On 2025-04-17 3:24 PM, Thomas Weißschuh wrote:
> acquire sleeping looks in atomic contexts.

typo? s/sleeping looks/sleeping locks/

present in patch descriptions as well

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Intel-wired-lan] [PATCH net-next v2 0/2] net: Don't use %pK through printk
  2025-04-17 13:39 ` [Intel-wired-lan] [PATCH net-next v2 0/2] net: Don't use %pK through printk Dawid Osuchowski
@ 2025-04-23 10:24   ` Thomas Weißschuh
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Weißschuh @ 2025-04-23 10:24 UTC (permalink / raw)
  To: Dawid Osuchowski
  Cc: Tony Nguyen, Przemek Kitszel, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Saeed Mahameed,
	Leon Romanovsky, Tariq Toukan, intel-wired-lan, netdev,
	linux-kernel, linux-rdma, Aleksandr Loktionov

On Thu, Apr 17, 2025 at 03:39:13PM +0200, Dawid Osuchowski wrote:
> On 2025-04-17 3:24 PM, Thomas Weißschuh wrote:
> > acquire sleeping looks in atomic contexts.
> 
> typo? s/sleeping looks/sleeping locks/
> 
> present in patch descriptions as well

Thanks for noticing. I fixed it up in my template now.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-04-23 10:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-04-17 13:24 [PATCH net-next v2 0/2] net: Don't use %pK through printk Thomas Weißschuh
2025-04-17 13:24 ` [PATCH net-next v2 1/2] ice: Don't use %pK through printk or tracepoints Thomas Weißschuh
2025-04-17 13:24 ` [PATCH net-next v2 2/2] net/mlx5: Don't use %pK through tracepoints Thomas Weißschuh
2025-04-17 13:39 ` [Intel-wired-lan] [PATCH net-next v2 0/2] net: Don't use %pK through printk Dawid Osuchowski
2025-04-23 10:24   ` Thomas Weißschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®