Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3020936imu; Mon, 19 Nov 2018 09:27:30 -0800 (PST) X-Google-Smtp-Source: AJdET5e/45WpO0tpsCaA3kfrBluTi+3HNAUGkOyfcxoTjlQKEIlRrxdxCFCd3hFdN+KmbWnIAemZ X-Received: by 2002:a63:7556:: with SMTP id f22mr19349886pgn.231.1542648450541; Mon, 19 Nov 2018 09:27:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542648450; cv=none; d=google.com; s=arc-20160816; b=UFG3RzFfayoOLnmHVEr3IUfC8RQnzKc55LTQyw9EHc+ekkg4HClWjRTjCWxF8B1JVc 3y24sydV3SQGrM61ctWLgKnm9skZbykL8tOr7wAG8sP8IV7N+EE9Yxf7GPxaHAHdpty/ Bv95IqWh+FAx5exAzac6ME6kHtE9NxoS8gvqbvt+sZvSxXWxTZr2DDmkHm/OQmR7Bndu jxlFj6htPm2b//A9XS1Zw9l28CMnWtLuT7uJC5XEkeN3sGiGPlIcsj88ysCi2zB5rOUY pv9ZkDZffjckNasMDUA8fPBVJZ2mQHQbE2olbN3VLNGoVbPqB873ztrMInXUmlsPClfG xZ/Q== 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=+yo36w+GHyIPEd8xM2yg9ct3bXf/RQYM+KgRzxi7oD4=; b=WuZQ4IAkH8fvU8nj4GK2OTkpLMMzEzKBwPwpryRXWXwj8fR2i0kaU3PzmR1E1cNW1F Hq/Z4B8DXkXMYcELjbmXY2qA9+RZCd3zQJUAFtqqvF0IRXeeJXulxRvXBCqhzAiLYLwI q4a/BUiREhnPtOmtjWBC0mvqNDVrOe9NyU3303l/G2CIHls6q4yxAlEGmUtNt6Ee8KqB p+JHKv/a0iLwYaIZ4mEJWdKhrIpKWMEEJvClKPBfbu/cqZn9TpivhVwoIW4srn29/5Oh M4nsMzRzPlHDIccOxIDbBp7PmBpTEEmX9g7qDEseuBpJvpsyTpE9Gtfiv5Extv2PDQiz U/HA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E5qKwrKR; 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 t136si10722317pfc.262.2018.11.19.09.27.04; Mon, 19 Nov 2018 09:27:30 -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=E5qKwrKR; 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 S2404486AbeKTDVb (ORCPT + 99 others); Mon, 19 Nov 2018 22:21:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:32882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390762AbeKTDV2 (ORCPT ); Mon, 19 Nov 2018 22:21:28 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 454A6206BA; Mon, 19 Nov 2018 16:57:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646633; bh=UyAbYr9XwUo2UmS8FJvZuPtrGiO/bOk3iiV6GNe8sJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E5qKwrKRhJ6bPvVgxwa46XZ3C2qL5q0W8n2eO854btta3VB9VrwKMU1jJZS1HBkJ1 L9vtfAsOdp6dttDv012/6yPUplcMhzpwjJsmkFie+FIxRajL0tGzmk3X9cNQEZmk2m O6itHgQ3ltNjS5ppG9bpVs+NaxbIocyh+Et0B4Hg= 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.4 024/160] x86: boot: Fix EFI stub alignment Date: Mon, 19 Nov 2018 17:27:43 +0100 Message-Id: <20181119162632.968406821@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162630.031306128@linuxfoundation.org> References: <20181119162630.031306128@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.4-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;