Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1196670pxu; Wed, 6 Jan 2021 15:28:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJyuZOkFNxtH9Lp89Iy/HnRm7hYrYKEupcS13f+ix6P3pJN5lfnPYNgQSXz6BUXH0DR8mLxS X-Received: by 2002:a50:fb85:: with SMTP id e5mr5460532edq.153.1609975718665; Wed, 06 Jan 2021 15:28:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609975718; cv=none; d=google.com; s=arc-20160816; b=0yYj7EJ4cewPeTR6VAPKuvD4aWfMStYz9zIOPnuz3mUU4Y9WS10D/bsiuhXRCupqRa pnXK2j03wGIKRJmiMc4gVPIxPWnVZiAnHaKE+CctsPkY07rEel1g0zSAol9t0eoA45/o o9RuSVh/09L6DoLZFLvIVfsymKrgrpsZlG1Tg7D9KLbQPBldFjbDzw5tvDYhefz5bmAj VTT5V0kW7xwDldqk1UYZl+dsN50L+eQ3NGOl8yQqgcLS0kbtonwgk2iOmisAGSS73uk+ AFU/+utnE0I/2fUKA7vd/m/tJQjvgyHkNFyLK3JHFNmhQ3y4Eq9TV8fuKzhxmrruBvoH chOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PCAsqtwy69+o8i02BTFhqMq2pnNK2pwjyZKbY8yJvCg=; b=YNYikNOrXzVDJZIddz5Ea4zCGBNssCmSmXaSAhr7a6ls4cQ83EeNSqgv5yvtVOTZDJ pjN2Xb9yGXMpF6XW6DApkYOy/g3K/+9iBveyiaPyxIun7ciIegJtjv7tGes0v29Dz+8m 6QHd98fFX0r/hMMxCvv5mHMEmyxqki3XEnM0a4xXxcaEBcO3a4toCX3UdcBy1MzYUf3p l1yv03uBZgL8SO4Gkth+7XVY27UzZ20SYlyqDUr9DwhgT7qywlfnT0DHx3iP/hChYaJC sggYhmvhk3IefAqSWH1HLLGKZC3+cbWeqx0mOlJdeWfrZh28qgC4I0jRZZOoI4BjeADc s7Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TQzI3ZZA; 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 o6si1471109ejj.354.2021.01.06.15.28.13; Wed, 06 Jan 2021 15:28:38 -0800 (PST) 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=TQzI3ZZA; 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 S1727464AbhAFX1B (ORCPT + 99 others); Wed, 6 Jan 2021 18:27:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727310AbhAFX1B (ORCPT ); Wed, 6 Jan 2021 18:27:01 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3471C06179C for ; Wed, 6 Jan 2021 15:26:20 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id be12so2345323plb.4 for ; Wed, 06 Jan 2021 15:26:20 -0800 (PST) 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=PCAsqtwy69+o8i02BTFhqMq2pnNK2pwjyZKbY8yJvCg=; b=TQzI3ZZAIZR7N5/XA6IW5c05vDDv6qHDLHvkMipjpKzLDsmB1UER8y27JaUViP+8UY z8SN3vF53VgXbVlMR32A/ek3vNHxL6CTCi4SOyls9Dy0R/Fkbx0xGeB2L5qy4fshF205 1HkUwMcY3Awy3CPPvmJmwZjJMYUrPRb5TKUZU= 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=PCAsqtwy69+o8i02BTFhqMq2pnNK2pwjyZKbY8yJvCg=; b=gnnRO5UcH5UADv+9XMuJWHGhyn5kGDavI8RFTMcCSDUzFJGSs4BA2sR17S4kiGJ/Iu 2zJvg4aFbjgMuINPwjc+u/2TX3WqBG3kKb4SpHQFYKyNUkB6VAtW2O6uxaauDI7NgV1G R9sLbhhk+bZrGYB1fZW8canpHutYjI5H0QpJ7k+KEWDAgq4Iqm4NFn2QdennM+20Xqu7 ymqhBzplptf1EOjNROuW1r+AS7bVdllYKc3F6qMolDPBfi1hUrmOLR4IbCgDlwri0gfK pqLWg03cUdb0WvaAWzKuL43S7MErBNocNvlK7uQvYyMdxJLz05Qz9ZqQH7WJXpuxED4B lY3w== X-Gm-Message-State: AOAM5315IrxvXzDxGuHSOUMGT2bvJc86E5ZHWlamKz9LoCydw+fvj7pY GAw/e9BKIuWjpcR1IVtpXVgjvg== X-Received: by 2002:a17:90a:7085:: with SMTP id g5mr6430887pjk.132.1609975580280; Wed, 06 Jan 2021 15:26:20 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g16sm3489366pfh.187.2021.01.06.15.26.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 15:26:19 -0800 (PST) Date: Wed, 6 Jan 2021 15:26:18 -0800 From: Kees Cook To: Alexander Lobakin Cc: Thomas Bogendoerfer , Nathan Chancellor , Fangrui Song , Jiaxun Yang , Alex Smith , Ralf Baechle , Markos Chandras , linux-mips@vger.kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org, Sami Tolvanen Subject: Re: [PATCH v2 mips-next 2/4] MIPS: vmlinux.lds.S: add ".gnu.attributes" to DISCARDS Message-ID: <202101061518.67B9E0205@keescook> References: <20210106200713.31840-1-alobakin@pm.me> <20210106200801.31993-1-alobakin@pm.me> <20210106200801.31993-2-alobakin@pm.me> <202101061400.8F83981AE@keescook> <20210106223606.267756-1-alobakin@pm.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210106223606.267756-1-alobakin@pm.me> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 06, 2021 at 10:36:38PM +0000, Alexander Lobakin wrote: > From: Kees Cook > Date: Wed, 6 Jan 2021 14:07:07 -0800 > > > On Wed, Jan 06, 2021 at 08:08:19PM +0000, Alexander Lobakin wrote: > >> Discard GNU attributes at link time as kernel doesn't use it at all. > >> Solves a dozen of the following ld warnings (one per every file): > >> > >> mips-alpine-linux-musl-ld: warning: orphan section `.gnu.attributes' > >> from `arch/mips/kernel/head.o' being placed in section > >> `.gnu.attributes' > >> mips-alpine-linux-musl-ld: warning: orphan section `.gnu.attributes' > >> from `init/main.o' being placed in section `.gnu.attributes' > >> > >> Misc: sort DISCARDS section entries alphabetically. > > > > Hmm, I wonder what is causing the appearance of .eh_frame? With help I > > tracked down all the causes of this on x86, arm, and arm64, so that's > > why it's not in the asm-generic DISCARDS section. I suspect this could > > be cleaned up for mips too? > > I could take a look and hunt it down. Could you please give some refs on > what were the causes and solutions for the mentioned architectures? Sure! Here are the ones I could find again: 34b4a5c54c42 ("arm64/kernel: Remove needless Call Frame Information annotations") 6e0a66d10c5b ("arm64/build: Remove .eh_frame* sections due to unwind tables") d1c0272bc1c0 ("x86/boot/compressed: Remove, discard, or assert for unwanted sections") > > Similarly for .gnu.attributes. What is generating that? (Or, more > > specifically, why is it both being generated AND discarded?) > > On my setup, GNU Attributes consist of MIPS FP type (soft) and > (if I'm correct) MIPS GNU Hash tables. Ah, right, the soft-float markings sound correct to discard, IIUC. > By the way. I've built the kernel with LLVM stack (and found several > subjects for more patches) and, besides '.got', also got a fistful > of '.data..compoundliteral*' symbols (drivers/mtd/nand/spi/, > net/ipv6/ etc). Where should they be placed (rodata, rwdata, ...) > or they are anomalies of some kind and should be fixed somehow? Ah yeah, I've seen this before: https://lore.kernel.org/lkml/202010051345.2Q0cvqdM-lkp@intel.com/ https://lore.kernel.org/lkml/CAKwvOd=s53vUELe311VSjxt2_eQd+RGNCf__n+cV+R=PQ_CdXQ@mail.gmail.com/ And it looks like LTO trips over it too: https://lore.kernel.org/lkml/20201211184633.3213045-3-samitolvanen@google.com/ So I think the correct solution is to follow Sami's patch and add it to vmlinux.lds.h: -#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX* +#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* ... -#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* -#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* +#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L* +#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral* Can you include a patch for this in your series? Thanks! -- Kees Cook