Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1588196ybt; Thu, 2 Jul 2020 08:57:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBy5pI9NyhCWZIAiMA7ACjtADeWmYC22Civp8xBPmKtPHeZjI5xRSXLAk9ZzRySbHstp8v X-Received: by 2002:a17:906:3fd2:: with SMTP id k18mr29766806ejj.387.1593705443330; Thu, 02 Jul 2020 08:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593705443; cv=none; d=google.com; s=arc-20160816; b=j5sANF04vi2ZOlWSlyWLSyM820l1u87DdJ03q9iknuFiDaXMFGraTj7IalG0QnEnxt lRx5KPFH14R6FaWp4y5nO/I1e4XGhrIE0j1A/uk8oPtd4SKo+uOiGBDhKmb3nz5aPlfC zaxybRjaGuLrPyKNExpE/9SZZGYfNxVUkaioccWyeWhH13rLYSOuxhGyfSgopiNRe7IV jku8CE0VEbFjImFWX96w9UAx0BK1qVPE/35pNgPA4c3OchopWNYgWBLvDQe252OzVo9g Dy3vPdi8/+Fc3iOJ+mpx0213FQMCIHLT9SgKEVkPJbzPjWeRSznGNyfd06YYntBfiKBA giTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=MeAooFE7BzOJmYHcj5OvJQ3TIg8iS0KIUniqk0qo5RE=; b=DpOP9UWJqv4FUkyTDR7hjtAXpjy7TTcq/0LV33NJA0eIJ7Uljj5GniLe/AJ0NpUPOx LcDPB5vY1OK/2QW4w1SKbRXHHsDNSvzr5Vqpfa5HeFj7l8dES8x8TlLqtIhQuRuAarHs d9UYz9Vz+yTPtQEyvCijHR/+6+b6cLJ+jTAgbMVkTDVoL+jweGRBzD4adKnaSjg1jWKH DT6PjilKpJpvZ3uGw+zk98DG0VK/Sc+AxwYiVWRMBxO5OsSB//Mglwz6t4X/oCqAo7h3 H0O/gAHm7LmPVhAo8kKE4pXRXGcIRVhVA15tEX2HkhiXLampc2KEt8MpN6cl8tkJHMYK x1gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=E231RZrQ; 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 cm10si6015287edb.208.2020.07.02.08.57.00; Thu, 02 Jul 2020 08:57:23 -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=E231RZrQ; 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 S1726151AbgGBPy5 (ORCPT + 99 others); Thu, 2 Jul 2020 11:54:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbgGBPy4 (ORCPT ); Thu, 2 Jul 2020 11:54:56 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B48B5C08C5DE for ; Thu, 2 Jul 2020 08:54:55 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id x11so11467240plo.7 for ; Thu, 02 Jul 2020 08:54:55 -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=MeAooFE7BzOJmYHcj5OvJQ3TIg8iS0KIUniqk0qo5RE=; b=E231RZrQeNOxHh/UTusOKpx/9GZyqw7QxQJkPeqUZz6CUpMxg+PQ93lPWTHg6A7njf 9/s9/DtLeQECLL3mPfiHy/zYgSl8SvJa1wS3GmTkJELVt6l7Yh5Xb07gOsTpgYaMInDs NWAAtwUQgGR66y9UiGHjay3pOw/x2zgzhXHgE= 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=MeAooFE7BzOJmYHcj5OvJQ3TIg8iS0KIUniqk0qo5RE=; b=A1cZNiFXUVvWP8RDe8TCYaNkK+3QllHBooOx7vVQ0feiUMQ4RNfR5XNQ+NNMKZuqa8 3JA3p6FhP4I+YGEzND4hLeGm14WoEUhSPHzpoqT2f3Iyr4wefrLJ3PHkE8KbfGakzf4D EJgCpO2FB4wus7iXYNslst1Hjfz3PM/9xcAXPjCKAHJ7BWFoaO2YNTmPCb8e/2Hdu1z4 Mgw3LdF1in2epcbXGhRQqQq1N19pq9MlBv0C9a/08IFfVr0g7a7Kzs3O6Wb+liZ3BSrk NM+FB5vyw21hrI160FMSsEkhV6JBuczSkyRITOKCwemPFEmNMkU2QenJjWIUzxB6sXc4 rfdQ== X-Gm-Message-State: AOAM533xp8HoP7xBkWmZc1RJh9HcLuSjkLvgivhgn4vULzu1OCNlyDal pG1suGkz4GVR60zGRdyw5uHhxg== X-Received: by 2002:a17:902:bb95:: with SMTP id m21mr26850948pls.111.1593705295142; Thu, 02 Jul 2020 08:54:55 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id n65sm9219269pfn.17.2020.07.02.08.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 08:54:54 -0700 (PDT) Date: Thu, 2 Jul 2020 08:54:53 -0700 From: Kees Cook To: Danny Lin Cc: Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Sami Tolvanen , Fangrui Song , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, stable@vger.kernel.org Subject: Re: [PATCH] vmlinux.lds.h: Coalesce transient LLVM dead code elimination sections Message-ID: <202007020853.5F15B5DDD@keescook> References: <20200702085400.2643527-1-danny@kdrag0n.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200702085400.2643527-1-danny@kdrag0n.dev> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 02, 2020 at 01:54:00AM -0700, Danny Lin wrote: > A recent LLVM 11 commit [1] made LLD stop implicitly coalescing some > temporary LLVM sections, namely .{data,bss}..compoundliteral.XXX: > > [30] .data..compoundli PROGBITS ffffffff9ac9a000 19e9a000 > 000000000000cea0 0000000000000000 WA 0 0 32 > [31] .rela.data..compo RELA 0000000000000000 40965440 > 0000000000001d88 0000000000000018 I 2238 30 8 > [32] .data..compoundli PROGBITS ffffffff9aca6ea0 19ea6ea0 > 00000000000033c0 0000000000000000 WA 0 0 32 > [33] .rela.data..compo RELA 0000000000000000 409671c8 > 0000000000000948 0000000000000018 I 2238 32 8 > [...] > [2213] .bss..compoundlit NOBITS ffffffffa3000000 1d85c000 > 00000000000000a0 0000000000000000 WA 0 0 32 > [2214] .bss..compoundlit NOBITS ffffffffa30000a0 1d85c000 > 0000000000000040 0000000000000000 WA 0 0 32 > [...] > > While these extra sections don't typically cause any breakage, they do > inflate the vmlinux size due to the overhead of storing metadata for > thousands of extra sections. > > It's also worth noting that for some reason, some downstream Android > kernels can't boot at all if these sections aren't coalesced. > > This issue isn't limited to any specific architecture; it affects arm64 > and x86 if CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is forced on. > > Example on x86 allyesconfig: > Before: 2241 sections, 1170972 KiB > After: 56 sections, 1171169 KiB > > [1] https://github.com/llvm/llvm-project/commit/9e33c096476ab5e02ab1c8442cc3cb4e32e29f17 > > Link: https://github.com/ClangBuiltLinux/linux/issues/958 > Cc: stable@vger.kernel.org # v4.4+ > Suggested-by: Fangrui Song > Signed-off-by: Danny Lin > --- > include/asm-generic/vmlinux.lds.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h > index db600ef218d7..18968cba87c7 100644 > --- a/include/asm-generic/vmlinux.lds.h > +++ b/include/asm-generic/vmlinux.lds.h > @@ -94,10 +94,10 @@ > */ > #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION > #define TEXT_MAIN .text .text.[0-9a-zA-Z_]* > -#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX* > +#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX* .data..compoundliteral* > #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]* > #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* > -#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* > +#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral* Are there .data.. and .bss.. sections we do NOT want to collect? i.e. why not include .data..* and .bss..* ? -- Kees Cook