Skip to contentSkip to conversation

drivers: dma-buf: Change %p to %pK in debug messages

PATCH RESEND In review Daniel Rosenberg 3 participants 3 messages Jun 5, 2018 – Jun 6, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 drivers: dma-buf: Change %p to %pK in debug messages

The format specifier %p can leak kernel addresses while not valuing the kptr_restrict system settings. Use %pK instead of %p, which also evaluates whether kptr_restrict is set.

---
 drivers/dma-buf/sync_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/sync_debug.c +1 -1
index c4c8ecb24aa9..d8d340542a79 100644
@@ -133,7 +133,7 @@ static void sync_print_sync_file(struct seq_file *s,
 	char buf[128];
 	int i;
 
-	seq_printf(s, "[%p] %s: %s\n", sync_file,
+	seq_printf(s, "[%pK] %s: %s\n", sync_file,
 		   sync_file_get_name(sync_file, buf, sizeof(buf)),
 		   sync_status_str(dma_fence_get_status(sync_file->fence)));
 
Signature · 1 line
2.17.0.441.gb46fe60e1d-goog
#1 lore raw

Quoting Daniel Rosenberg (2018-06-06 00:40:41)

Quoted 4 lines

The format specifier %p can leak kernel addresses while not valuing the kptr_restrict system settings. Use %pK instead of %p, which also evaluates whether kptr_restrict is set.

This is backwards though. You never care about the actual value here and the hashed pointer (%p) is always enough to provide an identifying token. -Chris

maintainer
#2 lore raw
In reply to Daniel Rosenberg
Quoted 17 lines · Daniel Rosenberg

The format specifier %p can leak kernel addresses while not valuing the kptr_restrict system settings. Use %pK instead of %p, which also evaluates whether kptr_restrict is set.

---
 drivers/dma-buf/sync_debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma-buf/sync_debug.c +0 -0
index c4c8ecb24aa9..d8d340542a79 100644

drivers/dma-buf/sync_debug.c static void sync_print_sync_file(struct seq_file *s, · line 136

Quoted 5 lines
drivers/dma-buf/sync_debug.c +1 -1
@@ -133,7 +133,7 @@ static void sync_print_sync_file(struct seq_file *s,
 	char buf[128];
 	int i;
 
-	seq_printf(s, "[%p] %s: %s\n", sync_file,
+	seq_printf(s, "[%pK] %s: %s\n", sync_file,

This is a root-only file, right? So it's not that bad of a problem. Also, by default, all %p pointers are now hashed so what really is leaking here?

And finally, why even print out a pointer at all? Why not just stick with the name and not worry about the pointer?

thanks,

greg k-h