Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp505055pxa; Fri, 21 Aug 2020 12:56:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn6pjn1kd/+qoOc8JBXfI7mAcxEZTHujwTNS0tSYY5qhEdlgMbF/SSuOu03whpGZrkcAJW X-Received: by 2002:a17:906:3c02:: with SMTP id h2mr4548035ejg.437.1598039800702; Fri, 21 Aug 2020 12:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598039800; cv=none; d=google.com; s=arc-20160816; b=xZ6wV17jvNLqvbJWU9Z7Oid1nsBaFHRLd0eUOTM/7lpduHe3puCZC8tWgiK6wJbzUP qQAy7jk4YVg1Jj0h/yajLVQxNFQsFQfz2+5GcR1f5W9Qi6pjaWDc6i4RP1zQhLiCNICm Xir+6KYweqIMLF6ir7dISvmtmDYDy3t8yQhSvKRJMxl4Fj9WFM574qSCWsh5ijKLzfxd 5CNee2Cs13bjIEBwpBx56wIDhfqwxJcvQScAFvYR8WGxsGRG7esUS/m52yhNZc3HbIPF 0f9aIe55B2c/nMVRbIsQWky6XavOoY1fBbzxqWbPrwcAPAaKQoxRO3dAl61JsOST9yHr oocw== 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=RsnjhsnTEGM+Cj4mkGtPoVyQesfOultuLxrGhrBG5/A=; b=SOVC+2fk1SZnh5ZypVUAaQ0OkD1dkytTYoHlGZECy5wl+UhbX2XJxzatEH1Qi/+UEr 6TIKFXB6KYCsudd/VMBAc/wkrgW0Pg6yD7o+A2mJk58d2qCfUeasbjspWExJiKAHC5ty TGNOcuRcCP8uFG0TewEGMIieW/4jIJlmy4OdD2z9CYrXSlQtqmspgZ+w2cxbhSV7ps85 E1rgJIAKHCGcCb/JrpSR7cMSQU+YbGEJZ1uv2qOegLMJF3h4fLoDTq63dpi1tuAwT2pC jtazSFnMno0MB/l0BHw5KHgVZFOziGRgYzo/z+RI6kta9Bg4UKQugetOc0jA8QfS2E+L KuOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BjCkHROY; 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 j3si1894343edt.444.2020.08.21.12.56.17; Fri, 21 Aug 2020 12:56:40 -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=BjCkHROY; 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 S1726929AbgHUTy6 (ORCPT + 99 others); Fri, 21 Aug 2020 15:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725992AbgHUTyR (ORCPT ); Fri, 21 Aug 2020 15:54:17 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D2CCC0617A5 for ; Fri, 21 Aug 2020 12:54:06 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id d19so1472999pgl.10 for ; Fri, 21 Aug 2020 12:54:06 -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=RsnjhsnTEGM+Cj4mkGtPoVyQesfOultuLxrGhrBG5/A=; b=BjCkHROY2CmoPNZCfAPOetFdIvdym0/mRthIj0PP/ZbxWLiS1o8kmsIYg0iFHhWFr8 A1Ch9dHodBjR4Kgfc/+/25Zi2M2gQZpGoSfr+Pjwhdw6LLPfKoFH3OIlxQdx816GQUNA NreqRzvr9dx2ItAUVHWMIgobbpacT3nHTvf3A= 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=RsnjhsnTEGM+Cj4mkGtPoVyQesfOultuLxrGhrBG5/A=; b=PvA2rkJKIOTQgxjB1QmW1kLqMmlkArYa5GAaVjWYeocBrqWO2vwVRFrc+sUNm/MJrT VS1JG1fPxJURroXJDWbRg0EGEOQXDhekDvYejWh2Q1s0TmSY26lSuCKJ+z2e9v0mx6Tu iSaDkW3Eka2WytfuYsndAQOT5YQOAGmchBHSd/0OIrcqWT18WAIy44/p41b3go2tlFrP gbYl5kGDO0KVWFWUpEphwLVRX1ksM+nWf9X2cbkxJ4mQwt7bMcvwiM7U4kSy1QVMGQFb 0oM9XGuTsGHaZI0I2vN0AawBTBEP9Yok5IX4iha9u3vNtmr2LynOZplaHEM3EccD9nki eQyQ== X-Gm-Message-State: AOAM530LAck5NLufAgAG0Wg+h+uHQK3SOhgqGnPis/A2ol6544XzsPpe WuLbj525HN4rRUgCWsgtcXG2ag== X-Received: by 2002:a63:2809:: with SMTP id o9mr3518924pgo.410.1598039646154; Fri, 21 Aug 2020 12:54:06 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id r15sm3651023pfq.189.2020.08.21.12.54.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:54:02 -0700 (PDT) From: Kees Cook To: Ingo Molnar Cc: Kees Cook , Ard Biesheuvel , Catalin Marinas , Mark Rutland , 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 13/29] arm64/build: Assert for unwanted sections Date: Fri, 21 Aug 2020 12:42:54 -0700 Message-Id: <20200821194310.3089815-14-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, 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). Suggested-by: Ard Biesheuvel Signed-off-by: Kees Cook --- arch/arm64/kernel/vmlinux.lds.S | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 16eb2ef806cd..6ccf19fd2b39 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -121,6 +121,14 @@ SECTIONS *(.got) /* Global offset table */ } + /* + * Make sure that the .got.plt is either completely empty or it + * contains only the lazy dispatch entries. + */ + .got.plt : { *(.got.plt) } + ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, + "Unexpected GOT/PLT entries detected!") + . = ALIGN(SEGMENT_ALIGN); _etext = .; /* End of text section */ @@ -243,6 +251,18 @@ SECTIONS ELF_DETAILS HEAD_SYMBOLS + + /* + * Sections that should stay zero sized, which is safer to + * explicitly check instead of blindly discarding. + */ + .plt : { + *(.plt) *(.plt.*) *(.iplt) *(.igot) + } + ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!") + + .data.rel.ro : { *(.data.rel.ro) } + ASSERT(SIZEOF(.data.rel.ro) == 0, "Unexpected RELRO detected!") } #include "image-vars.h" -- 2.25.1