Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp7321289pxv; Fri, 30 Jul 2021 16:00:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVWpF+8h52OtE801HeCi0qKByE5xipC8J/aO8pnQohaF6nYUtYcniP/xR377CrXTlO6wy8 X-Received: by 2002:a92:cb06:: with SMTP id s6mr2791790ilo.87.1627686038610; Fri, 30 Jul 2021 16:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627686038; cv=none; d=google.com; s=arc-20160816; b=D/G3oimvNdrxNVgALTRgkrF47fhP8G/qnhCDmnnoI3URQvY9nnUd6dt5bhNH3H1JyF hu8dYTBofP6EID9aIsj3tj46ggI/ox6IlKsTVaE8OtpDNuB2Q8YfD/BxjAbSITnWL+EW cbDz2WS/xubBjhnX6PP/Bb+ti7HkVYpWIo8eTvxFySDSFE7DK/YJtkdfKtV1FxTfRlFl 3BztTfCbmlOMf83datdAWsM0wAVb8YGbYPPawvhcmJ3ODjZt+1zVC7AM1waSsMQ7VGrL zIopU8jcO7zBBYF8jlo0w35UWUJk3BsxxgdLpw6yGXXNVkEOFPY98Rz4AbeCj01OzqKN J8gQ== 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=V2dvuvNFpryb1cvQLGlVrhhfsTfSnu/5+tUDbUkQolo=; b=Ra5isva7xNWB/YK5WJM01u2D3koIxOub0AL3q1V8fUFbNX8ZJMBidKMmEKncgAMmLv JRDkvX2QRFmCxmOr6/ndDZwvcfYPl0mYTbiJbKD9biI9iWEWcWKt6qJ0KWg/1AJfieMu MSOrCdcDedcp/R1NPJ/B3tpc/E/PePLWhRkscF3i4RDejrLQ+Wxi8W7u3fxfUYpsHL9V Qe3ozRnsKAXpvsiOIX/V8+kVl+5WYPAFZhgza4g9/e0EfoMgmQCWwyahebICTLOqio5/ UbHr27ob3pspzE72tN+oPgrjoptnusMEfisVOQ0KskEgxaWV5U10TbxmjBedHZbshIEe /NBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=sCMXYE8B; 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 a5si3887483ioo.37.2021.07.30.16.00.27; Fri, 30 Jul 2021 16:00:38 -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=sCMXYE8B; 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 S233273AbhG3W7s (ORCPT + 99 others); Fri, 30 Jul 2021 18:59:48 -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-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