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:   Wed, 7 Jun 2023 21:39:21 +0200
From:   Ard Biesheuvel <ardb@...nel.org>
To:     Borislav Petkov <bp@...en8.de>
Cc:     linux-efi@...r.kernel.org, linux-kernel@...r.kernel.org,
        Evgeniy Baskov <baskov@...ras.ru>,
        Andy Lutomirski <luto@...nel.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        Ingo Molnar <mingo@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Alexey Khoroshilov <khoroshilov@...ras.ru>,
        Peter Jones <pjones@...hat.com>,
        Gerd Hoffmann <kraxel@...hat.com>,
        Dave Young <dyoung@...hat.com>,
        Mario Limonciello <mario.limonciello@....com>,
        Kees Cook <keescook@...omium.org>,
        Tom Lendacky <thomas.lendacky@....com>,
        "Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Joerg Roedel <jroedel@...e.de>
Subject: Re: [PATCH v5 01/20] x86/efistub: Branch straight to kernel entry
 point from C code

On Wed, 7 Jun 2023 at 20:53, Borislav Petkov <bp@...en8.de> wrote:
>
> On Wed, Jun 07, 2023 at 09:23:23AM +0200, Ard Biesheuvel wrote:
> > -     return bzimage_addr;
> > +     if (IS_ENABLED(CONFIG_X86_64))
> > +             /* add offset of startup_64() */
> > +             bzimage_addr += 0x200;
>
> Uh, magic.
>
> Well, there's this:
>
> arch/x86/boot/compressed/head_64.S:
>
>         .code64
>         .org 0x200
> SYM_CODE_START(startup_64)
>         /*
>          * 64bit entry is 0x200 and it is ABI so immutable!
>          * We come here either from startup_32 or directly from a
>          * 64bit bootloader.
>
>
> Looking at Documentation/arch/x86/boot.rst, we actually say in the
> xloadflags section:
>
>   Bit 0 (read): XLF_KERNEL_64
>
>         - If 1, this kernel has the legacy 64-bit entry point at 0x200.
>
> and header.S sets that:
>
> xloadflags:
> #ifdef CONFIG_X86_64
> # define XLF0 XLF_KERNEL_64                     /* 64-bit kernel */
>
> so you checking CONFIG_X86_64 is probably ok.
>
> It might be cleaner, though, if you test XLF_KERNEL_64 directly and act
> accordingly, although, do I understand it correctly, that the EFI
> libstub goes together with the kernel it was built for so the checks
> would be doing the same thing...? I.e., the libstub cannot be somehow
> "glued" with another kernel or so, which doesn't set CONFIG_X86_64.
>

This code gets removed again later in the series, so i didn't bother
with any of this.

I think checking those XLF flags from code is something to avoid in
any case - it is part of the file representation, and consumed by
loaders. I am not sure we can assume that they are always accessible
from the running code (and EFI is not guaranteed to load the first
sector as this is the file header not the payload)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ