mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Question about output of kmalloc()
@ 2020-01-14  7:20 xuesong Chen
  2020-01-14 10:36 ` David Laight
  0 siblings, 1 reply; 3+ messages in thread
From: xuesong Chen @ 2020-01-14  7:20 UTC (permalink / raw)
  To: linux-kernel; +Cc: xuesong Chen

Hello,

Below code snippet in the .ko:

unsigned long *p = (unsigned long *)kmalloc(sizeof(*p), GFP_KERNEL);
printk("Addr of p = 0x%p\n", p);

The output is:
Addr of p = 0x0000000018606ce7

In my mind, during the early day, the p should be 0xfffff...., can
anybody give some tips why the output looks like it's a physical
address?

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

* RE: Question about output of kmalloc()
  2020-01-14  7:20 Question about output of kmalloc() xuesong Chen
@ 2020-01-14 10:36 ` David Laight
  2020-01-14 11:50   ` xuesong Chen
  0 siblings, 1 reply; 3+ messages in thread
From: David Laight @ 2020-01-14 10:36 UTC (permalink / raw)
  To: 'xuesong Chen', linux-kernel

From:  xuesong Chen
> Sent: 14 January 2020 07:21
> Below code snippet in the .ko:
> 
> unsigned long *p = (unsigned long *)kmalloc(sizeof(*p), GFP_KERNEL);
> printk("Addr of p = 0x%p\n", p);
> 
> The output is:
> Addr of p = 0x0000000018606ce7
> 
> In my mind, during the early day, the p should be 0xfffff...., can
> anybody give some tips why the output looks like it's a physical
> address?

The printed value is hashed to avoid leaking info.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

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

* Re: Question about output of kmalloc()
  2020-01-14 10:36 ` David Laight
@ 2020-01-14 11:50   ` xuesong Chen
  0 siblings, 0 replies; 3+ messages in thread
From: xuesong Chen @ 2020-01-14 11:50 UTC (permalink / raw)
  To: David Laight; +Cc: linux-kernel

On Tue, Jan 14, 2020 at 6:36 PM David Laight <David.Laight@aculab.com> wrote:
>
> From:  xuesong Chen
> > Sent: 14 January 2020 07:21
> > Below code snippet in the .ko:
> >
> > unsigned long *p = (unsigned long *)kmalloc(sizeof(*p), GFP_KERNEL);
> > printk("Addr of p = 0x%p\n", p);
> >
> > The output is:
> > Addr of p = 0x0000000018606ce7
> >
> > In my mind, during the early day, the p should be 0xfffff...., can
> > anybody give some tips why the output looks like it's a physical
> > address?
>
> The printed value is hashed to avoid leaking info.
>
But '%px' can print the correct value, so seems the infoleak is still
there... BTW, kindly point me to the hashed address code part?
>
>
>         David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)

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

end of thread, other threads:[~2020-01-14 11:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14  7:20 Question about output of kmalloc() xuesong Chen
2020-01-14 10:36 ` David Laight
2020-01-14 11:50   ` xuesong Chen

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

all inboxes | Powered by JetHome®