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 ABEBCC433DF for ; Sat, 1 Aug 2020 05:34:56 +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 78CA820725 for ; Sat, 1 Aug 2020 05:34:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ghtTsIR6"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="lsTcCKnk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 78CA820725 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+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:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7IHar/4zpGbpkWR8y/RpfFBo3atBpezAnnIQwbuPhAw=; b=ghtTsIR69xZ91HFZtMOIljsCy Uwg6QkscV2OtOjYJ7FyTiPCpEtwA2qUF/TpQCsCpt+jFlisUWz+7QnD8W1B8ElJBIU+j7nJPi3yFT aA1sjTB8GYy9EWgnqcIXSN+Pl+ScsCTnTDZxpBQ1SQRVnsJDhwZUTVuTnf/OJVyuA+kg+PlZ5yhMd O4PFLnG8sWGGazVTpa7wLeu/8/qtoCD1sDxubPBRQyVYfvJXt1vQYkIE2BNj88cfRiUxu3916fniF DctP06s1dJBT091CLDUJTF48Kh7DD0BLDw5FNt7yMmHOZ7OnkblHgd/A4IgggLi4pxqf/e4REKWvy OvS8qli4g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1k8n-0003le-RX; Sat, 01 Aug 2020 05:33:05 +0000 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1k8l-0003kl-6c for linux-arm-kernel@lists.infradead.org; Sat, 01 Aug 2020 05:33:04 +0000 Received: by mail-pf1-x442.google.com with SMTP id s26so15481529pfm.4 for ; Fri, 31 Jul 2020 22:33:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=gffroDgUnFtt8A2AavQiebLwAg263HkbnMzJiVCWfkA=; b=lsTcCKnkfydw+Ii8km9p3UWo/dSvLz89JhsnBhbJ4TPkaTaq195uGU+xPmB7hbteXr QbKhXniVeEqsmfnOWWFUyZByl8X7XD7jRWvMO3yDVpNDz2RSQD9haATYARnEusPPiuFO 9IoC96nIOOdr105GbzwVhN642SplbwKbAHC+w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gffroDgUnFtt8A2AavQiebLwAg263HkbnMzJiVCWfkA=; b=uZkQXto8X1fG/PU9Xia3ZUFRagkieInFObVz8OR8EES1blkWtGkS3h2TRvIAR/C2js Kh2xUQ0dndnzBgeiZKJA5kJiOQGWdgiL1hPW+b12uvIt59r13jUTAtXliOZJuwbWFZcB NFJqvAEgWrh0SJldX4UR50qeiScUgnZtST7Uqoj1GkIwRohlpUrCuFcFUJTIeozVHEDu 5z8i4yQPjHHPTpskA7URI0uYrPaDRdPWHqtvYHet5EfvmsUHiEgolEKTg4uuagZ/F2yi 8iKq1hN3Nr9NtNj66WCW8wa+DGAxOzUfhLlZs15SzP5Io9kzCEUrY+WbBfzjtCvvWzDb aD5g== X-Gm-Message-State: AOAM5316EUttP4u0DuzquD8Kq7jEqT3BnWsnoxgl1bwaNUUhMenGYtVk orJfWGBhh49XF7cmkU6PzOSTtg== X-Google-Smtp-Source: ABdhPJwGtAMiLQ/CKOHffEnCRbIQ0jCrPXCRbE9RQyNgzuKoph7XnnkSnRWsaFmBUt+EPnWoPJLUcA== X-Received: by 2002:a65:5604:: with SMTP id l4mr6920746pgs.268.1596259980678; Fri, 31 Jul 2020 22:33:00 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id y6sm12228821pfr.61.2020.07.31.22.32.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 22:32:59 -0700 (PDT) Date: Fri, 31 Jul 2020 22:32:58 -0700 From: Kees Cook To: Arvind Sankar Subject: Re: [PATCH v5 29/36] x86/build: Enforce an empty .got.plt section Message-ID: <202007312231.60719F7C4@keescook> References: <20200731230820.1742553-1-keescook@chromium.org> <20200731230820.1742553-30-keescook@chromium.org> <20200801021248.GB2700342@rani.riverdale.lan> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200801021248.GB2700342@rani.riverdale.lan> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200801_013303_287616_E7E70ACA X-CRM114-Status: GOOD ( 26.51 ) 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, 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 10:12:48PM -0400, Arvind Sankar wrote: > 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? When I switched from DISCARD to 0-assert, I tested all of these, but given so many combinations, perhaps I made a mistake. I will double-check and report back. -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel