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]
Message-ID: <CAMj1kXEcTfvRcNh_VDhj5QxzMhD9rFhVmeAfuSF7vm1c_4_iHg@mail.gmail.com>
Date: Sat, 17 Feb 2024 14:58:29 +0100
From: Ard Biesheuvel <ardb@...nel.org>
To: Borislav Petkov <bp@...en8.de>
Cc: Ard Biesheuvel <ardb+git@...gle.com>, linux-kernel@...r.kernel.org, 
	Kevin Loughlin <kevinloughlin@...gle.com>, Tom Lendacky <thomas.lendacky@....com>, 
	Dionna Glaze <dionnaglaze@...gle.com>, Thomas Gleixner <tglx@...utronix.de>, 
	Ingo Molnar <mingo@...hat.com>, Dave Hansen <dave.hansen@...ux.intel.com>, 
	Andy Lutomirski <luto@...nel.org>, Arnd Bergmann <arnd@...db.de>, Nathan Chancellor <nathan@...nel.org>, 
	Nick Desaulniers <ndesaulniers@...gle.com>, Justin Stitt <justinstitt@...gle.com>, 
	Kees Cook <keescook@...omium.org>, Brian Gerst <brgerst@...il.com>, linux-arch@...r.kernel.org, 
	llvm@...ts.linux.dev
Subject: Re: [PATCH v4 02/11] x86/startup_64: Replace pointer fixups with
 RIP-relative references

On Sat, 17 Feb 2024 at 13:51, Borislav Petkov <bp@...en8.de> wrote:
>
> On Tue, Feb 13, 2024 at 01:41:46PM +0100, Ard Biesheuvel wrote:
> > @@ -201,25 +201,19 @@ unsigned long __head __startup_64(unsigned long physaddr,
> >       load_delta += sme_get_me_mask();
> >
> >       /* Fixup the physical addresses in the page table */
> > -
> > -     pgd = fixup_pointer(early_top_pgt, physaddr);
> > -     p = pgd + pgd_index(__START_KERNEL_map);
> > -     if (la57)
> > -             *p = (unsigned long)level4_kernel_pgt;
> > -     else
> > -             *p = (unsigned long)level3_kernel_pgt;
> > -     *p += _PAGE_TABLE_NOENC - __START_KERNEL_map + load_delta;
> > -
> >       if (la57) {
> > -             p4d = fixup_pointer(level4_kernel_pgt, physaddr);
> > -             p4d[511] += load_delta;
> > +             p4d = (p4dval_t *)&RIP_REL_REF(level4_kernel_pgt);
> > +             p4d[MAX_PTRS_PER_P4D - 1] += load_delta;
> >       }
> >
> > -     pud = fixup_pointer(level3_kernel_pgt, physaddr);
> > -     pud[510] += load_delta;
> > -     pud[511] += load_delta;
> > +     pud = &RIP_REL_REF(level3_kernel_pgt)->pud;
> > +     pud[PTRS_PER_PUD - 2] += load_delta;
> > +     pud[PTRS_PER_PUD - 1] += load_delta;
> > +
> > +     pgd = &RIP_REL_REF(early_top_pgt)->pgd;
>
> Let's do the pgd assignment above, where it was so that we have that
> natural order of p4d -> pgd -> pud ->pmd etc manipulations.
>

pud and p4d need to be assigned first, unless we want to keep taking
the addresses of level4_kernel_pgt and level3_kernel_pgt twice as
before.

> > +     pgd[PTRS_PER_PGD - 1] = (pgdval_t)(la57 ? p4d : pud) | _PAGE_TABLE_NOENC;
>
> I see what you mean with pgd_index(__START_KERNEL_map) always being 511
> but this:
>
>         pgd[pgd_index(__START_KERNEL_map)] = (pgdval_t)(la57 ? p4d : pud) | _PAGE_TABLE_NOENC;
>
> says exactly what gets mapped there in the pagetable while
>
>         PTRS_PER_PGD - 1
>
> makes me wonder what's that last pud supposed to map.
>

Fair enough. But the same applies to p4d[] and pud[].

> Other than that, my gut feeling right now is, this would need extensive
> testing so that we make sure there's no fallout from it.
>

More testing is always good, but I am not particularly nervous about
these changes.

I could split this up into 3+ patches so we could bisect any resulting
issues more effectively.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ