Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1767675pxy; Mon, 2 Aug 2021 09:43:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwerfP0Y6S6WD7owNOnNC5rGG7vbSHHVyfNrRGI+NlktqJjhiR93bMY7H+eH5T/fM3CuuJB X-Received: by 2002:a17:906:cecc:: with SMTP id si12mr16590746ejb.335.1627922606513; Mon, 02 Aug 2021 09:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627922606; cv=none; d=google.com; s=arc-20160816; b=uKTtf3NswAtH6EcRRI3phytd9LjUtvhaL37wkTpIMBBebG216Tfxp4ZzPQ4JqgfKQJ 6fMtaiMGeu13mj28ZiXej7h1ZBMk1C6B2CYMKkJJ5RH5g+/ZDWg+Fiq4dZGWTwQHsIcr sYkLPr8H44pVr4G35ZZt0PGvtj9/d8R4NGnk55F7GE5h9pDPl1J7BI3Gq2cm23qOgizY Ys45BkeEt0NXqDQAX2W6jKdhP35TmeRvzT8ZKDJWQwmReOeLj7euMp8cjR61Bw2r6BKC 3rN2ZiWNFOlrgxPLpsZ8RYH5u2YInzwEdseRVjglVFemR9cfnV0BO/BpTe1F8ecnp9Ap ZGJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Mpn7PG82ctGVboEylkUCiZGj+PBEuHBMPwSjZySIC0s=; b=BAoAjOf4LTJJDY+PACUGMd0BcYfbsuQ7Acp6lc5pEYdFHVlOy6o7N5y0mMFdJ4WaIO FypKXossC3d+bMm+87rGDkxdpMR6c04ovLklRnGN+o1V9MNZabAI11GNO8FXrz9jP/Dn 3m3S2vFfGkKj9wDnmuy0o6YYZAECKvRCsELqV0WuIJVkssjfabvYXWUcYceNomhIk7We b2w1DDvMhu2EykNu1hNb5BsCsGZPwsWVJbCgQrgCo0SB53WUjsgCsn36yaFwa3bET3oX irh3RUq+6Vh0vG29LkUU4MCf2ZLLcptxzYmR94VLGb325UC4q89IDPBxYyQKzKOLVVRR to3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Iqhh7BSh; 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 d21si10426742eds.131.2021.08.02.09.43.03; Mon, 02 Aug 2021 09:43:26 -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=@google.com header.s=20161025 header.b=Iqhh7BSh; 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 S232056AbhHBQlU (ORCPT + 99 others); Mon, 2 Aug 2021 12:41:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbhHBQlU (ORCPT ); Mon, 2 Aug 2021 12:41:20 -0400 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5790BC06175F for ; Mon, 2 Aug 2021 09:41:10 -0700 (PDT) Received: by mail-lf1-x130.google.com with SMTP id m13so34779071lfg.13 for ; Mon, 02 Aug 2021 09:41:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Mpn7PG82ctGVboEylkUCiZGj+PBEuHBMPwSjZySIC0s=; b=Iqhh7BSh+B86kg39xX8VkoRpnOqC8KFwDcrhQ+zu0THerTrxEbIkP37rvWmRxSw7jE 84lg7TEWZymIsscS6kgojGiOacOUw4zLVFhs2xve/OiqUmzeLsTg07NjjN3CVTJhSyiz pP0W7M6r5fBu60lsQqlydDLgx8LXb271JeGxPQLKu37ohhWTDKPuHKqtGLxsb3xqmkB/ 99vi9xftpRnY2i6z97YkD64tr66TpzVS7o8SkKEq2nnxlRyl1Uowv9hYmvXLoTZaLH4q tCHu6hKlqbaPMTGB5hQ+K5mOikgCrJcOm+byKWkPw7KLMkShqXUuX191a/bqzjxirdiV g66g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Mpn7PG82ctGVboEylkUCiZGj+PBEuHBMPwSjZySIC0s=; b=Vy8f/xDeHQafSmCHqcV6RXlDYpa2SIMhaZgMokYjqwibF9UuaRO/YgjFwN8obGQsF8 7dRyhK8Joi25R10Qe9sjSNOaF0yfp1osTUjoTRN9a4brv3qK6gMyVdA0eg38WawGHzAE ZIJZ/cAqznFi44uBCB1Dh4g3Gn2KW5HpR8S+smg5JVOlKg7RYMt9sFHYDK9j5q+OMUr4 tjCv+dC5/C78Q1oq0iKoaDE5JhxEIxXZD2T/T77l9jRK5cTL3lLNAn6tLJNGD2DvhLe4 s0BBVSgMnScISLvWz28eLYq/nVEfChNKQHljWGQNuxiZZko2ES0ZAcAGYigqSOoPiQ8z olsw== X-Gm-Message-State: AOAM532ZTnozd7kXnrlj+oDDjPF0Bjgk+JhAEiB5XQVsUE4lFlqdmGNx Ahnfzp1qbu4HPmNCu0J9ByZ5NYT1ZgbDHGnNTp67qQ== X-Received: by 2002:ac2:4ac6:: with SMTP id m6mr13931061lfp.73.1627922468420; Mon, 02 Aug 2021 09:41:08 -0700 (PDT) MIME-Version: 1.0 References: <20210730223815.1382706-1-nathan@kernel.org> <20210731023107.1932981-1-nathan@kernel.org> In-Reply-To: <20210731023107.1932981-1-nathan@kernel.org> From: Nick Desaulniers Date: Mon, 2 Aug 2021 09:40:56 -0700 Message-ID: Subject: Re: [PATCH v2] vmlinux.lds.h: Handle clang's module.{c,d}tor sections To: Nathan Chancellor Cc: Kees Cook , Arnd Bergmann , Fangrui Song , Marco Elver , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, clang-built-linux@googlegroups.com, stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 30, 2021 at 7:33 PM Nathan Chancellor wrote: > > A recent change in LLVM causes module_{c,d}tor sections to appear when > CONFIG_K{A,C}SAN are enabled, which results in orphan section warnings > because these are not handled anywhere: > > ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.asan.module_ctor) is being placed in '.text.asan.module_ctor' > ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.asan.module_dtor) is being placed in '.text.asan.module_dtor' > ld.lld: warning: arch/x86/pci/built-in.a(legacy.o):(.text.tsan.module_ctor) is being placed in '.text.tsan.module_ctor' > > Fangrui explains: "the function asan.module_ctor has the SHF_GNU_RETAIN > flag, so it is in a separate section even with -fno-function-sections > (default)". > > Place them in the TEXT_TEXT section so that these technologies continue > to work with the newer compiler versions. All of the KASAN and KCSAN > KUnit tests continue to pass after this change. > > Cc: stable@vger.kernel.org > Link: https://github.com/ClangBuiltLinux/linux/issues/1432 > Link: https://github.com/llvm/llvm-project/commit/7b789562244ee941b7bf2cefeb3fc08a59a01865 > Signed-off-by: Nathan Chancellor Reviewed-by: Nick Desaulniers > --- > > v1 -> v2: > > * Fix inclusion of .text.tsan.* (Nick) > > * Drop .text.asan as it does not exist plus it would be handled by a > different line (Fangrui) > > * Add Fangrui's explanation about why the LLVM commit caused these > sections to appear. > > include/asm-generic/vmlinux.lds.h | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h > index 17325416e2de..62669b36a772 100644 > --- a/include/asm-generic/vmlinux.lds.h > +++ b/include/asm-generic/vmlinux.lds.h > @@ -586,6 +586,7 @@ > NOINSTR_TEXT \ > *(.text..refcount) \ > *(.ref.text) \ > + *(.text.asan.* .text.tsan.*) \ > TEXT_CFI_JT \ > MEM_KEEP(init.text*) \ > MEM_KEEP(exit.text*) \ > > base-commit: 4669e13cd67f8532be12815ed3d37e775a9bdc16 > -- > 2.32.0.264.g75ae10bc75 > -- Thanks, ~Nick Desaulniers