Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp500325pxa; Fri, 21 Aug 2020 12:47:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXV2bZ+CgzAmeQ68wyZ7lH0Vlf32mp126dRxMS3bwEk/1YkuKYlbFpWT+tcJMHq5hfB1Jx X-Received: by 2002:a17:906:dbf4:: with SMTP id yd20mr4356400ejb.369.1598039234300; Fri, 21 Aug 2020 12:47:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598039234; cv=none; d=google.com; s=arc-20160816; b=y6cB75s4D/Qv9T7YK+CJfP0WJPO6W+/+fLLjcrOQ4O9BXAqZf17vOCdLAV3YxS/B91 a9RLJIJo157+VaUou7XVVH2jwCHp+jhXHZSDtQAnw/BftW+fC5WcgSLN/P4oQ3hB2de7 HczSiXvKLQTChT2TgMYNuBfSCSR5ka4thB7IXe+crHq94xiv0UUCYZuRlG2PjlsDm8LP lSw8SW5DuRSF5AvHiT98l2Vu8UTzKDUhOGyHRnY3b/0YH8JkgSNyqlYajA2hkkSXePPd WxQpwDrTnRFvIzsw1f+SYir6aK3x4BB0i9pSL2jTECHGhHR38AkCtKRTRVb+SmUi13rv gXXQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2SO+UGcbCrLenHkErAflqsGtJX/MLOFJ7NqTGBJ73x8=; b=MxyGy9DnCUYbcfcVoaYzJ2CENQCKVY3lmAXJZM51FHX5MXa2999Ahnr11M+282wNyT UCwmmTlegt1jcewS5h9HHmkfincJsb45VSITs4XmTirqsffhw6MNiy88qmTNUHaKuuRg dmeXJR7OeO1TOPTwLj/uVd2qscWVpsUDZTPUA1ukDyjLpkdu0UUJq9OLuPObqG8tTv7R 7zBIMqGR+OnJYHaaV0zbCQFtsC+umdifDeZg4eM5n/PYmZ4DrMZFNMIpZlH9Sqzqxnqz nxDu7yOy7yhVCVqynyNtMbZ6sJD+M8y5BnxNGHNTCv5PTP3BQbUsTOq514bFHU/tw5o3 JXDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GF8WNGGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n28si2108622eda.478.2020.08.21.12.46.51; Fri, 21 Aug 2020 12:47:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=GF8WNGGb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726968AbgHUTpt (ORCPT + 99 others); Fri, 21 Aug 2020 15:45:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726817AbgHUTo5 (ORCPT ); Fri, 21 Aug 2020 15:44:57 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79898C06138F for ; Fri, 21 Aug 2020 12:44:31 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id t6so1254915pjr.0 for ; Fri, 21 Aug 2020 12:44:31 -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=2SO+UGcbCrLenHkErAflqsGtJX/MLOFJ7NqTGBJ73x8=; b=GF8WNGGbz0L91U/cKK8hFCLiRU4GwBwG4dOQCTOrpJCd24QY/0vGi6vnGJMoYwqo9j tg5x5+RDELdR2JEO4trH7JtQZw3eWL1PnG0VNMUjRiMWm8/9k2VtuwglST1tWIBAWTS1 P+x+GSWOlYP3io7XqFUjxcgSnBkW/qZP7U2eY= 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=2SO+UGcbCrLenHkErAflqsGtJX/MLOFJ7NqTGBJ73x8=; b=blA97oGORqv7EJ/jJjR48V9OxbgwxLBtSNIi72JfaYJ6QhONlEHNn87zpVE9JfuAbq 5KwEROKM1M46oO1RlSK3fzYWbJIrXoNNRRXje86r4EJkWWrWrsRGlAQEXtiS7KB4NbOx cJkoBGyC6RXD4Q7XfAV2aZCwm0aPFIVveDuzr32lrVmzuufbCmLE9OY9IxvMDBiE/DAE 16R1VtCbjWXfc7k6q1S96tlnvT51kpGFNkwPaD/c1K1Iy5UNAUJBHOAfFxf5+DRgMu2W EdmTBSi9NcZ1TXSYZLQpm3fA+KdMLLT4O//RCd73yZHE0OfweD+BSy+ufjEitKLRSeTr uigg== X-Gm-Message-State: AOAM531rr0g/LXarqyKqmogve1CdnSPgQZoyTs9/ac8KgE2DukautIIW L5Xs33Q1wwN1S0MS+a+/TyaPyg== X-Received: by 2002:a17:902:d691:: with SMTP id v17mr3392145ply.235.1598039071121; Fri, 21 Aug 2020 12:44:31 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id o66sm2795858pgo.25.2020.08.21.12.44.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:44:30 -0700 (PDT) From: Kees Cook To: Ingo Molnar Cc: Kees Cook , Catalin Marinas , Mark Rutland , Ard Biesheuvel , Peter Collingbourne , James Morse , Borislav Petkov , Ingo Molnar , Russell King , Masahiro Yamada , Arvind Sankar , Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , x86@kernel.org, clang-built-linux@googlegroups.com, linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 18/29] arm/build: Assert for unwanted sections Date: Fri, 21 Aug 2020 12:42:59 -0700 Message-Id: <20200821194310.3089815-19-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821194310.3089815-1-keescook@chromium.org> References: <20200821194310.3089815-1-keescook@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 | 11 +++++++++++ arch/arm/kernel/vmlinux-xip.lds.S | 2 ++ arch/arm/kernel/vmlinux.lds.S | 2 ++ 3 files changed, 15 insertions(+) diff --git a/arch/arm/include/asm/vmlinux.lds.h b/arch/arm/include/asm/vmlinux.lds.h index 6624dd97475c..4a91428c324d 100644 --- a/arch/arm/include/asm/vmlinux.lds.h +++ b/arch/arm/include/asm/vmlinux.lds.h @@ -52,6 +52,17 @@ 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 : { \ + *(.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 -- 2.25.1