Thread (8 messages) 8 messages, 3 authors, 2021-10-01

Re: [PATCH] drivers/ata: Fix kernel pointer leak

From: Sergey Shtylyov <hidden>
Date: 2021-10-01 20:18:05

On 10/1/21 4:18 AM, Damien Le Moal wrote:

[...]
quoted
quoted
quoted
Pointers should be printed with %p or %px rather than cast to
'unsigned long' and pinted with %lx
s/pinted/printed
quoted
Change %lx to %p to print the secured pointer.

Signed-off-by: Guo Zhi <redacted>
---
  drivers/ata/pata_atp867x.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/ata/pata_atp867x.c b/drivers/ata/pata_atp867x.c
index 2bc5fc81efe3..c32b95f48e50 100644
--- a/drivers/ata/pata_atp867x.c
+++ b/drivers/ata/pata_atp867x.c
@@ -447,11 +447,11 @@ static int atp867x_ata_pci_sff_init_host(struct ata_host *host)
  #ifdef	ATP867X_DEBUG
  		atp867x_check_ports(ap, i);
  #endif
-		ata_port_desc(ap, "cmd 0x%lx ctl 0x%lx",
-			(unsigned long)ioaddr->cmd_addr,
-			(unsigned long)ioaddr->ctl_addr);
-		ata_port_desc(ap, "bmdma 0x%lx",
-			(unsigned long)ioaddr->bmdma_addr);
+		ata_port_desc(ap, "cmd 0x%p ctl 0x%p",
+			ioaddr->cmd_addr,
+			ioaddr->ctl_addr);
+		ata_port_desc(ap, "bmdma 0x%p",
+			ioaddr->bmdma_addr);
  
  		mask |= 1 << i;
  	}
Looks OK to me. But please fix the commit title to:

"ata: atp867x: Fix pointer value print"

"pointer leak" is too scary for what is only a simple printk problem.
    It's not a simple printk() problem, it's an kernel info leak that he's 
fixing. But, as I said, this driver doesn't use MMIO, so "leaks" only I/O port 
addresses.
OK. I interpreted "leak" as memory leak... So the problem is print of pointer
addresses that are unused. But if they are, shouldn't the pointers be NULL ? (I
am absolutely not familiar with this driver, never looked at it).
  They are used to map the I/O parts, so the driver can use ioread*()/iowrite()*.

[...]


MBR, Sergey
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help