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: <CAMj1kXEDPwORj=oeQJ66FVD6WMjpxWiXX1Y317izHzRH1c1ncw@mail.gmail.com>
Date:   Fri, 22 Oct 2021 16:48:31 +0200
From:   Ard Biesheuvel <ardb@...nel.org>
To:     Tom Lendacky <thomas.lendacky@....com>
Cc:     Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        X86 ML <x86@...nel.org>, linux-efi <linux-efi@...r.kernel.org>,
        platform-driver-x86@...r.kernel.org,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H. Peter Anvin" <hpa@...or.com>,
        Darren Hart <dvhart@...radead.org>,
        Andy Shevchenko <andy@...radead.org>,
        Matt Fleming <matt@...eblueprint.co.uk>,
        "# 3.4.x" <stable@...r.kernel.org>
Subject: Re: [PATCH] x86/sme: Explicitly map new EFI memmap table as encrypted

On Thu, 21 Oct 2021 at 15:21, Tom Lendacky <thomas.lendacky@....com> wrote:
>
> On 10/20/21 1:02 PM, Tom Lendacky wrote:
> > Reserving memory using efi_mem_reserve() calls into the x86
> > efi_arch_mem_reserve() function. This function will insert a new EFI
> > memory descriptor into the EFI memory map representing the area of
> > memory to be reserved and marking it as EFI runtime memory. As part
> > of adding this new entry, a new EFI memory map is allocated and mapped.
> > The mapping is where a problem can occur. This new memory map is mapped
> > using early_memremap() and generally mapped encrypted, unless the new
> > memory for the mapping happens to come from an area of memory that is
> > marked as EFI_BOOT_SERVICES_DATA memory.

This bit already sounds dodgy to me. At runtime, anything provided by
the firmware that needs to be mapped unencrypted should be
identifiable as such, regardless of the memory type. So why is there a
special case for BS data?

> > In this case, the new memory will
> > be mapped unencrypted. However, during replacement of the old memory map,
> > efi_mem_type() is disabled, so the new memory map will now be long-term
> > mapped encrypted (in efi.memmap), resulting in the map containing invalid
> > data and causing the kernel boot to crash.
> >
> > Since it is known that the area will be mapped encrypted going forward,
> > explicitly map the new memory map as encrypted using early_memremap_prot().
> >
> > Cc: <stable@...r.kernel.org> # 4.14.x
> > Fixes: 8f716c9b5feb ("x86/mm: Add support to access boot related data in the clear")
> > Signed-off-by: Tom Lendacky <thomas.lendacky@....com>
> > ---
> >   arch/x86/platform/efi/quirks.c | 3 ++-
> >   1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
> > index b15ebfe40a73..b0b848d6933a 100644
> > --- a/arch/x86/platform/efi/quirks.c
> > +++ b/arch/x86/platform/efi/quirks.c
> > @@ -277,7 +277,8 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size)
> >               return;
> >       }
> >
> > -     new = early_memremap(data.phys_map, data.size);
> > +     new = early_memremap_prot(data.phys_map, data.size,
> > +                               pgprot_val(pgprot_encrypted(FIXMAP_PAGE_NORMAL)));
>
> I should really have a comment above this as to why this version of the
> early_memremap is being used.
>
> Let me add that (and maybe work on the commit message a bit) and submit a
> v2. But I'll hold off for a bit in case any discussion comes about.
>

For the [backported] change itself (with the comment added)

Acked-by: Ard Biesheuvel <ardb@...nel.org>

but I'd still like to understand if we can improve the situation with BS data.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ