Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3116911imu; Mon, 19 Nov 2018 10:52:42 -0800 (PST) X-Google-Smtp-Source: AJdET5f8830gqa/Z9gDCTlU/Lfl/qw81OrauSIOE2GVyZMS6ev1yvmPn+ynwDCljwPHdrhsbHeBp X-Received: by 2002:a17:902:6185:: with SMTP id u5mr22352966plj.194.1542653562801; Mon, 19 Nov 2018 10:52:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653562; cv=none; d=google.com; s=arc-20160816; b=zqnopznAFag2SIrzlFRyXDZD8m+ixwGPGbcqQZHLM5WrscFzg9RhhopM7F/8x8bSFz 5l5LTZFieo8Us1wqC3nE8o4uZcENGu0Cw32UEfNAf8skCLPPVO0dRG4oaMgkEpa7AYfj jHdC10PYd8P1e1LlxiXzRxQP19fNtcjQCwOMdY66/ImPpJIuhBu6atHcpWCMqIUbeIBB oWjAgubOKE34vygW6Texrfk/zxpC6JofOD9tyOdeePc3tt7Z9lHeQSQP9v8lOmhaDtk6 PZSWfxfhs8wJvkXjTCgcj6jyBuAgMNsYYYGYTbXl2hcotuvW7qnrirz9pAmFX3RDVJfe 8nXQ== 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=mf62A1JodLN5Bn4jCpI4HS8qzdKSc/PjSxQP4H/Lfis=; b=xoFs+2SQJjrglNayI2fueRbcb2meZEIZ5G6okUNs833r99pSrLu6Bmjj4tqtUTNBLi 1ITyN/8X9CkhQqioeQzIX+JZO3KN5m18vsr/NXqNR68wpLgmgZvOryF8sf4L7dwUWT/S DjuwFLxio3ZqLEceqI5aY0JEh+Xp+tYhV28n4S590/PudM+0wOVLffrMfosaBUE5lyys 3yNMb9JwPssb7cVQY1zTEhmnnroOfxNrE+QRU04gsIEhilwklWIjCPqKG9mOeAS4KQBW VN8Ln+CbxHiY2M5IVfUB2h4G//5/g/ejv+8Qp0ksWDhztVsxDa+GWEJV3+hAWhYtYh7x V/Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pVisua2t; 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 v63-v6si44852914pfb.67.2018.11.19.10.52.28; Mon, 19 Nov 2018 10:52:42 -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=pVisua2t; 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 S2406306AbeKTD1y (ORCPT + 99 others); Mon, 19 Nov 2018 22:27:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:42078 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405677AbeKTD1x (ORCPT ); Mon, 19 Nov 2018 22:27:53 -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 56968214E0; Mon, 19 Nov 2018 17:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542647016; bh=XdLkS/VBoRwLRITJZw1CyLbTNqEGCBWVbQhkn9dszzw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pVisua2tmdJwPiy4ON/i+erULldtxjrZY5dKINcBss4WB732SbvthEfmcmV66wL6e 0A0VCYSCjSBUkaorDyoMvDodh4oe7vDDE24UXFvHu4MiQuGAtOeQSzOIVjSGLbPDy8 yPVr0rbr/WglRz4D3mr5/1KnLSwixFExevGOKhYs= 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 3.18 19/90] x86: boot: Fix EFI stub alignment Date: Mon, 19 Nov 2018 17:29:01 +0100 Message-Id: <20181119162624.026267991@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162620.585061184@linuxfoundation.org> References: <20181119162620.585061184@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 3.18-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;