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=-25.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL 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 4105FC4320A for ; Fri, 30 Jul 2021 22:59:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FE1A601FC for ; Fri, 30 Jul 2021 22:59:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233461AbhG3W7t (ORCPT ); Fri, 30 Jul 2021 18:59:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229604AbhG3W7r (ORCPT ); Fri, 30 Jul 2021 18:59:47 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41711C06175F for ; Fri, 30 Jul 2021 15:59:42 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id u2so4559214plg.10 for ; Fri, 30 Jul 2021 15:59:42 -0700 (PDT) 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=V2dvuvNFpryb1cvQLGlVrhhfsTfSnu/5+tUDbUkQolo=; b=sCMXYE8BPVu/dKEp3RQsjKh5BuJC1zZZb4+9CntVolv0Jbrb/288cSPWlbgdYB6uV8 WJXTQDArwMcZuEtSPpFWbXRWRAWq6AvaG6OKGWySn3W8iDAsfRyVvtdb1/efkiAlUIUW n7KgCTW1pAQ8LyKDcl2tVh/E5CWElNXrwCZmEevGnBD7Pn0mnmpbVXIjrhbcv4C5m963 eoeYNJGNPQUSRSipE7Kfd9amGgFWJIUqyeyILlgygBlypxHV+pfv0CgeLk7sG0mF4Lc/ MdIVR+f/eT+lmsmqc7z9fRROYhrxD8JPegsJJ+4ESDXsUCKfqNjW34r9okUBJARXwgH9 6rUg== 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=V2dvuvNFpryb1cvQLGlVrhhfsTfSnu/5+tUDbUkQolo=; b=QQ4jGiMea69g0j6uSoFkDAB4NL9/rkVgzEBPFh5DQU5STn76HX8N3GsJ6Ulgce6jmJ ndII3PB5ETNQAyoWS55PqHWsKLcx9KnoDy41ORUQG4+Sm6RGR2gWUDeYSYX1jf1Rzpo0 O4YOjTz2ZSoVX5IP3eg5v+cfpujsezcd2i6MB+Wu95x2i/b/gCgJrG29Tee1GHTyXoS4 Zg+yOUyoocyOCLdFGJBDjmOe/1O4sLNdyImVC1I/KGp4hAmjsDXFwI1xNOmU2TGtHJD6 mu0+gCsOTus6xSoW76CUowuEC6R2tc/WJITiFuoeNbfWTVeDsSs7ej1zIZ3iBbRCeOVS ZxEg== X-Gm-Message-State: AOAM530Ne7Dkrc+DvTrfpuj4yxkXznuUv9cwZO+dxL0xtpRk8fpgBFIX PA/uieKWkrdBeLEqxzIyhxJiyA== X-Google-Smtp-Source: ABdhPJy5fOXlF8mlpIqzL8jUb2C6BgbXxOZyyEYs4oEPgoSBaa6t7Y9gQXLYxESft75tpRgo3kepEw== X-Received: by 2002:a17:902:b713:b029:12b:b249:693f with SMTP id d19-20020a170902b713b029012bb249693fmr4511815pls.17.1627685981632; Fri, 30 Jul 2021 15:59:41 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:160:995:7f22:dc59]) by smtp.gmail.com with ESMTPSA id a20sm3235150pjh.46.2021.07.30.15.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jul 2021 15:59:40 -0700 (PDT) Date: Fri, 30 Jul 2021 15:59:36 -0700 From: Fangrui Song To: Nathan Chancellor Cc: Nick Desaulniers , Kees Cook , Arnd Bergmann , 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 Subject: Re: [PATCH] vmlinux.lds.h: Handle clang's module.{c,d}tor sections Message-ID: <20210730225936.ce3hcjdg2sptvbh7@google.com> References: <20210730223815.1382706-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-07-30, Nick Desaulniers wrote: >On Fri, Jul 30, 2021 at 3:38 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' > >^ .text.tsan.* I was wondering why the orphan section warning only arose recently. Now I see: the function asan.module_ctor has the SHF_GNU_RETAIN flag, so it is in a separate section even with -fno-function-sections (default). It seems that with -ffunction-sections the issue should have been caught much earlier. >> >> 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 >> --- >> 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..3b79b1e76556 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.asan.*) \ > >Will this match .text.tsan.module_ctor? asan.module_ctor is the only function AddressSanitizer synthesizes in the instrumented translation unit. There is no function called "asan". (Even if a function "asan" exists due to -ffunction-sections -funique-section-names, TEXT_MAIN will match .text.asan, so the .text.asan pattern will match nothing.) >Do we want to add these conditionally on >CONFIG_KASAN_GENERIC/CONFIG_KCSAN like we do for SANITIZER_DISCARDS? > >> TEXT_CFI_JT \ >> MEM_KEEP(init.text*) \ >> MEM_KEEP(exit.text*) \ >> >> base-commit: 4669e13cd67f8532be12815ed3d37e775a9bdc16 >> -- > > >-- >Thanks, >~Nick Desaulniers