From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ED7DC433DF for ; Thu, 28 May 2020 06:35:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E7D7207D3 for ; Thu, 28 May 2020 06:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590647705; bh=NuGCPmxAGBI2XK8Nm9wCfXWioEgp2KAM821Yx4GB6vY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=fouKaMM3c22N+nyAQoftFRoJudpTVUHF7jjnhI+1DOBQ4O3IfhB6r966EzgiZ3fvJ 8tuM7qsu1M6hWo5suI/FOX2T8rbF+wplgwIueO49+LAHSFZV1EieftCmKkGr3Pc60t dSfVNetBfngJ+IhGrnZo4r7VP/9LwCjdIStaQHRE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726036AbgE1GfE (ORCPT ); Thu, 28 May 2020 02:35:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:40382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725601AbgE1GfD (ORCPT ); Thu, 28 May 2020 02:35:03 -0400 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 00181207D3; Thu, 28 May 2020 06:35:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590647703; bh=NuGCPmxAGBI2XK8Nm9wCfXWioEgp2KAM821Yx4GB6vY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=hBkGKwKaOLoXTSF2wTsqB3XRiFaK9iNxYq4NWm8JGcWnlrm4CKncsJCylmJkXMdel SpQ/qZUXC0Z78TuhINGVMQ94Vu/RvBi4+0KYrIyOZwediIFmRY+Jv7Aol/OfdTUDgr ytFM2BNE7Bjq5YA7WBPLJRAsmyTMb3b37fqQLi+A= Received: by mail-io1-f42.google.com with SMTP id c8so8427529iob.6; Wed, 27 May 2020 23:35:02 -0700 (PDT) X-Gm-Message-State: AOAM530keRgFmV+8xsMlkiuBRXWK+Xl3Celi6A4oK95yBvx2H1WGzyZP ZO8jxFC6M0ONnrHek7cB6Guba1khrm9VUVUpjhM= X-Google-Smtp-Source: ABdhPJznn4Cx3G1U8IfKievX2GTQvjlLB94d6qrtuij0ra7aauuhDyzjASGycwEt2xh3e/kXI5QpCJHBTCdgwh4eNYM= X-Received: by 2002:a02:3341:: with SMTP id k1mr1322375jak.74.1590647702377; Wed, 27 May 2020 23:35:02 -0700 (PDT) MIME-Version: 1.0 References: <20200527232602.21596-1-nivedita@alum.mit.edu> In-Reply-To: <20200527232602.21596-1-nivedita@alum.mit.edu> From: Ard Biesheuvel Date: Thu, 28 May 2020 08:34:50 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] efi/x86: Don't blow away existing initrd To: Arvind Sankar , Stephen Rothwell , Borislav Petkov Cc: Dan Williams , Ingo Molnar , Thomas Gleixner , linux-efi , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org (+ Stephen, Boris) On Thu, 28 May 2020 at 01:26, Arvind Sankar 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 > Tested-by: Dan Williams > Signed-off-by: Arvind Sankar Reviewed-by: Ard Biesheuvel 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 >