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=-9.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 87119C433E1 for ; Sat, 1 Aug 2020 02:12:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E83020838 for ; Sat, 1 Aug 2020 02:12:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H0j3lwKV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728314AbgHACMx (ORCPT ); Fri, 31 Jul 2020 22:12:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727047AbgHACMw (ORCPT ); Fri, 31 Jul 2020 22:12:52 -0400 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D18B1C06174A; Fri, 31 Jul 2020 19:12:51 -0700 (PDT) Received: by mail-qv1-xf42.google.com with SMTP id b2so4467091qvp.9; Fri, 31 Jul 2020 19:12:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=RcNuzy0I0GlSHPsgjAin26OQE0adxaomHrcIgCRJLsA=; b=H0j3lwKVrWTDg9Nj6lVX8E+JSdSgFYHExHD3kQRejF/GSPasrUcW4qwkiqAR9d+N3o 3GyzgqqDKhtfP/fSUb/csNcwcdH2smwmb06YPDfK2hSusUJWXGtMhqYTvkRkpVDRb5yV ceHtuJ7ki2HPQiCs63cDIX7EArJ+qR8ExtFfmrJt3FtGWFVv0l3NZ+PN6x3ZlT3zpBEJ szBzA2zc3FwnVv39VVBY1dTUaO6w8TWIoyxvZdq55+HccFDvzp33gDoJp8N9CU8v6r0I bDHiBKKIR4HXPxu+G7JWYuTrG/UO/eqb2/uIlG7jq1W47h7QmdVsDuESBeNVsyZH51hK MW3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=RcNuzy0I0GlSHPsgjAin26OQE0adxaomHrcIgCRJLsA=; b=MmeBFXNEg1AkrrcuaN/ccA7ktcCmiLuEwEzarwyXynHFSTQv5Q1Dq8bDszN5KkotnC Od3uqb5vasz5N2vWWLj7i2T1Y/xadjptqDu5512uYfb6r/706E5Vl9AxY7DsAJXGTpX5 h0WKWApSIZ68Pl6HSGujKILgHzYSoNkV2racMd2aRXnC3DMxh1dredqzyMqh57N1oQMV 8IDVq+kE8u1SedDwS1Gp2xcPht+jFJcgwocy9GmPU8+AGAsj9AQF6Z4qbYi19KFUgK9n 08GiqLKKj8JBMYaJQw+//vMtnUKYW3ZC9dmb/QYN0KoHjGYtvzCSYamBI5I0Y+9yvRkl BAqw== X-Gm-Message-State: AOAM531KgMfPi4HARyuSv8umTEOJseyUOMovwcUfEd9lyWaQfVl476/a MSuLa4ER6KGSczt0faM5q6k= X-Google-Smtp-Source: ABdhPJznGsCyCuOqLliE1x4Zh3NMzH7OELuVpjiOV0wBqMg6k32zgEIVZ6p0HuoA1y4AaRJkh9a7eg== X-Received: by 2002:ad4:500c:: with SMTP id s12mr6997719qvo.101.1596247971068; Fri, 31 Jul 2020 19:12:51 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id u42sm14062820qtu.48.2020.07.31.19.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 19:12:50 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Fri, 31 Jul 2020 22:12:48 -0400 To: Kees Cook Cc: Thomas Gleixner , Will Deacon , 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: Re: [PATCH v5 29/36] x86/build: Enforce an empty .got.plt section Message-ID: <20200801021248.GB2700342@rani.riverdale.lan> References: <20200731230820.1742553-1-keescook@chromium.org> <20200731230820.1742553-30-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200731230820.1742553-30-keescook@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 31, 2020 at 04:08:13PM -0700, Kees Cook wrote: > The .got.plt section should always be zero (or filled only with the > linker-generated lazy dispatch entry). Enforce this with an assert and > mark the section as NOLOAD. This is more sensitive than just blindly > discarding the section. > > Signed-off-by: Kees Cook > --- > arch/x86/kernel/vmlinux.lds.S | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S > index 0cc035cb15f1..7faffe7414d6 100644 > --- a/arch/x86/kernel/vmlinux.lds.S > +++ b/arch/x86/kernel/vmlinux.lds.S > @@ -414,8 +414,20 @@ SECTIONS > ELF_DETAILS > > DISCARDS > -} > > + /* > + * Make sure that the .got.plt is either completely empty or it > + * contains only the lazy dispatch entries. > + */ > + .got.plt (NOLOAD) : { *(.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!") > +} > > #ifdef CONFIG_X86_32 > /* > -- > 2.25.1 > Is this actually needed? vmlinux is a position-dependent executable, and it doesn't get linked with any shared libraries, so it should never have a .got or .got.plt at all I think? Does it show up as an orphan without this? 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=-10.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 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 4EFA3C433DF for ; Sat, 1 Aug 2020 02:14:26 +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 19B6D20838 for ; Sat, 1 Aug 2020 02:14:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yungBAu5"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H0j3lwKV" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19B6D20838 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=alum.mit.edu 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:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=/sATKsJNA+9fnu3uaA2b/s0PEX+VqY02rh8yQg68xsk=; b=yungBAu58UzzDylQi/Q8NTXu3 bxmjLy9BS8mFvWWcMEtfrit+pPfrXU899+Wgv4CSPcwTl6bsrP2GPOlyHfqXMmBRsIS+TX1RIvfl4 edKNH5TA9bF32ZIPq1e7o5mQCBSVl2b8XJuLKQl1JduI5872BRqEJaDQhmyGXV8VFexkLmbzMEZd0 77j00wYnv8rAK93C1jgphen5ceZj/CxpVYdTxzCkRzsSg2nA2JfxRVV0tCxSogtLecPgrwDElAGUe 7qUMTGkZu7CYoipMoAf98agjBg1HmonnRHs1Gu39UkSva8Ywff3AWvwEtjifOwn1d6cYSREVHMnAK AB7zT6AKQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1h15-0000ZX-VJ; Sat, 01 Aug 2020 02:12:55 +0000 Received: from mail-qv1-xf44.google.com ([2607:f8b0:4864:20::f44]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1h12-0000YX-S5 for linux-arm-kernel@lists.infradead.org; Sat, 01 Aug 2020 02:12:53 +0000 Received: by mail-qv1-xf44.google.com with SMTP id a19so9036746qvy.3 for ; Fri, 31 Jul 2020 19:12:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=RcNuzy0I0GlSHPsgjAin26OQE0adxaomHrcIgCRJLsA=; b=H0j3lwKVrWTDg9Nj6lVX8E+JSdSgFYHExHD3kQRejF/GSPasrUcW4qwkiqAR9d+N3o 3GyzgqqDKhtfP/fSUb/csNcwcdH2smwmb06YPDfK2hSusUJWXGtMhqYTvkRkpVDRb5yV ceHtuJ7ki2HPQiCs63cDIX7EArJ+qR8ExtFfmrJt3FtGWFVv0l3NZ+PN6x3ZlT3zpBEJ szBzA2zc3FwnVv39VVBY1dTUaO6w8TWIoyxvZdq55+HccFDvzp33gDoJp8N9CU8v6r0I bDHiBKKIR4HXPxu+G7JWYuTrG/UO/eqb2/uIlG7jq1W47h7QmdVsDuESBeNVsyZH51hK MW3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:date:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=RcNuzy0I0GlSHPsgjAin26OQE0adxaomHrcIgCRJLsA=; b=MG2E77+S1611Que7kks4jr8aHPrECvJulujF487H+SDSYKmLuuUDrVfcFm4cT89lj3 H6icHv6cKj5XIESpIu1GO+xCtqc/c5NbUParwqIrTnt/7OB9y37+fnutdsxr2OlnTwuF xdR8D0uY3T4spEJlMC8JC4U7mHyGqF6fXrtOBWt+eVYnjg43W1vlmJlN9xqleffWmNxF 4LMkZqd2q+NVA1+fhfvxGevozSdEz9X7H2kp2sgj9++GoLIA/bc0PGfeXDobv/aWpMze 4jMJtoBiPTBsTdrXPXPBvB7fjfR9JKiSRc7GvBqbLnbr64HilPpHgDQc6VEXTwmAUwMw kJCA== X-Gm-Message-State: AOAM531YBqpnb9BTwsvrvvBbUhZTMSi3+XeZBBIp8q4EQaOaS9c3mQ1U uur/QpghYE5lt1pfrM0ApxU= X-Google-Smtp-Source: ABdhPJznGsCyCuOqLliE1x4Zh3NMzH7OELuVpjiOV0wBqMg6k32zgEIVZ6p0HuoA1y4AaRJkh9a7eg== X-Received: by 2002:ad4:500c:: with SMTP id s12mr6997719qvo.101.1596247971068; Fri, 31 Jul 2020 19:12:51 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id u42sm14062820qtu.48.2020.07.31.19.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 19:12:50 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Fri, 31 Jul 2020 22:12:48 -0400 To: Kees Cook Subject: Re: [PATCH v5 29/36] x86/build: Enforce an empty .got.plt section Message-ID: <20200801021248.GB2700342@rani.riverdale.lan> References: <20200731230820.1742553-1-keescook@chromium.org> <20200731230820.1742553-30-keescook@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200731230820.1742553-30-keescook@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200731_221252_972055_A7FF4750 X-CRM114-Status: GOOD ( 24.00 ) 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, Arnd Bergmann , Peter Collingbourne , Catalin Marinas , Masahiro Yamada , x86@kernel.org, Nick Desaulniers , Russell King , linux-kernel@vger.kernel.org, Nathan Chancellor , clang-built-linux@googlegroups.com, Arvind Sankar , Ingo Molnar , James Morse , Thomas Gleixner , Borislav Petkov , Will Deacon , 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 On Fri, Jul 31, 2020 at 04:08:13PM -0700, Kees Cook wrote: > The .got.plt section should always be zero (or filled only with the > linker-generated lazy dispatch entry). Enforce this with an assert and > mark the section as NOLOAD. This is more sensitive than just blindly > discarding the section. > > Signed-off-by: Kees Cook > --- > arch/x86/kernel/vmlinux.lds.S | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S > index 0cc035cb15f1..7faffe7414d6 100644 > --- a/arch/x86/kernel/vmlinux.lds.S > +++ b/arch/x86/kernel/vmlinux.lds.S > @@ -414,8 +414,20 @@ SECTIONS > ELF_DETAILS > > DISCARDS > -} > > + /* > + * Make sure that the .got.plt is either completely empty or it > + * contains only the lazy dispatch entries. > + */ > + .got.plt (NOLOAD) : { *(.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!") > +} > > #ifdef CONFIG_X86_32 > /* > -- > 2.25.1 > Is this actually needed? vmlinux is a position-dependent executable, and it doesn't get linked with any shared libraries, so it should never have a .got or .got.plt at all I think? Does it show up as an orphan without this? _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel