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=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 0AE9EC433DF for ; Sat, 1 Aug 2020 01:49:53 +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 C78642072A for ; Sat, 1 Aug 2020 01:49:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Ya+Z49Ui"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rweOnJ01" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C78642072A 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=DXxVD1GcoUi3sq8rzSY9C1TU+Qw6Gx+YEuovSXxvw/s=; b=Ya+Z49UiOhM9QplscvfyUeGZm DCcgZ6PauoTN5wvni9qXpVKiUI9VDXIBUQlxMwSSKIaIe/fB0P1Mj9sdIr5Kge/AtyGPo2k9NCkQF br2CGdee4IjrxPpZ9FekFbFQbj+MLt7gcPZaQu+2XJxRxv2wdgtabAYyB+aOLaRDJZp4ll5Mqt2yL ZR/Yf5pW3BNg6iEV9vBbugtsu16XO6ugGGUctX24jjeJTTiZrxGnhMdhkda/p+kmERuIzVbE9ovyL wjL4PQcuDVRWfqGtAO4lyz+iva3yMIcTO0G+ui4LM4Myua2dGDRDCJk80pBEuP/WEVgjQ2PgkT1qQ 3RSQdunMA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1gd2-0007ou-Lf; Sat, 01 Aug 2020 01:48:04 +0000 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k1gcz-0007nv-F8 for linux-arm-kernel@lists.infradead.org; Sat, 01 Aug 2020 01:48:02 +0000 Received: by mail-qk1-x741.google.com with SMTP id l64so23811255qkb.8 for ; Fri, 31 Jul 2020 18:47:59 -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=DfgKTVMFpic0lvlFw/heJsrWIE3jTqCxvCbC4XpQbAk=; b=rweOnJ01nmAYHvLiHAsMtHB4+7hGTuaJgfJNv4cNQR23MLI6XWzYJm998XxMdchzjb XP4uBBQ5hwdPxd6HssESos6Ze2840JD+nBoiNC1+o6lDoNSW1crF6SQerJ0gxEdFCuLG LH7QCe3A1iy1DnieHTPYK9cI7zjJPIfI2QGcedKZHgo5MPVbSs8LdkHi+57rF6ZYYnaQ gVj6YGiUijeqhq0UUv6/w4xWUaTZctRZMRrItn2ELY5/fdRCXk3ectjVDoZxiNeGJ1hG 2qyBdH7NzqeWpPTNaPbRmxqcasJlNT8Bb+rJr04NECEWL5n1970lqzlt/DWOLOWSsARa mF6g== 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=DfgKTVMFpic0lvlFw/heJsrWIE3jTqCxvCbC4XpQbAk=; b=kJCWtp0hlW5AcBM+psi+aeBoa+W5ZdvMkJ4+cPqW1oBANxXiNHP/HquGxI1W0asyXP 7qOtqsJ/Y1YKRwdbUO0oe8vbsh0EbY5g00sv6vJia9XqN1Jpdv7wfeyW3t1XVHFjQ0Y6 1ng0AsW4FcHlsBAZTyMGNJMsdlwwlmFFBJr4BKJXWG1ZqNiT+l5f2ssq6FnLoYYFpxNi NGV3+mnTpakVnnVAJ5SQPVGh7dPUFNi7T2tcUfYXvqkeB1mV54nx5yh3iOheu2wEzBmN dgt0cDvUvK3omRhsyxrzVpPv2f4T2akJCs9Rk30Xw8K+ITddKs5x55u2MsQWUTg2Dn0x Y1Yw== X-Gm-Message-State: AOAM530Y7GvkI0EJr8JOEk4sa9FG0AdxXwVzELWg7Ad9GYTlVTDLeUZC 8pIsLKTB7Rs/gTADdTF3W2g= X-Google-Smtp-Source: ABdhPJxliEC7tkuTaMnDy7cW9516HhJz7m8xvAVOsPuOEMr9SnyUOcCZu77gHA7uT4OL8j3TRvlNSQ== X-Received: by 2002:a37:62d4:: with SMTP id w203mr6547799qkb.463.1596246478260; Fri, 31 Jul 2020 18:47:58 -0700 (PDT) Received: from rani.riverdale.lan ([2001:470:1f07:5f3::b55f]) by smtp.gmail.com with ESMTPSA id o37sm12377089qte.9.2020.07.31.18.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 18:47:57 -0700 (PDT) From: Arvind Sankar X-Google-Original-From: Arvind Sankar Date: Fri, 31 Jul 2020 21:47:55 -0400 To: Kees Cook Subject: Re: [PATCH v5 32/36] x86/boot/compressed: Reorganize zero-size section asserts Message-ID: <20200801014755.GA2700342@rani.riverdale.lan> References: <20200731230820.1742553-1-keescook@chromium.org> <20200731230820.1742553-33-keescook@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200731230820.1742553-33-keescook@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200731_214801_520776_DE31AD7A X-CRM114-Status: GOOD ( 21.04 ) 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:16PM -0700, Kees Cook wrote: > For readability, move the zero-sized sections to the end after DISCARDS > and mark them NOLOAD for good measure. > > Signed-off-by: Kees Cook > --- > arch/x86/boot/compressed/vmlinux.lds.S | 42 +++++++++++++++----------- > 1 file changed, 25 insertions(+), 17 deletions(-) > > diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S > index 3c2ee9a5bf43..42dea70a5091 100644 > --- a/arch/x86/boot/compressed/vmlinux.lds.S > +++ b/arch/x86/boot/compressed/vmlinux.lds.S > @@ -42,18 +42,16 @@ SECTIONS > *(.rodata.*) > _erodata = . ; > } > - .rel.dyn : { > - *(.rel.*) > - } > - .rela.dyn : { > - *(.rela.*) > - } > - .got : { > - *(.got) > - } > .got.plt : { > *(.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!") > > .data : { > _data = . ; > @@ -85,13 +83,23 @@ SECTIONS > ELF_DETAILS > > DISCARDS > -} > > -ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") > -#ifdef CONFIG_X86_64 > -ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0x18, "Unexpected GOT/PLT entries detected!") > -#else > -ASSERT(SIZEOF(.got.plt) == 0 || SIZEOF(.got.plt) == 0xc, "Unexpected GOT/PLT entries detected!") > -#endif > + /* > + * Sections that should stay zero sized, which is safer to > + * explicitly check instead of blindly discarding. > + */ > + .got (NOLOAD) : { > + *(.got) > + } > + ASSERT(SIZEOF(.got) == 0, "Unexpected GOT entries detected!") > > -ASSERT(SIZEOF(.rel.dyn) == 0 && SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations detected!") > + /* ld.lld does not like .rel* sections being made "NOLOAD". */ > + .rel.dyn : { > + *(.rel.*) > + } > + ASSERT(SIZEOF(.rel.dyn) == 0, "Unexpected run-time relocations (.rel) detected!") > + .rela.dyn : { > + *(.rela.*) > + } > + ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!") > +} > -- > 2.25.1 > There's no point in marking zero-size sections NOLOAD -- if the ASSERT's passed, they won't be present in the file at all anyway. The only section for which there might be a point is .got.plt, which is non-empty on 32-bit, and only if it is first moved to the end. That saves a few bytes. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel