Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp501255pxa; Fri, 21 Aug 2020 12:48:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd20MOgoCD254LTpnTODjY/KEKekMZygYEKVvRM6m4QXwJhgF4YzlU4F9LyU6A2aIpiKUc X-Received: by 2002:a17:906:78e:: with SMTP id l14mr4833175ejc.67.1598039335787; Fri, 21 Aug 2020 12:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598039335; cv=none; d=google.com; s=arc-20160816; b=QMt9R2C3zLUb8EPQbA/yaO/sjqGVEGvjhXnws13mnB044TOR7iPT4K4FbUJQwe1JeE ytr4zbGkWuBLuHFMD/invMGk0tQL1TQrEU1Fhzs5xCWG6Sw+yKWpenGj7a/VChnTrtxW BMUoaNUJRssV8ASRvczZCmlSGwm1BwmQ5CuUXKBVyoveRjUSr7ZuYIWrWUqP2kJyQfCL ZFtrgLnyIKvd9CG1vVTvXGo6BdZyDDHXySfKU+IG+vNZtBdxCxFgh4hCU5d3psjGunXk Bz1JHLuOJoyVXYLA8UfSS3ldyYvo+qbxVVA/JSeO8FeBh2dq7iGaNRcXBxS7nAo51/kq z2IQ== 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=LnzDApNoxwO5pBe0Rw0QWzekBEKvTuf/gsd4zpzC+NU=; b=iKWd9Gg8Zq7dSLxoda/EVlWOQkegrCyTjPV02IAQUGxtNVc6MqI3dHph6N4MkV0szl VKpWMu9ZwwrX8xUKPGi5Y8szJAL7LxoKxJkccNRGRivX+cO8dZ4yfoEzTwUYplxmprrn sQW1ndPWF2NG9oyLhARbZE6rCXO3+ZkpHkSMWbvtiiaqBX2CGyn53FmVngqe8KwieDbD +jXNTUEBv+eaY9Zc8RCKAHT1WoiAfTJigh0/eLYt5jsIwXEeuaU8edZ3dPuZ42BCkqUn MvYClKqguYKFEhPHKpqelTPHeS11SkF1e479a+BHexCNZW8NRLL1cYYLEtyTjIaNvBNa budg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=UoERYCO2; 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 e5si1764768ejc.182.2020.08.21.12.48.32; Fri, 21 Aug 2020 12:48:55 -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=UoERYCO2; 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 S1726838AbgHUTph (ORCPT + 99 others); Fri, 21 Aug 2020 15:45:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726851AbgHUTpG (ORCPT ); Fri, 21 Aug 2020 15:45:06 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3105C061348 for ; Fri, 21 Aug 2020 12:44:34 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id ds1so1261496pjb.1 for ; Fri, 21 Aug 2020 12:44:34 -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=LnzDApNoxwO5pBe0Rw0QWzekBEKvTuf/gsd4zpzC+NU=; b=UoERYCO24yjxw/nfIGuRfWgjYp/IIpMBbAVGy1Wh0MBis2sB6JQnzFux8I34fXIfzL XiTwAIwqPF4tOCBbtkjo2duqIpNp4WHF09n3SLEANmWxObkZKlAhR7FwKcJlzhd+gQgM C1S+79RksYz2j/ZELEmvpwtea99u0tMD9V+xs= 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=LnzDApNoxwO5pBe0Rw0QWzekBEKvTuf/gsd4zpzC+NU=; b=NZOGBeu0bVFSsjvzC2ZJM+HdCbsricOIsFM2qhsrY/AttTiHl1wAtYZxJZHGv/scg8 XRfWRif0893JIvMSqYUCNod2zzyciiF5TB5NTwvGWXW3JCEYJ17ne87QIcGkBq2PN/A+ 4eHdf7eGyiBWFhfu8BCmgBecTGA3lbWFkw7VC2FyejoCWUUprctkG57dEG6DEX85E5E2 uyxnUIGbaGkl+4yJucNBVPSX9MhZ2c89saG+DvjxtCvP2+nk73d8teXJCF1zFp/EWcew LKl5eay3uCcw0LAnT2U/FGc33wS+tE+gUsS5bJT6Co/KgKnnKrHZtUSzHIS+zWd43N/C HRgQ== X-Gm-Message-State: AOAM530PHgdeya/uUaC16h+KkQVXkaLg3w7+qWZUmOLIfROyMwAOzf1X +Vl4mBKwWst2u1UuZbOeM6jw0Q== X-Received: by 2002:a17:902:ac84:: with SMTP id h4mr3560513plr.334.1598039073450; Fri, 21 Aug 2020 12:44:33 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id o7sm2570901pjl.48.2020.08.21.12.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2020 12:44:32 -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 24/29] x86/build: Assert for unwanted sections Date: Fri, 21 Aug 2020 12:43:05 -0700 Message-Id: <20200821194310.3089815-25-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 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/kernel/vmlinux.lds.S | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 4b1b936a6e7d..45d72447df84 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -427,6 +427,30 @@ SECTIONS SIZEOF(.got.plt) == 0xc, #endif "Unexpected GOT/PLT entries detected!") + + /* + * Sections that should stay zero sized, which is safer to + * explicitly check instead of blindly discarding. + */ + .got : { + *(.got) *(.igot.*) + } + ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") + + .plt : { + *(.plt) *(.plt.*) *(.iplt) + } + ASSERT(SIZEOF(.plt) == 0, "Unexpected run-time procedure linkages detected!") + + .rel.dyn : { + *(.rel.*) *(.rel_*) + } + ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!") + + .rela.dyn : { + *(.rela.*) *(.rela_*) + } + ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!") } #ifdef CONFIG_X86_32 -- 2.25.1