public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mtd: stm32-quadspi: replace "%p" with "%pK"
@ 2018-07-06 13:05 Benjamin Gaignard
  2018-07-06 14:44 ` Richard Weinberger
  2018-07-07 10:09 ` Boris Brezillon
  0 siblings, 2 replies; 5+ messages in thread
From: Benjamin Gaignard @ 2018-07-06 13:05 UTC (permalink / raw)
  To: linux-arm-kernel

The format specifier "%p" can leak kernel addresses.
Use "%pK" instead.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
---
 drivers/mtd/spi-nor/stm32-quadspi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/spi-nor/stm32-quadspi.c b/drivers/mtd/spi-nor/stm32-quadspi.c
index 72553506a00b..13e9fc961d3b 100644
--- a/drivers/mtd/spi-nor/stm32-quadspi.c
+++ b/drivers/mtd/spi-nor/stm32-quadspi.c
@@ -355,7 +355,7 @@ static int stm32_qspi_read_reg(struct spi_nor *nor,
 	struct device *dev = flash->qspi->dev;
 	struct stm32_qspi_cmd cmd;
 
-	dev_dbg(dev, "read_reg: cmd:%#.2x buf:%p len:%#x\n", opcode, buf, len);
+	dev_dbg(dev, "read_reg: cmd:%#.2x buf:%pK len:%#x\n", opcode, buf, len);
 
 	memset(&cmd, 0, sizeof(cmd));
 	cmd.opcode = opcode;
@@ -376,7 +376,7 @@ static int stm32_qspi_write_reg(struct spi_nor *nor, u8 opcode,
 	struct device *dev = flash->qspi->dev;
 	struct stm32_qspi_cmd cmd;
 
-	dev_dbg(dev, "write_reg: cmd:%#.2x buf:%p len:%#x\n", opcode, buf, len);
+	dev_dbg(dev, "write_reg: cmd:%#.2x buf:%pK len:%#x\n", opcode, buf, len);
 
 	memset(&cmd, 0, sizeof(cmd));
 	cmd.opcode = opcode;
@@ -398,7 +398,7 @@ static ssize_t stm32_qspi_read(struct spi_nor *nor, loff_t from, size_t len,
 	struct stm32_qspi_cmd cmd;
 	int err;
 
-	dev_dbg(qspi->dev, "read(%#.2x): buf:%p from:%#.8x len:%#zx\n",
+	dev_dbg(qspi->dev, "read(%#.2x): buf:%pK from:%#.8x len:%#zx\n",
 		nor->read_opcode, buf, (u32)from, len);
 
 	memset(&cmd, 0, sizeof(cmd));
-- 
2.15.0

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

* [PATCH] mtd: stm32-quadspi: replace "%p" with "%pK"
  2018-07-06 13:05 [PATCH] mtd: stm32-quadspi: replace "%p" with "%pK" Benjamin Gaignard
@ 2018-07-06 14:44 ` Richard Weinberger
  2018-07-06 14:47   ` Boris Brezillon
  2018-07-07 10:09 ` Boris Brezillon
  1 sibling, 1 reply; 5+ messages in thread
From: Richard Weinberger @ 2018-07-06 14:44 UTC (permalink / raw)
  To: linux-arm-kernel

Am Freitag, 6. Juli 2018, 15:05:25 CEST schrieb Benjamin Gaignard:
> The format specifier "%p" can leak kernel addresses.
> Use "%pK" instead.

Does %pK really make sense for dev_dbg()?
When the driver is being debugged "leaking" is on purpose. :)

Thanks,
//richard
 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
> ---
>  drivers/mtd/spi-nor/stm32-quadspi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/stm32-quadspi.c b/drivers/mtd/spi-nor/stm32-quadspi.c
> index 72553506a00b..13e9fc961d3b 100644
> --- a/drivers/mtd/spi-nor/stm32-quadspi.c
> +++ b/drivers/mtd/spi-nor/stm32-quadspi.c
> @@ -355,7 +355,7 @@ static int stm32_qspi_read_reg(struct spi_nor *nor,
>  	struct device *dev = flash->qspi->dev;
>  	struct stm32_qspi_cmd cmd;
>  
> -	dev_dbg(dev, "read_reg: cmd:%#.2x buf:%p len:%#x\n", opcode, buf, len);
> +	dev_dbg(dev, "read_reg: cmd:%#.2x buf:%pK len:%#x\n", opcode, buf, len);
>  
>  	memset(&cmd, 0, sizeof(cmd));
>  	cmd.opcode = opcode;
> @@ -376,7 +376,7 @@ static int stm32_qspi_write_reg(struct spi_nor *nor, u8 opcode,
>  	struct device *dev = flash->qspi->dev;
>  	struct stm32_qspi_cmd cmd;
>  
> -	dev_dbg(dev, "write_reg: cmd:%#.2x buf:%p len:%#x\n", opcode, buf, len);
> +	dev_dbg(dev, "write_reg: cmd:%#.2x buf:%pK len:%#x\n", opcode, buf, len);
>  
>  	memset(&cmd, 0, sizeof(cmd));
>  	cmd.opcode = opcode;
> @@ -398,7 +398,7 @@ static ssize_t stm32_qspi_read(struct spi_nor *nor, loff_t from, size_t len,
>  	struct stm32_qspi_cmd cmd;
>  	int err;
>  
> -	dev_dbg(qspi->dev, "read(%#.2x): buf:%p from:%#.8x len:%#zx\n",
> +	dev_dbg(qspi->dev, "read(%#.2x): buf:%pK from:%#.8x len:%#zx\n",
>  		nor->read_opcode, buf, (u32)from, len);
>  
>  	memset(&cmd, 0, sizeof(cmd));
> 

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

* [PATCH] mtd: stm32-quadspi: replace "%p" with "%pK"
  2018-07-06 14:44 ` Richard Weinberger
@ 2018-07-06 14:47   ` Boris Brezillon
  2018-07-06 14:49     ` Richard Weinberger
  0 siblings, 1 reply; 5+ messages in thread
From: Boris Brezillon @ 2018-07-06 14:47 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, 06 Jul 2018 16:44:44 +0200
Richard Weinberger <richard@nod.at> wrote:

> Am Freitag, 6. Juli 2018, 15:05:25 CEST schrieb Benjamin Gaignard:
> > The format specifier "%p" can leak kernel addresses.
> > Use "%pK" instead.  
> 
> Does %pK really make sense for dev_dbg()?
> When the driver is being debugged "leaking" is on purpose. :)

%p already gives you a hash of the pointer address. At least with %pK
you can turn it off through a sysctl :).

> 
> Thanks,
> //richard
>  
> > Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
> > ---
> >  drivers/mtd/spi-nor/stm32-quadspi.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/mtd/spi-nor/stm32-quadspi.c b/drivers/mtd/spi-nor/stm32-quadspi.c
> > index 72553506a00b..13e9fc961d3b 100644
> > --- a/drivers/mtd/spi-nor/stm32-quadspi.c
> > +++ b/drivers/mtd/spi-nor/stm32-quadspi.c
> > @@ -355,7 +355,7 @@ static int stm32_qspi_read_reg(struct spi_nor *nor,
> >  	struct device *dev = flash->qspi->dev;
> >  	struct stm32_qspi_cmd cmd;
> >  
> > -	dev_dbg(dev, "read_reg: cmd:%#.2x buf:%p len:%#x\n", opcode, buf, len);
> > +	dev_dbg(dev, "read_reg: cmd:%#.2x buf:%pK len:%#x\n", opcode, buf, len);
> >  
> >  	memset(&cmd, 0, sizeof(cmd));
> >  	cmd.opcode = opcode;
> > @@ -376,7 +376,7 @@ static int stm32_qspi_write_reg(struct spi_nor *nor, u8 opcode,
> >  	struct device *dev = flash->qspi->dev;
> >  	struct stm32_qspi_cmd cmd;
> >  
> > -	dev_dbg(dev, "write_reg: cmd:%#.2x buf:%p len:%#x\n", opcode, buf, len);
> > +	dev_dbg(dev, "write_reg: cmd:%#.2x buf:%pK len:%#x\n", opcode, buf, len);
> >  
> >  	memset(&cmd, 0, sizeof(cmd));
> >  	cmd.opcode = opcode;
> > @@ -398,7 +398,7 @@ static ssize_t stm32_qspi_read(struct spi_nor *nor, loff_t from, size_t len,
> >  	struct stm32_qspi_cmd cmd;
> >  	int err;
> >  
> > -	dev_dbg(qspi->dev, "read(%#.2x): buf:%p from:%#.8x len:%#zx\n",
> > +	dev_dbg(qspi->dev, "read(%#.2x): buf:%pK from:%#.8x len:%#zx\n",
> >  		nor->read_opcode, buf, (u32)from, len);
> >  
> >  	memset(&cmd, 0, sizeof(cmd));
> >   
> 
> 

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

* [PATCH] mtd: stm32-quadspi: replace "%p" with "%pK"
  2018-07-06 14:47   ` Boris Brezillon
@ 2018-07-06 14:49     ` Richard Weinberger
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Weinberger @ 2018-07-06 14:49 UTC (permalink / raw)
  To: linux-arm-kernel

Am Freitag, 6. Juli 2018, 16:47:32 CEST schrieb Boris Brezillon:
> On Fri, 06 Jul 2018 16:44:44 +0200
> Richard Weinberger <richard@nod.at> wrote:
> 
> > Am Freitag, 6. Juli 2018, 15:05:25 CEST schrieb Benjamin Gaignard:
> > > The format specifier "%p" can leak kernel addresses.
> > > Use "%pK" instead.  
> > 
> > Does %pK really make sense for dev_dbg()?
> > When the driver is being debugged "leaking" is on purpose. :)
> 
> %p already gives you a hash of the pointer address. At least with %pK
> you can turn it off through a sysctl :).

Once again I mixed %p and %pK.
So then %pK is what we want. :D

Thanks,
//richard

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

* [PATCH] mtd: stm32-quadspi: replace "%p" with "%pK"
  2018-07-06 13:05 [PATCH] mtd: stm32-quadspi: replace "%p" with "%pK" Benjamin Gaignard
  2018-07-06 14:44 ` Richard Weinberger
@ 2018-07-07 10:09 ` Boris Brezillon
  1 sibling, 0 replies; 5+ messages in thread
From: Boris Brezillon @ 2018-07-07 10:09 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri,  6 Jul 2018 15:05:25 +0200
Benjamin Gaignard <benjamin.gaignard@linaro.org> wrote:

> The format specifier "%p" can leak kernel addresses.
> Use "%pK" instead.
> 
> Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>

Applied.

Thanks,

Boris

> ---
>  drivers/mtd/spi-nor/stm32-quadspi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/spi-nor/stm32-quadspi.c b/drivers/mtd/spi-nor/stm32-quadspi.c
> index 72553506a00b..13e9fc961d3b 100644
> --- a/drivers/mtd/spi-nor/stm32-quadspi.c
> +++ b/drivers/mtd/spi-nor/stm32-quadspi.c
> @@ -355,7 +355,7 @@ static int stm32_qspi_read_reg(struct spi_nor *nor,
>  	struct device *dev = flash->qspi->dev;
>  	struct stm32_qspi_cmd cmd;
>  
> -	dev_dbg(dev, "read_reg: cmd:%#.2x buf:%p len:%#x\n", opcode, buf, len);
> +	dev_dbg(dev, "read_reg: cmd:%#.2x buf:%pK len:%#x\n", opcode, buf, len);
>  
>  	memset(&cmd, 0, sizeof(cmd));
>  	cmd.opcode = opcode;
> @@ -376,7 +376,7 @@ static int stm32_qspi_write_reg(struct spi_nor *nor, u8 opcode,
>  	struct device *dev = flash->qspi->dev;
>  	struct stm32_qspi_cmd cmd;
>  
> -	dev_dbg(dev, "write_reg: cmd:%#.2x buf:%p len:%#x\n", opcode, buf, len);
> +	dev_dbg(dev, "write_reg: cmd:%#.2x buf:%pK len:%#x\n", opcode, buf, len);
>  
>  	memset(&cmd, 0, sizeof(cmd));
>  	cmd.opcode = opcode;
> @@ -398,7 +398,7 @@ static ssize_t stm32_qspi_read(struct spi_nor *nor, loff_t from, size_t len,
>  	struct stm32_qspi_cmd cmd;
>  	int err;
>  
> -	dev_dbg(qspi->dev, "read(%#.2x): buf:%p from:%#.8x len:%#zx\n",
> +	dev_dbg(qspi->dev, "read(%#.2x): buf:%pK from:%#.8x len:%#zx\n",
>  		nor->read_opcode, buf, (u32)from, len);
>  
>  	memset(&cmd, 0, sizeof(cmd));

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

end of thread, other threads:[~2018-07-07 10:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-06 13:05 [PATCH] mtd: stm32-quadspi: replace "%p" with "%pK" Benjamin Gaignard
2018-07-06 14:44 ` Richard Weinberger
2018-07-06 14:47   ` Boris Brezillon
2018-07-06 14:49     ` Richard Weinberger
2018-07-07 10:09 ` Boris Brezillon

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