From patchwork Fri Jul 31 23:08:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 11695585 Return-Path: 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 6A57B138A for ; Fri, 31 Jul 2020 23:13:18 +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 3FA65205CB for ; Fri, 31 Jul 2020 23:13:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="k5DqZ4wG"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="JAuYbSst" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3FA65205CB 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=+3IkmeCk24lBJol0STyN/yK7DK8Q+i7VA7k0k2s32tg=; b=k5DqZ4wG+rOT35gE+zgYoBRN/ H8XJdM2NtkVeD27t1z+D/qcPC4CgB8R74o2mup4xv8JQii+O92Gu+maa1cu41xJ7hxsOFJd7Mc9I0 tCzUXC+flGje6qlyarw4onfpH0UkA5bEXdMDyGf/CEKtTQ+jzhlUUGJZo6Dg1OaJXBPvfDctQkwEW F73lbVE1Ee407iT2CBvcmZfL4A2Ix50uYceVJLbCE6IAOKnvd/71fslHTr6ptGrgbielKd+mtNJTd 89N5S8JPuhzmCwmdvlSwE+OCdWlP2vwPZCGiRX2KFdkPmRDHxpbou9jVk7xJ7VQczjYFv+sU+tZBY 04PXtBCCw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1eCx-0001Xu-L4; Fri, 31 Jul 2020 23:13:01 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1e8y-0008DW-MY for linux-arm-kernel@lists.infradead.org; Fri, 31 Jul 2020 23:09:03 +0000 Received: by mail-pl1-x643.google.com with SMTP id d1so18093831plr.8 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=1/odabPwHQ2/Ek+CjiibQWaFn9uH/zMNlMmZjncvN+I=; b=JAuYbSstQfukYE+Gb0Ne3AWJsz3y+BlIBQzjuLdwl34WW/5cbPcD0t5CHhdrnYt4P3 xCUUA6EqSYHRyEaYtQDNEDCQom38Ssx+gnWJzailUIVVZGprbqvIEm49kDNsHFrs+06/ VGIh/ScEhC/6EEEQyATwr44GVOS6GPHdqpL10= 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=1/odabPwHQ2/Ek+CjiibQWaFn9uH/zMNlMmZjncvN+I=; b=GzPLAZFTSCQ2exV3ikemqojLgyEH+kTTraWoBzBVHUZvZfvKu6tavq/RBlmzF06cjH qahw+hqpJNi0sgdKdmnnXgIeTydBY4BEdppQoRqcJhIDh8RUZOHv6gJv8KgvWSFUVlwV WVoXsA1DgOYD4S2EdMyYhmN0krDyxxcwaGjZuX4NC13byplbgwb3rohpms1J5iXJ8K4J slXvvZrYnzdRUxbjpufWQA4eLARDvbzxV92CMzh5Hn0fYm4TiPJKoAjyXAGV+BLrp3px mSYLdQRtQKt3YZpP9v3UEbNCZhNrCdJZmLaeZFV48ca0hjo07y7tTowAXmPIk/A9tvY8 fcJg== X-Gm-Message-State: AOAM532ynZyh9m11864tQzVoYtWpfavgAGbKkbkTZdrpF5NzJ2s4vWB0 AU61fDrKFlDe5XRdoQhDrRXQZg== X-Google-Smtp-Source: ABdhPJxMsEgUP85f2oRI5I8YFPTSXC9amM4W7Q94F6/Za32NnrZP42b5jtXzGrIuUujHM4rhfoKpRQ== X-Received: by 2002:a17:90a:dc06:: with SMTP id i6mr5914699pjv.161.1596236930832; Fri, 31 Jul 2020 16:08:50 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id b20sm4306905pfo.88.2020.07.31.16.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 16:08:49 -0700 (PDT) From: Kees Cook To: Thomas Gleixner , Will Deacon Subject: [PATCH v5 36/36] arm/build: Assert for unwanted sections Date: Fri, 31 Jul 2020 16:08:20 -0700 Message-Id: <20200731230820.1742553-37-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-20200731_190852_836425_35813CFD X-CRM114-Status: GOOD ( 15.02 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:643 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -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.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: 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In preparation for warning on orphan sections, enforce expected-to-be-zero-sized sections (since discarding them might hide problems with them suddenly gaining unexpected entries). Signed-off-by: Kees Cook --- arch/arm/include/asm/vmlinux.lds.h | 10 ++++++++++ arch/arm/kernel/vmlinux-xip.lds.S | 2 ++ arch/arm/kernel/vmlinux.lds.S | 2 ++ 3 files changed, 14 insertions(+) diff --git a/arch/arm/include/asm/vmlinux.lds.h b/arch/arm/include/asm/vmlinux.lds.h index 6624dd97475c..e0d49fd756f7 100644 --- a/arch/arm/include/asm/vmlinux.lds.h +++ b/arch/arm/include/asm/vmlinux.lds.h @@ -52,6 +52,16 @@ ARM_MMU_DISCARD(*(__ex_table)) \ COMMON_DISCARDS +/* + * Sections that should stay zero sized, which is safer to explicitly + * check instead of blindly discarding. + */ +#define ARM_ASSERTS \ + .plt (NOLOAD) : { \ + *(.iplt) *(.rel.iplt) *(.iplt) *(.igot.plt) \ + } \ + ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!") + #define ARM_DETAILS \ ELF_DETAILS \ .ARM.attributes 0 : { *(.ARM.attributes) } diff --git a/arch/arm/kernel/vmlinux-xip.lds.S b/arch/arm/kernel/vmlinux-xip.lds.S index 11ffa79751da..50136828f5b5 100644 --- a/arch/arm/kernel/vmlinux-xip.lds.S +++ b/arch/arm/kernel/vmlinux-xip.lds.S @@ -152,6 +152,8 @@ SECTIONS STABS_DEBUG DWARF_DEBUG ARM_DETAILS + + ARM_ASSERTS } /* diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index dc672fe35de3..5f4922e858d0 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S @@ -151,6 +151,8 @@ SECTIONS STABS_DEBUG DWARF_DEBUG ARM_DETAILS + + ARM_ASSERTS } #ifdef CONFIG_STRICT_KERNEL_RWX