Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3437899imu; Sun, 11 Nov 2018 15:05:41 -0800 (PST) X-Google-Smtp-Source: AJdET5fXeyEl+uMjZ80ZaLiZXk/Uq6bF25hgypHTfjy8B5s7DqI4QlhLnZ/nfUCG8yKP/SHv6NdZ X-Received: by 2002:a17:902:443:: with SMTP id 61-v6mr17321686ple.216.1541977541008; Sun, 11 Nov 2018 15:05:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977540; cv=none; d=google.com; s=arc-20160816; b=NJe/Za7273v7GLTU0CeLcy67Xvtb6xUixdjh097gKTsSwDyIQXPYUfHubhuO//ow6h ABAMrIN1uvsFGYEG4eiODsWbmJE2vRnQmhBuqn8vcPe5eOlK72kNr+J7KZ0vShGulb2P DTeLvuTnbid8AdrNKOfdTR+5ulYxTluGnRkll42FwLCQqCLNaHbApLBNYupru8UoDCJ3 u2Mi1A9vXrQMGVIKzjE7ZjCnnbpTWtdyeQDB0bUxUFC97xZnPVQ/0IS54f88Tj249ASi 3ud16gv0zT1LfZs/NBwvNJ3OJTWRs21jkDw1I2F6LqUyjBn1NwaCyAaaoOnfMKkaO791 OYuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mv4ET0XLWdqGP2X5flm/bY/6TRzgmhDbfgtsrlDZ9Cs=; b=GQwJ0ZX7/1qdhEjWUXZj+b7vaBIsP5jvloSgxLotq330buWn89QbkoteUUh1g+dnCt 7dS0dSFCGseldoELE9FhnasoP3q5/9G3A+B/iFS4zENCIGuHStI8IjQysKtK0q120yCp EvuPv4+gBT1xjiygSDmE6DqARFmZ+Z3CGLsjKe7uyqPQSkmX6vi/K1xr4EJdZNup8vnr 79tSvA59l9n9waQ0CyfgfZOOUWk4SGultoDfaPLdt6PqVjV/EbzhCSz0YmpWLAu0i+18 7PLPaW07ILMQhne3soINKJrTKo9LuO9VCRlc9NcCzyDuVwDdD0bEQVHGntuXbhWPbTEr fcuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jd1nmmDc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12si7802919pgq.26.2018.11.11.15.05.26; Sun, 11 Nov 2018 15:05:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Jd1nmmDc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390477AbeKLIWS (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:51248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390429AbeKLIWQ (ORCPT ); Mon, 12 Nov 2018 03:22:16 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A4A5E223D8; Sun, 11 Nov 2018 22:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975539; bh=yE2/3O1Q2j6bVFh2MdfvGUMML2O6aU0KkQlXlcjVeQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jd1nmmDcVFAuKv1WG5SzrnI5N94p3kWOz6Cxz66V0mPU2UDoDwBwJKG1EFs1x/U2m cZ9Klf6JDhNRny6BwNd4DdiKnsdJU6CvODqingXuJWftKjT+05TeKZ1MjGteJuMMnu iV3RO6/ZLHCwfZjoBKkAxBOO0tqz2S5Xk2bJbbsI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ben Hutchings , Ard Biesheuvel , Sasha Levin Subject: [PATCH 4.14 061/222] x86: boot: Fix EFI stub alignment Date: Sun, 11 Nov 2018 14:22:38 -0800 Message-Id: <20181111221653.451357731@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ben Hutchings [ Upstream commit 9c1442a9d039a1a3302fa93e9a11001c5f23b624 ] We currently align the end of the compressed image to a multiple of 16. However, the PE-COFF header included in the EFI stub says that the file alignment is 32 bytes, and when adding an EFI signature to the file it must first be padded to this alignment. sbsigntool commands warn about this: warning: file-aligned section .text extends beyond end of file warning: checksum areas are greater than image size. Invalid section table? Worse, pesign -at least when creating a detached signature- uses the hash of the unpadded file, resulting in an invalid signature if padding is required. Avoid both these problems by increasing alignment to 32 bytes when CONFIG_EFI_STUB is enabled. Signed-off-by: Ben Hutchings Signed-off-by: Ard Biesheuvel Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/x86/boot/tools/build.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c @@ -391,6 +391,13 @@ int main(int argc, char ** argv) die("Unable to mmap '%s': %m", argv[2]); /* Number of 16-byte paragraphs, including space for a 4-byte CRC */ sys_size = (sz + 15 + 4) / 16; +#ifdef CONFIG_EFI_STUB + /* + * COFF requires minimum 32-byte alignment of sections, and + * adding a signature is problematic without that alignment. + */ + sys_size = (sys_size + 1) & ~1; +#endif /* Patch the setup code with the appropriate size parameters */ buf[0x1f1] = setup_sectors-1;