All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] habanalabs: use %px instead of %p in error print
@ 2019-03-02  9:43 Oded Gabbay
  2019-03-07  3:46 ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Oded Gabbay @ 2019-03-02  9:43 UTC (permalink / raw)
  To: gregkh, linux-kernel; +Cc: joe

When parsing the address of an internal command buffer, the driver prints
an error if the buffer's address is not in the range of the device's DRAM
or SRAM memory address space.

Use %px to print the real address that the user gave the driver and not a
hashed value, so the user will get a clue regarding the origin of his
error.

Note that if the print occurs, the pointer that is printed is a
user's virtual address and not some kind of physical address.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
---
 drivers/misc/habanalabs/goya/goya.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c
index c4f3ec1e9d8b..238dd57c541b 100644
--- a/drivers/misc/habanalabs/goya/goya.c
+++ b/drivers/misc/habanalabs/goya/goya.c
@@ -4293,7 +4293,7 @@ static int goya_parse_cb_no_ext_quque(struct hl_device *hdev,
 			return 0;
 
 		dev_err(hdev->dev,
-			"Internal CB address %p + 0x%x is not in SRAM nor in DRAM\n",
+			"Internal CB address %px + 0x%x is not in SRAM nor in DRAM\n",
 			parser->user_cb, parser->user_cb_size);
 
 		return -EFAULT;
-- 
2.18.0


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

* Re: [PATCH] habanalabs: use %px instead of %p in error print
  2019-03-02  9:43 [PATCH] habanalabs: use %px instead of %p in error print Oded Gabbay
@ 2019-03-07  3:46 ` Kees Cook
  2019-03-07  5:42   ` Oded Gabbay
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2019-03-07  3:46 UTC (permalink / raw)
  To: Oded Gabbay; +Cc: Greg KH, LKML, Joe Perches

On Sat, Mar 2, 2019 at 1:43 AM Oded Gabbay <oded.gabbay@gmail.com> wrote:
>
> When parsing the address of an internal command buffer, the driver prints
> an error if the buffer's address is not in the range of the device's DRAM
> or SRAM memory address space.
>
> Use %px to print the real address that the user gave the driver and not a
> hashed value, so the user will get a clue regarding the origin of his
> error.
>
> Note that if the print occurs, the pointer that is printed is a
> user's virtual address and not some kind of physical address.

Err, which virtual address space is this? If this is mapped into the
kernel's virtual address space, this should not be %px...

-Kees

>
> Suggested-by: Joe Perches <joe@perches.com>
> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
> ---
>  drivers/misc/habanalabs/goya/goya.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c
> index c4f3ec1e9d8b..238dd57c541b 100644
> --- a/drivers/misc/habanalabs/goya/goya.c
> +++ b/drivers/misc/habanalabs/goya/goya.c
> @@ -4293,7 +4293,7 @@ static int goya_parse_cb_no_ext_quque(struct hl_device *hdev,
>                         return 0;
>
>                 dev_err(hdev->dev,
> -                       "Internal CB address %p + 0x%x is not in SRAM nor in DRAM\n",
> +                       "Internal CB address %px + 0x%x is not in SRAM nor in DRAM\n",
>                         parser->user_cb, parser->user_cb_size);
>
>                 return -EFAULT;
> --
> 2.18.0
>


-- 
Kees Cook

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

* Re: [PATCH] habanalabs: use %px instead of %p in error print
  2019-03-07  3:46 ` Kees Cook
@ 2019-03-07  5:42   ` Oded Gabbay
  2019-03-07 15:54     ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Oded Gabbay @ 2019-03-07  5:42 UTC (permalink / raw)
  To: Kees Cook; +Cc: Greg KH, LKML, Joe Perches

On Thu, Mar 7, 2019 at 5:46 AM Kees Cook <keescook@chromium.org> wrote:
>
> On Sat, Mar 2, 2019 at 1:43 AM Oded Gabbay <oded.gabbay@gmail.com> wrote:
> >
> > When parsing the address of an internal command buffer, the driver prints
> > an error if the buffer's address is not in the range of the device's DRAM
> > or SRAM memory address space.
> >
> > Use %px to print the real address that the user gave the driver and not a
> > hashed value, so the user will get a clue regarding the origin of his
> > error.
> >
> > Note that if the print occurs, the pointer that is printed is a
> > user's virtual address and not some kind of physical address.
>
> Err, which virtual address space is this? If this is mapped into the
> kernel's virtual address space, this should not be %px...
No, it's not mapped to kernel in any way.
It's supposed to be an address in the device's address space.
As this is an error message, it's either a wrong address in the
device's address space, or it's a user-space virtual address.
Oded


>
> -Kees
>
> >
> > Suggested-by: Joe Perches <joe@perches.com>
> > Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
> > ---
> >  drivers/misc/habanalabs/goya/goya.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c
> > index c4f3ec1e9d8b..238dd57c541b 100644
> > --- a/drivers/misc/habanalabs/goya/goya.c
> > +++ b/drivers/misc/habanalabs/goya/goya.c
> > @@ -4293,7 +4293,7 @@ static int goya_parse_cb_no_ext_quque(struct hl_device *hdev,
> >                         return 0;
> >
> >                 dev_err(hdev->dev,
> > -                       "Internal CB address %p + 0x%x is not in SRAM nor in DRAM\n",
> > +                       "Internal CB address %px + 0x%x is not in SRAM nor in DRAM\n",
> >                         parser->user_cb, parser->user_cb_size);
> >
> >                 return -EFAULT;
> > --
> > 2.18.0
> >
>
>
> --
> Kees Cook

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

* Re: [PATCH] habanalabs: use %px instead of %p in error print
  2019-03-07  5:42   ` Oded Gabbay
@ 2019-03-07 15:54     ` Kees Cook
  0 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2019-03-07 15:54 UTC (permalink / raw)
  To: Oded Gabbay; +Cc: Greg KH, LKML, Joe Perches

On Wed, Mar 6, 2019 at 9:42 PM Oded Gabbay <oded.gabbay@gmail.com> wrote:
>
> On Thu, Mar 7, 2019 at 5:46 AM Kees Cook <keescook@chromium.org> wrote:
> >
> > On Sat, Mar 2, 2019 at 1:43 AM Oded Gabbay <oded.gabbay@gmail.com> wrote:
> > >
> > > When parsing the address of an internal command buffer, the driver prints
> > > an error if the buffer's address is not in the range of the device's DRAM
> > > or SRAM memory address space.
> > >
> > > Use %px to print the real address that the user gave the driver and not a
> > > hashed value, so the user will get a clue regarding the origin of his
> > > error.
> > >
> > > Note that if the print occurs, the pointer that is printed is a
> > > user's virtual address and not some kind of physical address.
> >
> > Err, which virtual address space is this? If this is mapped into the
> > kernel's virtual address space, this should not be %px...
> No, it's not mapped to kernel in any way.
> It's supposed to be an address in the device's address space.
> As this is an error message, it's either a wrong address in the
> device's address space, or it's a user-space virtual address.

Okay, thanks! :)

-- 
Kees Cook

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

end of thread, other threads:[~2019-03-07 15:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-02  9:43 [PATCH] habanalabs: use %px instead of %p in error print Oded Gabbay
2019-03-07  3:46 ` Kees Cook
2019-03-07  5:42   ` Oded Gabbay
2019-03-07 15:54     ` Kees Cook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.