Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp186535ybm; Wed, 27 May 2020 23:37:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0v3ZH6wROfqHpm3b2uXLo2HPl9X9/ebq2dvB2Ox//J/7pASVMeYw23Jkf006HQxC7YHz+ X-Received: by 2002:a50:abe3:: with SMTP id u90mr1553160edc.278.1590647878912; Wed, 27 May 2020 23:37:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590647878; cv=none; d=google.com; s=arc-20160816; b=EXx2EB4sip5ajnUuMmfn8icy8Tkr/TOfGnG487hZMPI6VkcdzUJ5vHvHKTWs/CBXtc CZrtBPaZshXASlAcj/suEIYf+TYL/aGIzkg49c6eLz0uju070FkY5vhGtRvo3aslNgpO xi2lL86Cs/koUZa85IOt+XAcpBRrlXNZRbSeXkgrhSyJm9xxwp9bONnFPtk11S/6YJXm ktmBwQrM9R+FudbGIgsXOX6KqQWkT7Jfkkp9T/10ODGNSy8xMln7P5nByLwFw480n8u9 mhFkfPFwflABU7XOlFDut7B7nJUo6U5RdHbyTxx1oxLmZNSxgAX2gcECYa9o5uu5AKzh Ty7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=t1PTINs6NjXMS2KCUhdqpJTmmsKz6YWqmpcqHa0KRhs=; b=DsfLzOwg5GbNQFRsJTFg6PEx2ICXvT40s2Ko0Pxy7pEmQqWTCjxDvHaO6TiBcud0oj /aoN6JBB+i/juFEdQSdsKsmvZd+cnrDpGw4BtHo7b+F0qgoW7fNBhEVrDjPfLKrLT0EP ATRVbN80f09J4dtcL3vgR1Jkzap/cvqAQkcnpDB6CFESAVEvwax1JK5zQTUcEkdXGKsI Hb4MznQpfXAIQgU0IITL4o47RsbpfAZkBLMNla5gzWcGOqA95R47DpK8XYUYDpdIEY/O zlgyIAM9qEzCOgOd9asSYoTy4KSx4g5epMwhcoWk3GWhMJA/382jgqzU1OqX2rkf8FjZ wbQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hBkGKwKa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r20si2916540eja.234.2020.05.27.23.37.35; Wed, 27 May 2020 23:37:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hBkGKwKa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725859AbgE1GfE (ORCPT + 99 others); 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-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 >