diff mbox series

[net-next,7/7] net/mlx5: Don't use %pK through tracepoints

Message ID 20250414-restricted-pointers-net-v1-7-12af0ce46cdd@linutronix.de (mailing list archive)
State New
Delegated to: Johannes Berg
Headers show
Series net: Don't use %pK through printk | expand

Checks

Context Check Description
wifibot/fixes_present success Fixes tag not required for -next series
wifibot/series_format success Posting correctly formatted
wifibot/tree_selection success Guessed tree name to be wireless-next
wifibot/ynl success Generated files up to date; no warnings/errors; no diff in generated;
wifibot/build_32bit success Errors and warnings before: 1 this patch: 1
wifibot/build_allmodconfig_warn success Errors and warnings before: 2 this patch: 2
wifibot/build_clang success Errors and warnings before: 2 this patch: 2
wifibot/build_clang_rust success No Rust files in patch. Skipping build
wifibot/build_tools success No tools touched, skip
wifibot/check_selftest success No net selftest shell script
wifibot/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
wifibot/deprecated_api success None detected
wifibot/header_inline success No static functions without inline keyword in header files
wifibot/kdoc success Errors and warnings before: 0 this patch: 0
wifibot/source_inline success Was 0 now: 0
wifibot/verify_fixes success No Fixes tag
wifibot/verify_signedoff success Signed-off-by tag matches author and committer

Commit Message

Thomas Weißschuh April 14, 2025, 8:26 a.m. UTC
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>
---
 drivers/net/ethernet/mellanox/mlx5/core/sf/dev/diag/dev_tracepoint.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tariq Toukan April 14, 2025, 10:49 a.m. UTC | #1
On 14/04/2025 11:26, Thomas Weißschuh wrote:
> 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>
> ---
>   drivers/net/ethernet/mellanox/mlx5/core/sf/dev/diag/dev_tracepoint.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Loktionov, Aleksandr April 14, 2025, 4:17 p.m. UTC | #2
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of
> Thomas Weißschuh
> Sent: Monday, April 14, 2025 10:26 AM
> To: Jeff Johnson <jjohnson@kernel.org>; Loic Poulain
> <loic.poulain@linaro.org>; Brian Norris <briannorris@chromium.org>;
> Francesco Dolcini <francesco@dolcini.it>; Nguyen, Anthony L
> <anthony.l.nguyen@intel.com>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>; Andrew Lunn <andrew+netdev@lunn.ch>;
> David S. Miller <davem@davemloft.net>; Dumazet, Eric
> <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>; Paolo Abeni
> <pabeni@redhat.com>; Saeed Mahameed <saeedm@nvidia.com>; Leon
> Romanovsky <leon@kernel.org>; Tariq Toukan <tariqt@nvidia.com>
> Cc: ath10k@lists.infradead.org; linux-kernel@vger.kernel.org;
> ath11k@lists.infradead.org; ath12k@lists.infradead.org;
> wcn36xx@lists.infradead.org; linux-wireless@vger.kernel.org; intel-wired-
> lan@lists.osuosl.org; netdev@vger.kernel.org; linux-rdma@vger.kernel.org;
> Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> Subject: [Intel-wired-lan] [PATCH net-next 7/7] net/mlx5: Don't use %pK
> through 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 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>
> ---
>  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..9b0f44253f332aa602a8
> 4a1f6d7532a500dd4f55 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
diff mbox series

Patch

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)