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=ham 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 2C371C433E0 for ; Sat, 1 Aug 2020 00:03:15 +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 E986620829 for ; Sat, 1 Aug 2020 00:03:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CA71qxVT"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="E16hD+pF"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="dE/Lv+CU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E986620829 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=gBpGviUHhyHhc991q1BJ4X0sFK3EY0o/OmDGy0uagdI=; b=CA71qxVTf/YW9FIS64J/tVato vl+N5z8ssbP6C6NH/6hx0wDq86N6wM/MyZamCfwSYjy/vRiSMVTjemlJNiBhrqyWwvwoPRavG1xiT jdSeYu4MsVRNKiIJrtaHhZ7MzkaRMgzRpZcnTp35dxyW4XcXVGKM/DU6mHaT7iyRZ+UsM+wokOfJY gymMGLoxJil+B0kpR9Mpp6qXO0hge/ZZ77JctexPTgf9LWl8pABcepKttN9CGsyI6YllAFqELWFJL Cy2ml9MYAjx/Un1dxIwNZKT8yT0Lef7c0U0dVjw9uuN0tInvcMHMQFu9LAabhYPi2UYVjNBiFHvCr z2WFdIKfA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1eE2-00027P-5h; Fri, 31 Jul 2020 23:14:07 +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 1k1e9C-0008Iw-0V for linux-arm-kernel@merlin.infradead.org; Fri, 31 Jul 2020 23:09:06 +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=jrAblmr6ozIS72tPylywn6+f+xtS4UhaP8bWtW4yv24=; b=E16hD+pFhqkhoFptwdctDnj6/H 9ee2w0mKhxOlC+1t6NOS6zThp0bU+PHAXTAqnodVTAkjOouxAUUhg0CRWka4IlHTu9S+AJ6jjp3Fb sAsVHV2HptggViz44qlypLAE6e6zHoYqXAyjGqYWQhCOq+7ntRkAZ3jlpkXH5EVWLq0wpeGuusnly LtytYxfMH9kEOmCjeUyWBDhRBx3hqt30+QNwDraqXtwLEe1+CunUvCALjpKFN5MRqXMX7buCyWpu8 yBGfxrnfF3v5w+0ol8BRBEQ9nIgrnid06HViAVMfoAs2YRMnDoQlv/RXQ+PzY8WA9f2oPUmfsHmkk iIyk6DjQ==; Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1e8y-0000aI-Q8 for linux-arm-kernel@lists.infradead.org; Fri, 31 Jul 2020 23:09:04 +0000 Received: by mail-pf1-x441.google.com with SMTP id s26so15178568pfm.4 for ; Fri, 31 Jul 2020 16:08:52 -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=jrAblmr6ozIS72tPylywn6+f+xtS4UhaP8bWtW4yv24=; b=dE/Lv+CUA/T7hFTSyS/prDIBwKu/ji5fc0y2Bvs2zCPUa36aaYuKYtGCWE1TiPc+U5 VmeZKoRZYCjcKC45iW2ezGMhW8mV6FXFni0hFNHu5kzRpTCuDIkn88ZAPH+X6Su8OTPX dsyMxubhpOlOMQIDeQNqP4d+u9LhnVaPCznvQ= 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=jrAblmr6ozIS72tPylywn6+f+xtS4UhaP8bWtW4yv24=; b=BFBLVedC3fAlGSGM1KuaHlYvu8GmWmyRhEYLi6XRE5iMj8mPTGUbTdxn8xRoWKB0s8 NWGBMSC8MScEdcx+sv6ygjNZLju4WQDLze12N6flDhAr2XQ1Qvp3jH22+dIacn7sXqhe pMo2gen0iEHBBZqQzPsjErfsrgtw+xabSst+0+oJC7liFfpp5r6kgskjIMEZsgFGYLxG q9lJUPbDWuFlKrT7ksgJsOId9jgwetDB5PXCDixaucNwlc2y/Uwxj9GaA10VXMz/02/p GHL+nATHMAVwsrzRjVXWSlxSF9c2mVZHnVo4BbZZIXMCwg1CudSlm1C+LojoXtUYedYB D2UQ== X-Gm-Message-State: AOAM531h+8xvWQsxvH08WjxtCZ+fwpTG0BH3LtKAV/7Z9jh2neRuGfZl lXfrIEsuSy27s2zQQxPtRn9fSCtTFsg= X-Google-Smtp-Source: ABdhPJyu/p7gfXhwLLFTUjqcKNpeho/cbat9YHoxOtNjsvvByKqqv61amhieFG04PGKt/BiiHt+iFQ== X-Received: by 2002:a62:6083:: with SMTP id u125mr5816247pfb.286.1596236928921; 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 k4sm7192916pjg.48.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 32/36] x86/boot/compressed: Reorganize zero-size section asserts Date: Fri, 31 Jul 2020 16:08:16 -0700 Message-Id: <20200731230820.1742553-33-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_836620_F5689A76 X-CRM114-Status: GOOD ( 12.66 ) 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 For readability, move the zero-sized sections to the end after DISCARDS and mark them NOLOAD for good measure. Signed-off-by: Kees Cook --- arch/x86/boot/compressed/vmlinux.lds.S | 42 +++++++++++++++----------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S index 3c2ee9a5bf43..42dea70a5091 100644 --- a/arch/x86/boot/compressed/vmlinux.lds.S +++ b/arch/x86/boot/compressed/vmlinux.lds.S @@ -42,18 +42,16 @@ SECTIONS *(.rodata.*) _erodata = . ; } - .rel.dyn : { - *(.rel.*) - } - .rela.dyn : { - *(.rela.*) - } - .got : { - *(.got) - } .got.plt : { *(.got.plt) } + ASSERT(SIZEOF(.got.plt) == 0 || +#ifdef CONFIG_X86_64 + SIZEOF(.got.plt) == 0x18, +#else + SIZEOF(.got.plt) == 0xc, +#endif + "Unexpected GOT/PLT entries detected!") .data : { _data = . ; @@ -85,13 +83,23 @@ SECTIONS ELF_DETAILS DISCARDS -} -ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") -#ifdef CONFIG_X86_64 -ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!") -#else -ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc, "Unexpected GOT/PLT entries detected!") -#endif + /* + * Sections that should stay zero sized, which is safer to + * explicitly check instead of blindly discarding. + */ + .got (NOLOAD) : { + *(.got) + } + ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") -ASSERT(SIZEOF(.rel.dyn) == 0 && SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations detected!") + /* ld.lld does not like .rel* sections being made "NOLOAD". */ + .rel.dyn : { + *(.rel.*) + } + ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!") + .rela.dyn : { + *(.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