diff mbox series

[v3,1/8] ref_tracker: don't use %pK in pr_ostream() output

Message ID 20250417-reftrack-dbgfs-v3-1-c3159428c8fb@kernel.org (mailing list archive)
State Superseded
Headers show
Series ref_tracker: add ability to register a debugfs file for a ref_tracker_dir | expand

Checks

Context Check Description
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Jeff Layton April 17, 2025, 1:11 p.m. UTC
As Thomas Weißschuh points out [1], it is now preferable to use %p
instead of hashed pointers with printk(), since raw pointers should no
longer be leaked into the kernel log. Change the ref_tracker
infrastructure to use %p instead of %pK in its formats.

[1]: https://lore.kernel.org/netdev/20250414-restricted-pointers-net-v1-0-12af0ce46cdd@linutronix.de/

Cc: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 lib/ref_tracker.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Thomas Weißschuh April 17, 2025, 1:25 p.m. UTC | #1
On Thu, Apr 17, 2025 at 09:11:04AM -0400, Jeff Layton wrote:
> As Thomas Weißschuh points out [1], it is now preferable to use %p
> instead of hashed pointers with printk(), since raw pointers should no
> longer be leaked into the kernel log. Change the ref_tracker
> infrastructure to use %p instead of %pK in its formats.
> 
> [1]: https://lore.kernel.org/netdev/20250414-restricted-pointers-net-v1-0-12af0ce46cdd@linutronix.de/
> 
> Cc: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Thanks,

Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

> ---
>  lib/ref_tracker.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c
> index cf5609b1ca79361763abe5a3a98484a3ee591ff2..de71439e12a3bab6456910986fa611dfbdd97980 100644
> --- a/lib/ref_tracker.c
> +++ b/lib/ref_tracker.c
> @@ -96,7 +96,7 @@ __ref_tracker_dir_pr_ostream(struct ref_tracker_dir *dir,
>  
>  	stats = ref_tracker_get_stats(dir, display_limit);
>  	if (IS_ERR(stats)) {
> -		pr_ostream(s, "%s@%pK: couldn't get stats, error %pe\n",
> +		pr_ostream(s, "%s@%p: couldn't get stats, error %pe\n",
>  			   dir->name, dir, stats);
>  		return;
>  	}
> @@ -107,13 +107,13 @@ __ref_tracker_dir_pr_ostream(struct ref_tracker_dir *dir,
>  		stack = stats->stacks[i].stack_handle;
>  		if (sbuf && !stack_depot_snprint(stack, sbuf, STACK_BUF_SIZE, 4))
>  			sbuf[0] = 0;
> -		pr_ostream(s, "%s@%pK has %d/%d users at\n%s\n", dir->name, dir,
> +		pr_ostream(s, "%s@%p has %d/%d users at\n%s\n", dir->name, dir,
>  			   stats->stacks[i].count, stats->total, sbuf);
>  		skipped -= stats->stacks[i].count;
>  	}
>  
>  	if (skipped)
> -		pr_ostream(s, "%s@%pK skipped reports about %d/%d users.\n",
> +		pr_ostream(s, "%s@%p skipped reports about %d/%d users.\n",
>  			   dir->name, dir, skipped, stats->total);
>  
>  	kfree(sbuf);
> 
> -- 
> 2.49.0
>
diff mbox series

Patch

diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c
index cf5609b1ca79361763abe5a3a98484a3ee591ff2..de71439e12a3bab6456910986fa611dfbdd97980 100644
--- a/lib/ref_tracker.c
+++ b/lib/ref_tracker.c
@@ -96,7 +96,7 @@  __ref_tracker_dir_pr_ostream(struct ref_tracker_dir *dir,
 
 	stats = ref_tracker_get_stats(dir, display_limit);
 	if (IS_ERR(stats)) {
-		pr_ostream(s, "%s@%pK: couldn't get stats, error %pe\n",
+		pr_ostream(s, "%s@%p: couldn't get stats, error %pe\n",
 			   dir->name, dir, stats);
 		return;
 	}
@@ -107,13 +107,13 @@  __ref_tracker_dir_pr_ostream(struct ref_tracker_dir *dir,
 		stack = stats->stacks[i].stack_handle;
 		if (sbuf && !stack_depot_snprint(stack, sbuf, STACK_BUF_SIZE, 4))
 			sbuf[0] = 0;
-		pr_ostream(s, "%s@%pK has %d/%d users at\n%s\n", dir->name, dir,
+		pr_ostream(s, "%s@%p has %d/%d users at\n%s\n", dir->name, dir,
 			   stats->stacks[i].count, stats->total, sbuf);
 		skipped -= stats->stacks[i].count;
 	}
 
 	if (skipped)
-		pr_ostream(s, "%s@%pK skipped reports about %d/%d users.\n",
+		pr_ostream(s, "%s@%p skipped reports about %d/%d users.\n",
 			   dir->name, dir, skipped, stats->total);
 
 	kfree(sbuf);