Message ID | 20200731230820.1742553-34-keescook@chromium.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <SRS0=15xB=BL=lists.infradead.org=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@kernel.org> Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D885E1575 for <patchwork-linux-arm@patchwork.kernel.org>; Sat, 1 Aug 2020 01:05:48 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B14FA2076B for <patchwork-linux-arm@patchwork.kernel.org>; Sat, 1 Aug 2020 01:05:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cAxucMP1"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="F+PwLeUK"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="erx5/Jpq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B14FA2076B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=GKwgcLF1y0aEAnfQyi8KoTeD1PAgPCxSE0+X4MbAWAQ=; b=cAxucMP1JQJuNqQaq70eZrQP+ WiR/VOzJ+/K78SoIYZwuJWsXrRzID9P0DJ3+XXks45j3ke5mm9UL7henHrHmQsNOTASjbSX08U1tX 9uKG1WagZHGuwjsDpc0sEd2z3XBbxu30KM4uLhDD8+aZ4rT3ENAIb/QOdUYEjJ0IuUWYvb36F7GXS 8MwNeFqYTFDFt2RPUdR3ocsAhrP3npFqHqgF9kU0oqUyAgvqejvG3bhg9sPIAt3zFOKw5ZuUVSl5/ mafI899ngZ62uTYqyxh54lB/G7moUJ4GWxmvcOp+eZ8c/9BHDpw1fVWIgw6xAvnTTX/KHeG0OOKFv 3fywYdwlQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1eDB-0001eg-BP; Fri, 31 Jul 2020 23:13:13 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1e99-0008I8-Ig for linux-arm-kernel@merlin.infradead.org; Fri, 31 Jul 2020 23:09:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=8vhxEY/3GLUdito3wLDKhA5WtBC+SXdkXa/hytPCigE=; b=F+PwLeUKK8YlB+UWdepcbl8BNz Up40wGrYEjzLw/iuxJ1slgcLpLJVizWxIrev4G8eLJGRTCvTUy7kgW358mMhXkY+HBhMAdYJjEwEf C1vlzN5mEKr3D2698ni4H9WcgHKhvdazqcbKHzf3o9bWYILPcXJZK+tM+6DPVSwElsZGaaxtrRNvj z1xAMWa/1bF3DW9KChNK7qvg9kAQGr7i3FEEgaGMi/RgYVuYEKxMVQU7o452fJtpyZnZ9o9rjEluQ vKZwnnLPfKHcjjjWwHB7rqlVQISmFO9j5EPwzDdxhpKrJPFzWPRHqx9GJxYkmjRV49nDNsDkjmVqx NTwufMrw==; Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1e8y-0000aA-9a for linux-arm-kernel@lists.infradead.org; Fri, 31 Jul 2020 23:09:02 +0000 Received: by mail-pf1-x42b.google.com with SMTP id m8so8322510pfh.3 for <linux-arm-kernel@lists.infradead.org>; Fri, 31 Jul 2020 16:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8vhxEY/3GLUdito3wLDKhA5WtBC+SXdkXa/hytPCigE=; b=erx5/JpqhPcqTt2NRt7KYL2WjFYzLuGG8P3y0Er3rEKdM9crkTPu/ZeFlU0GCIVOMc DiuJnOx0TWdOG3xCGBDcbldLx8jiF9vR+PM5/8GcMbuuzJl25XeRIG6137MXRlGMlfwL YRvGL0llW8thsScXCRcN7FWXAu5q57sDHshm8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8vhxEY/3GLUdito3wLDKhA5WtBC+SXdkXa/hytPCigE=; b=Pu34dnMai1YsJ1o0vf+D+Z/aVTzcUoLZPsT9QhaNpR74o6rRlS0UVy9vawjIooiKk2 Qu0sEbicNueItvqyQM6XY8xo2fQTgVtWpC7iLl2f0+hbdIs4bQj+eQgu+f2T46hwqH1T FAOzDYNC1mnqAdP3mDzkAQXjbxO1HzUB49iX1L7CDE/eEJs3JKVdQ1Op+K7BkXNBbywV IXrrzabyq8bxRpJ+a+Q2VnYgukd/ajtxytPwaNMTLE8vkzFMZ+P0IzlrHcX23966W8On oIPf9NJUq3WgyeTRrdY6xpdX9Th9EPomuqqnhYJf600pT2JJO45yJEvVq6V7JD0iHqyj ttNw== X-Gm-Message-State: AOAM533DhxvnLfbgUZJwVwiiejlCtdzrHR8D+dUUQQZ1jhLVyBJyXml5 ZMghxCbQ+RvdD3uAAYrtkcvJdA== X-Google-Smtp-Source: ABdhPJyLpLDveshlbN8sTzxQNU2pIN2ioMmjwXEATDhMsYZvm7qIKteqmlw+pfo4TpnxoNFX69boWQ== X-Received: by 2002:a65:6644:: with SMTP id z4mr5848694pgv.391.1596236928153; Fri, 31 Jul 2020 16:08:48 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id k21sm8098390pgl.0.2020.07.31.16.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 16:08:44 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Thomas Gleixner <tglx@linutronix.de>, Will Deacon <will@kernel.org> Subject: [PATCH v5 33/36] x86/boot/compressed: Remove, discard, or assert for unwanted sections Date: Fri, 31 Jul 2020 16:08:17 -0700 Message-Id: <20200731230820.1742553-34-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200731230820.1742553-1-keescook@chromium.org> References: <20200731230820.1742553-1-keescook@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200801_000853_189398_FDEF30D3 X-CRM114-Status: GOOD ( 14.70 ) X-Spam-Score: -2.1 (--) X-Spam-Report: SpamAssassin version 3.4.4 on casper.infradead.org summary: Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42b listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Cc: Mark Rutland <mark.rutland@arm.com>, linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, Kees Cook <keescook@chromium.org>, Arnd Bergmann <arnd@arndb.de>, Catalin Marinas <catalin.marinas@arm.com>, Masahiro Yamada <masahiroy@kernel.org>, x86@kernel.org, Nick Desaulniers <ndesaulniers@google.com>, Russell King <linux@armlinux.org.uk>, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Arvind Sankar <nivedita@alum.mit.edu>, Ingo Molnar <mingo@redhat.com>, James Morse <james.morse@arm.com>, Nathan Chancellor <natechancellor@gmail.com>, Borislav Petkov <bp@suse.de>, Peter Collingbourne <pcc@google.com>, Ard Biesheuvel <ardb@kernel.org>, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org |
Series |
Warn on orphan section placement
|
expand
|
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 96d53e300ab6..43b49e1f5b6d 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile @@ -49,6 +49,7 @@ GCOV_PROFILE := n UBSAN_SANITIZE :=n KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE) +KBUILD_LDFLAGS += $(call ld-option,--no-ld-generated-unwind-info) # Compressed kernel should be built as PIE since it may be loaded at any # address by the bootloader. LDFLAGS_vmlinux := -pie $(call ld-option, --no-dynamic-linker) diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S index 42dea70a5091..1fb9809a9e61 100644 --- a/arch/x86/boot/compressed/vmlinux.lds.S +++ b/arch/x86/boot/compressed/vmlinux.lds.S @@ -83,6 +83,11 @@ SECTIONS ELF_DETAILS DISCARDS + /DISCARD/ : { + *(.dynamic) *(.dynsym) *(.dynstr) *(.dynbss) + *(.hash) *(.gnu.hash) + *(.note.*) + } /* * Sections that should stay zero sized, which is safer to @@ -93,13 +98,18 @@ SECTIONS } ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") + .plt (NOLOAD) : { + *(.plt) *(.plt.*) + } + ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!") + /* ld.lld does not like .rel* sections being made "NOLOAD". */ .rel.dyn : { - *(.rel.*) + *(.rel.*) *(.rel_*) } ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!") .rela.dyn : { - *(.rela.*) + *(.rela.*) *(.rela_*) } ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!") }
In preparation for warning on orphan sections, stop the linker from generating the .eh_frame* sections, discard unwanted non-zero-sized generated sections, and enforce other expected-to-be-zero-sized sections (since discarding them might hide problems with them suddenly gaining unexpected entries). Signed-off-by: Kees Cook <keescook@chromium.org> --- arch/x86/boot/compressed/Makefile | 1 + arch/x86/boot/compressed/vmlinux.lds.S | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)