Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3486911imu; Sun, 11 Nov 2018 16:12:07 -0800 (PST) X-Google-Smtp-Source: AJdET5eMIwyLCso/BXTFcRU/Ad2Y2e5KHLxhafIGjE42Mu2fXSjxDS5yj54VoZ4iD+ZUXpJY0F4J X-Received: by 2002:a63:dd55:: with SMTP id g21mr2629181pgj.86.1541981527597; Sun, 11 Nov 2018 16:12:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981527; cv=none; d=google.com; s=arc-20160816; b=nNlbqgfDICsNfwDwTE9wvIVMb5KP4g4qUhWqA63eTTORQQgjRFAaKvc/RNQV8jhWIn cyVyhBEvX6lb2lAQsb0cxt5AM78TCyKAJtwiHCxiflB5MmQrX47in4hH/VQtYl+Tmbcv ZQyeStEIUMuC7LVWnp+cLAUUz4MO1Ux55gxPYigkdmTmvSuADiMHIzJ+Fy6gd+VIRNJI zOJc1jp1rXhgLfqRpWK8GDyWOvw2mwOwVzzKaY3sTipU+fEpimMdIzR38XEJP6Uc3c6G zaUYKZdU16B15wvwbv8uarZwBmwSiuqqHclynQoVI5UGoC+lcB8Pr1BaoTG+Yiehjow3 1Hkg== 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=YKtlRRQfJlN5KQT3hiqLbKu/EiBjj70wmOBQDw5yVxY=; b=iFx4rD7RrZC6EHHHMEvimbkegKrBolcllxUA4s6n4qy2FFDj4M5xtMplGY09No8Y3H YZzCHZL0DI6qyPcLVwkIs7a4o/YXFIfXWqInVuPMW0cELVQIQpYDfX9Yy9gmhdRHlWBp 5n7hOgTFeOkTgneX+MmgTTAA62aXW8d1o0V1CfcYXdxQC/WocQ5OvjdkfELYtqGwDEPh DTL6sInhF3VaYk2BHa0KA6n8b3zy59Uell6jLuTybVkc5DxOs/LcCKKnpm4WAbH0K5YQ sHbehYZceZe+1It4AwBB+qdXFRhJAUAMM40pnR3/lWYBG71095gNQjAP4Aaiu0PM4fB0 yMJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cYNZYELe; 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 s192si15058422pgc.144.2018.11.11.16.11.52; Sun, 11 Nov 2018 16:12:07 -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=cYNZYELe; 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 S1730685AbeKLIRV (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:60734 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730601AbeKLIRU (ORCPT ); Mon, 12 Nov 2018 03:17:20 -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 9081D21582; Sun, 11 Nov 2018 22:27:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975244; bh=ilCo/euLNic/OVhVdK9d1TS4JCBiabVSwo2Wzg50YE4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cYNZYELehdPdBt/Ge7ys/1pAOS5o/yxQ0gGKB+cm7e0YRR5A21XUB22MhUY1u1u69 VHVmzOHHNgr5SMXDHZqLE20o5SG7TWDdSRxrMeu1Uhk0GSzSJxRKJiBihB/55MaIJ4 11wbfQOppD+LTiOEodsw0vJMzj2LJaLbcatfudnM= 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.19 094/361] x86: boot: Fix EFI stub alignment Date: Sun, 11 Nov 2018 14:17:21 -0800 Message-Id: <20181111221632.942122619@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@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.19-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;