[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMj1kXH+FAdSbM7BEmMY7KOKnuUetx8zo42zPuhfnmf206AunQ@mail.gmail.com>
Date:   Thu, 28 May 2020 08:34:50 +0200
From:   Ard Biesheuvel <ardb@...nel.org>
To:     Arvind Sankar <nivedita@...m.mit.edu>,
        Stephen Rothwell <sfr@...b.auug.org.au>,
        Borislav Petkov <bp@...en8.de>
Cc:     Dan Williams <dan.j.williams@...el.com>,
        Ingo Molnar <mingo@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-efi <linux-efi@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] efi/x86: Don't blow away existing initrd
(+ Stephen, Boris)
On Thu, 28 May 2020 at 01:26, Arvind Sankar <nivedita@...m.mit.edu> wrote:
>
> Commit
>   987053a30016 ("efi/x86: Move command-line initrd loading to efi_main")
> moved the command-line initrd loading into efi_main, with a check to
> ensure that it was attempted only if the EFI stub was booted via
> efi_pe_entry rather than the EFI handover entry.
>
> However, in the case where it was booted via handover entry, and thus an
> initrd may have already been loaded by the bootloader, it then wrote 0
> for the initrd address and size, removing any existing initrd.
>
> Fix this by checking if size is positive before setting the fields in
> the bootparams structure.
>
> Fixes: 987053a30016 ("efi/x86: Move command-line initrd loading to efi_main")
> Reported-by: Dan Williams <dan.j.williams@...el.com>
> Tested-by: Dan Williams <dan.j.williams@...el.com>
> Signed-off-by: Arvind Sankar <nivedita@...m.mit.edu>
Reviewed-by: Ard Biesheuvel <ardb@...nel.org>
Apologies to all for the breakage, and for not catching this in review.
Ingo, Thomas, Boris: please apply this directly to efi/core asap.
Stephen: gives that this breaks the boot for a lot of people, you
might want to pull this into -next directly.
Thanks,
Ard.
> ---
>  drivers/firmware/efi/libstub/x86-stub.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
> index 072b7cf40475..ceb8e16c8b75 100644
> --- a/drivers/firmware/efi/libstub/x86-stub.c
> +++ b/drivers/firmware/efi/libstub/x86-stub.c
> @@ -774,10 +774,12 @@ unsigned long efi_main(efi_handle_t handle,
>                         efi_err("Failed to load initrd!\n");
>                         goto fail;
>                 }
> -               efi_set_u64_split(addr, &hdr->ramdisk_image,
> -                                 &boot_params->ext_ramdisk_image);
> -               efi_set_u64_split(size, &hdr->ramdisk_size,
> -                                 &boot_params->ext_ramdisk_size);
> +               if (size > 0) {
> +                       efi_set_u64_split(addr, &hdr->ramdisk_image,
> +                                         &boot_params->ext_ramdisk_image);
> +                       efi_set_u64_split(size, &hdr->ramdisk_size,
> +                                         &boot_params->ext_ramdisk_size);
> +               }
>         }
>
>         /*
> --
> 2.26.2
>
Powered by blists - more mailing lists
 
