Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2108471pxb; Fri, 29 Jan 2021 13:29:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJxckfg8Jxex2QuHMKVBAoA3XwVMzwSM1vwyGjbCuyEAgIRKaU92tcGQ8ai4SHhbgKb6NBaf X-Received: by 2002:a05:6402:1a57:: with SMTP id bf23mr7453883edb.183.1611955780239; Fri, 29 Jan 2021 13:29:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611955780; cv=none; d=google.com; s=arc-20160816; b=qP6DTtVW452gYb9CLZz8D/M1YmDxaxEYx4n0Pn8NQK4lsLbq67roY7XH1Dg2ZxIeE7 i2pbIrrkPDMIU3/fDE+mt6nB9ExuIs9C5lzvfakcTjS42qvaYFeWtOWveeg7e+kIG/Zg E69NjkQ65eAlo3A5KlGjQ56zSuJBDTWJ0zuvtANYuHFdg+7YICTDLT9IZU6qsJbAELar LiGyVNaHQBzbwH3GqU0bI4cZEHEJISFYJ+RI6fqBoY5fjMaG92Ji8zhp9yinwz35N+OH cFf9MyGWXq0uY2g5rO1/ZYFJIhRUGo7mRUyl5hfuqbWJz/pEG2zhz0re/jDfDFU2gftI lQ+Q== 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=H9w4bRYBU76OhsJf1ZTWPcMTo7sL+1mxGISEO7vuja8=; b=qnZgw8NusvRzsT3fRLyMxHZf2al8B4mEjifC18tI1e1hywwAD1B/6qVDgQ8oAAfsKf QrnfT09SVF6fdC2t4wXDi2XkatlSuVAT/hCLxogOWidDTJTgvfH1LuLKKMC4Vexv4WnP YXqAYy5kvIhbm3cOdx1PqfxpE71BfALFVzm4ExdWpaZwpjJhMPhWEgY7yhrfMSwlwjjG HCc7Dm3bVVru+DUM2Wt94QpIQ+3cFSE5vpp3LAIejT1oQS/RytbN5x2RsCt0E6TksMIN /ZrTQLn2SobsPIVtNAekLb3VzggrmjUbgxfNsGuvJoMK3TT8/w3gvlWEt5ZYMUv3fQwX o1qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dX37CiuM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ws14si5754014ejb.625.2021.01.29.13.29.15; Fri, 29 Jan 2021 13:29:40 -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=@google.com header.s=20161025 header.b=dX37CiuM; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233384AbhA2V2X (ORCPT + 99 others); Fri, 29 Jan 2021 16:28:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233476AbhA2V2C (ORCPT ); Fri, 29 Jan 2021 16:28:02 -0500 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AC28C061573 for ; Fri, 29 Jan 2021 13:27:22 -0800 (PST) Received: by mail-pg1-x536.google.com with SMTP id o7so7538209pgl.1 for ; Fri, 29 Jan 2021 13:27:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=H9w4bRYBU76OhsJf1ZTWPcMTo7sL+1mxGISEO7vuja8=; b=dX37CiuMQ4aXIY1kTIUP4PzukKYIdr8eZlMKzfLK3WjreHdGbMMCpS72DXvwzzA9IV 8giEw0ti1ilbZGsXxxTOiyGvTSSzJdTbN4pGgc/KblDO4eO14V2rb7mu9vBPuoyIIthS ZNLBdoGTi3si0CJkE9Tnkd/9aDOmOY/D9ejKNxXwva0wMXoCdHckQza8LPBWNnvRzqMG 7zZG1uKe1W9c6nXhf/j3bi3DLlqFQdTralnrRT/urIXcmjBsRjW9wXv4eftDz0/TyMaL QfbU80bxqcSWC9XHgsc6YeV6ZdBYfsASx8pgCaZ4f3sFzsJSZsuSGnzxe1Qo2Q56D5S4 zAbg== 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=H9w4bRYBU76OhsJf1ZTWPcMTo7sL+1mxGISEO7vuja8=; b=iYCn+WZcnOEIXS4EehFWRYe8mLCdP0Tz5RFufruyttLGo6IVQduvUp6dx2fj28EsNF jAxaVIg52647Yr5K2hbtSBiRMSjs2ZKvyVh8A3lkOF0aRLTPSGqBEXCObPNVPFBBemvl eOyRE/Ix5qzTB1i/cV1Mzq0erOHxVbEyQs9GT6sdKyzD82Ucc/GjAwO0OiPtTkY5oZqZ 3ftgnuEowDs1GlRX5sdX1aJ4ap5abbBSxoKBs/en1OrqXyLE8Txekoa9VDUz9t//IZcc PNyEOtM+oK10oDOC0ouq7opeW4u6MdCnUiRSaqeO4qtZt1BQgtIGIKhYRrn5HcmrGT/E R6lw== X-Gm-Message-State: AOAM533V9P7OuejUygMbBY5Fr5zu+56Vpl0MovL+n8rsZIQ16UYSxSs2 4OzLbLuASuqwmoelY+2nxhSqWw== X-Received: by 2002:a65:4c4c:: with SMTP id l12mr6376812pgr.361.1611955641890; Fri, 29 Jan 2021 13:27:21 -0800 (PST) Received: from google.com ([2620:15c:2ce:0:a6ae:11ff:fe11:4abb]) by smtp.gmail.com with ESMTPSA id o190sm6607952pgo.50.2021.01.29.13.27.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jan 2021 13:27:21 -0800 (PST) Date: Fri, 29 Jan 2021 13:27:18 -0800 From: Fangrui Song To: Nick Desaulniers Cc: Nathan Chancellor , Arnd Bergmann , Kees Cook , LKML , clang-built-linux , kernel test robot Subject: Re: [PATCH] vmlinux.lds.h: Define SANTIZER_DISCARDS with CONFIG_GCOV_KERNEL=y Message-ID: <20210129212718.lf7kdw6d5rrtnt4q@google.com> References: <20210129201116.2658179-1-nathan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-01-29, Nick Desaulniers wrote: >On Fri, Jan 29, 2021 at 12:11 PM Nathan Chancellor wrote: >> >> clang produces .eh_frame sections when CONFIG_GCOV_KERNEL is enabled, >> even when -fno-asynchronous-unwind-tables is in KBUILD_CFLAGS: >> >> $ make CC=clang vmlinux >> ... >> ld: warning: orphan section `.eh_frame' from `init/main.o' being placed in section `.eh_frame' >> ld: warning: orphan section `.eh_frame' from `init/version.o' being placed in section `.eh_frame' >> ld: warning: orphan section `.eh_frame' from `init/do_mounts.o' being placed in section `.eh_frame' >> ld: warning: orphan section `.eh_frame' from `init/do_mounts_initrd.o' being placed in section `.eh_frame' >> ld: warning: orphan section `.eh_frame' from `init/initramfs.o' being placed in section `.eh_frame' >> ld: warning: orphan section `.eh_frame' from `init/calibrate.o' being placed in section `.eh_frame' >> ld: warning: orphan section `.eh_frame' from `init/init_task.o' being placed in section `.eh_frame' >> ... >> >> $ rg "GCOV_KERNEL|GCOV_PROFILE_ALL" .config >> CONFIG_GCOV_KERNEL=y >> CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y >> CONFIG_GCOV_PROFILE_ALL=y >> >> This was already handled for a couple of other options in >> commit d812db78288d ("vmlinux.lds.h: Avoid KASAN and KCSAN's unwanted >> sections") and there is an open LLVM bug for this issue. Take advantage >> of that section for this config as well so that there are no more orphan >> warnings. >> >> Link: https://bugs.llvm.org/show_bug.cgi?id=46478 >> Link: https://github.com/ClangBuiltLinux/linux/issues/1069 >> Reported-by: kernel test robot >> Signed-off-by: Nathan Chancellor > >Reviewed-by: Nick Desaulniers > >I suspect we're going to need to add module level attributes in LLVM >IR for these options, then check those when synthesizing new function >definitions within LLVM. At least we'll be able to point to this file >and say "hey, this is a general problem in LLVM, and here are 3 >specific cases now where it's a problem." Not a large problem, but >would help us save some bytes in the final object. LLVM is not >producing data in this section for all code, just these synthesized >routines. Maybe. There are also a long list of security features which may impose additional requirements. Adding a module flag metadata for each such feature will be a long battle. For .eh_frame, I think it is important/generic enough and can benefit other applications that deserves special handling (and I can look into it). For .init_array, I am not too sure.... >> --- >> include/asm-generic/vmlinux.lds.h | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h >> index b2b3d81b1535..f753fd449436 100644 >> --- a/include/asm-generic/vmlinux.lds.h >> +++ b/include/asm-generic/vmlinux.lds.h >> @@ -988,12 +988,13 @@ >> #endif >> >> /* >> - * Clang's -fsanitize=kernel-address and -fsanitize=thread produce >> + * Clang's -fsanitize=kernel-address, -fsanitize=thread, >> + * and -fprofile-arcs -ftest-coverage produce unwanted >> * unwanted sections (.eh_frame and .init_array.*), but >> * CONFIG_CONSTRUCTORS wants to keep any .init_array.* sections. >> * https://bugs.llvm.org/show_bug.cgi?id=46478 >> */ >> -#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN) >> +#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KCSAN) || defined(CONFIG_GCOV_KERNEL) >> # ifdef CONFIG_CONSTRUCTORS >> # define SANITIZER_DISCARDS \ >> *(.eh_frame) >> >> base-commit: bec4c2968fce2f44ce62d05288a633cd99a722eb >> -- >> 2.30.0 >> Drop -ftest-coverage. -ftest-coverage just produces .gcno and does not affect code generation. Reviewed-by: Fangrui Song