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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 1 May 2017 08:24:23 -0700
From:   Dan Williams <dan.j.williams@...el.com>
To:     Baoquan He <bhe@...hat.com>
Cc:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>, X86 ML <x86@...nel.org>,
        Kees Cook <keescook@...omium.org>,
        Thomas Garnier <thgarnie@...gle.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Yasuaki Ishimatsu <yasu.isimatu@...il.com>,
        Jinbum Park <jinb.park7@...il.com>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
        Yinghai Lu <yinghai@...nel.org>, Dave Young <dyoung@...hat.com>
Subject: Re: [PATCH] x86/mm: Fix incorrect for loop count calculation in sync_global_pgds

On Mon, May 1, 2017 at 7:52 AM, Baoquan He <bhe@...hat.com> wrote:
> On 05/01/17 at 07:40am, Dan Williams wrote:
>> On Mon, May 1, 2017 at 4:41 AM, Baoquan He <bhe@...hat.com> wrote:
>> >  arch/x86/mm/init_64.c | 6 ++++--
>> >  1 file changed, 4 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
>> > index 15173d3..dbf4f00 100644
>> > --- a/arch/x86/mm/init_64.c
>> > +++ b/arch/x86/mm/init_64.c
>> > @@ -94,12 +94,14 @@ __setup("noexec32=", nonx32_setup);
>> >   */
>> >  void sync_global_pgds(unsigned long start, unsigned long end)
>> >  {
>> > -       unsigned long address;
>> > +       unsigned long address, address_next;
>> >
>> > -       for (address = start; address <= end; address += PGDIR_SIZE) {
>> > +       for (address = start; address <= end; address = address_next) {
>> >                 const pgd_t *pgd_ref = pgd_offset_k(address);
>> >                 struct page *page;
>> >
>> > +               address_next = (address & PGDIR_MASK) + PGDIR_SIZE;
>> > +
>>
>> Let's change this to put the next address calculation in the for loop
>> directly and use the ALIGN macro. Something like:
>>
>>  for (address = start; address <= end; address = ALIGN(address + 1, PGDIR_SIZE))
>
> Hi Dan,
>
> Good idea!
>
> Do you think below change is OK for you? Taking out the initialization
> can make the for loop line be shorter than 80 char.
>

I would just wrap the "address = ALIGN(address + 1, PGDIR_SIZE)" if it
doesn't fit.

>
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 15173d3..0840311 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -94,12 +94,14 @@ __setup("noexec32=", nonx32_setup);
>   */
>  void sync_global_pgds(unsigned long start, unsigned long end)
>  {
> -       unsigned long address;
> +       unsigned long address = start;
>
> -       for (address = start; address <= end; address += PGDIR_SIZE) {
> +       for (; address <= end; address = ALIGN(address + 1, PGDIR_SIZE))
> {
>                 const pgd_t *pgd_ref = pgd_offset_k(address);
>                 struct page *page;
>
> +               address_next = (address & PGDIR_MASK) + PGDIR_SIZE;
> +

This gets deleted of course.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ