lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJrd-Uvzy18SfjjqbqZCPHjw+ujQXsBpvov4b=bfAwZrj=bCAA@mail.gmail.com>
Date:   Mon, 3 Apr 2023 23:39:58 +0900
From:   Jaewon Kim <jaewon31.kim@...il.com>
To:     Petr Mladek <pmladek@...e.com>
Cc:     Jaewon Kim <jaewon31.kim@...sung.com>,
        "senozhatsky@...omium.org" <senozhatsky@...omium.org>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        GyeongHwan Hong <gh21.hong@...sung.com>
Subject: Re: [RFC] vsprintf: compile error on %09pK

2023년 4월 3일 (월) 오후 9:53, Petr Mladek <pmladek@...e.com>님이 작성:
>
> On Mon 2023-04-03 19:46:17, Jaewon Kim wrote:
> > Hello
> >
> > I've just changed %09lx to %09pK on my driver code to hide the address, but I
> > faced compiler error. The %9pK without 0 worked.
>
> What exactly do you want to achieve, please?

Hello

Thank you for your comment.

I wanted to print phys_addr_t  type value only when kptr_restrict sysctl is
allowed. So I thought I could use %pK for that purpose. And the physical
address is not that long. I wanted to make that length short like 9 hex.

>
> Note that printk() hashes pointers by default. It means that %p does not
> print the value but a hash based on the value.
>
> If you print the same pointer twice, you will see the same hash, so
> you know that the pointer is the same. But you do not see the address
> so that you could not use the value for a security attack.
>
> See Documentation/core-api/printk-formats.rst
>
> Anyway, the main question if it makes sense to print the pointer value
> at all. The address is not useful if it can't be compared with
> other pointers or if the data on the address could not be checked.
>
> > Is there restriction on %pK which does now allow %0 ? I've wondered whether I
> > did wrong or it is a printk problem.
> >
> > To show easily I tried to add pr_info("%09pK\n", nodemask); in page_alloc.c
> > Then here's what I did.
> >
> > $ ARCH=x86 make x86_64_defconfig ; make mm/page_alloc.o
> > #
> > # No change to .config
> > #
> >   CALL    scripts/checksyscalls.sh
> >   DESCEND objtool
> >   INSTALL libsubcmd_headers
> >   CC      mm/page_alloc.o
> > In file included from ./include/asm-generic/bug.h:22:0,
> >                  from ./arch/x86/include/asm/bug.h:87,
> >                  from ./include/linux/bug.h:5,
> >                  from ./include/linux/mmdebug.h:5,
> >                  from ./include/linux/mm.h:6,
> >                  from mm/page_alloc.c:19:
> > mm/page_alloc.c: In function ‘__alloc_pages’:
> > ./include/linux/kern_levels.h:5:18: error: '0' flag used with ‘%p’ gnu_printf format [-Werror=format=]
> >  #define KERN_SOH "\001"  /* ASCII Start Of Header */
>
> As Sergey already wrote. %p does not support any modification flags.

Okay, then we can't use %09pK. I've just wondered because %9pK works.

BR
Jaewon Kim

>
> Best Regards,
> Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ