From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 750BCC433E0 for ; Sat, 1 Aug 2020 01:05:44 +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 3EDA42064B for ; Sat, 1 Aug 2020 01:05:44 +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 3EDA42064B 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+linux-arm-kernel=archiver.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 ; 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 To: Thomas Gleixner , Will Deacon 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-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, Kees Cook , Arnd Bergmann , Catalin Marinas , Masahiro Yamada , x86@kernel.org, Nick Desaulniers , Russell King , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Arvind Sankar , Ingo Molnar , James Morse , Nathan Chancellor , Borislav Petkov , Peter Collingbourne , Ard Biesheuvel , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- arch/x86/boot/compressed/Makefile | 1 + arch/x86/boot/compressed/vmlinux.lds.S | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) 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!") } -- 2.25.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel