Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp122693pxy; Sat, 31 Jul 2021 02:11:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6dqPZlDIetn8R8up3Zlj5AbKYJ0ppmQfV5MNkp1EokEGnpeTD+iLwYcQAMSraQScJML4O X-Received: by 2002:a17:906:f20a:: with SMTP id gt10mr6737262ejb.267.1627722676235; Sat, 31 Jul 2021 02:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627722676; cv=none; d=google.com; s=arc-20160816; b=Zd3Mz+Fb03lEiVh6yLbTy9XNjpOM+9ne4EedtdTrEV9JPass9zyk1TSxZMc/Rvpc/f II0E5udFVfbsw3Xrj/xdb7X9HA/LJMMgV/BaBrqb5kOFKauD3UBQAOX4P/ZTjz5eG1uf a0SbMFuHiCyL5Egpx89Z5X/QCK5NfuSbZpvhTLtHi3UyKSTVylYmoCRJuusuwFdqsY7P v56DZi4HFJ/5sfSj2mvKRtTzXZPL4qZogCd7kPSwQvGrqTflC5/qPtG1GmfxGYkUwcCd 8B3sbsfaKy55E215yitZGgvreSa7hyIyFf92hVD4jlv1kglZVJcRYop11s7JWZ2JeEhC ivCg== 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=vaAWrkzE49kpA8JCIiCiOMwaEcjf5J0qZweefCaV6Js=; b=Xrr2vrLCuaHh5JCLz+qxHvqxYo2lbtXxpu1U/+w+rfXiABQvKGVtsOGC5BCAGeKmC5 QRmexna3yvNnwhqurSXoPTSkOGCQm0Ue5rQOD8Zk/pq6r0CQ4nHmLRzpl67D6tZwCbL0 JlreJWdp5gPyUQnSIvyaZtbhabI4/BG6xeFC3oy9MG9IUG9I/tb98JuTPGCEkHWP4Z7I aWZTDxvU+JRmK/fazSqJefIL0PmSsT0IJviYiJoMpMBwt56UzW1WGu3vi8RU8s9Ua8Bl qcnPTtrvp7bwkIvk3C6YhuXzsqvqyt0BoSPO2g+drtazKjBtFYr7u16Us41bdT8P+LNZ ASEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Gp8ddgcS; 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 w5si855509edd.82.2021.07.31.02.10.52; Sat, 31 Jul 2021 02:11:16 -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=Gp8ddgcS; 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 S232473AbhGaJJO (ORCPT + 99 others); Sat, 31 Jul 2021 05:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbhGaJJO (ORCPT ); Sat, 31 Jul 2021 05:09:14 -0400 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73DFAC0613D3 for ; Sat, 31 Jul 2021 02:09:07 -0700 (PDT) Received: by mail-ot1-x334.google.com with SMTP id 48-20020a9d0bb30000b02904cd671b911bso12246895oth.1 for ; Sat, 31 Jul 2021 02:09:07 -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=vaAWrkzE49kpA8JCIiCiOMwaEcjf5J0qZweefCaV6Js=; b=Gp8ddgcSsdz7JROBXknYU+v2p1kXvS2NTlufoSvXs2xSBqOzoSTqrTEoNNr4cvOn/L X2w8AjJPeuQf1ZWGpOsHKDhbvsTjlLuoiLUsck5u6sK+JfUFcHbrC9i3E4srckgJzSMm 1mfA/Rq4fQZDS3lXE0loMMIOduFdV4+GHh1jTgbTsde8dy8dU3IZdLSppJh4fako4XRi KMVV9x2djecxSD9XfPH68Cb4xxfF5vTVTcasDIEWSDpbX3kJaxnIkVGmJTkxH4aXDlCq RhegliyZROtvGJM6wZva2mOMui6QylvPWju4wqUMZnoLHag3sA08TXGsfAVbRZZYAde6 m3FQ== 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=vaAWrkzE49kpA8JCIiCiOMwaEcjf5J0qZweefCaV6Js=; b=tbiMNIDxabGLIEL+M6RGpzkCMQEkE3afifHfCnBsKX7dVsF5Wyox5iTzckQG0qw+Cu Zv+hfSMMYwYSQY2z3B4nTC/UDR+Dc28LxKbKhsIBOzVKuVvrASNnHA5Ozcu1cDTv/9Sj /en2vxSc0Hjkn15/NPFO+QNtPLZnyBc3xVlPYDsLNZAGBwzvSsOv8/SmkgjPhXhGzMBc VedLOeqXl9ZTu+qxnz373rUeSoDSxV00DQD0879awiYd7zR8vWMDkRZnk2FN2I/bUDtY bOjranWvqZAjuvxrl9StGIF0izzWVBF01Eb7i1pstzbOJG4do8/QPbQwSP0MhtHztkaX Pf3g== X-Gm-Message-State: AOAM533D4zZLYRW0vGxm0d60zGoa4hFDfNQGHoA3U6nRhsEp/XZ0pllV Fl8TPJHovyMQbAOh/m9AElgdZsJL0KbnUPRtayvv+g== X-Received: by 2002:a05:6830:23a7:: with SMTP id m7mr5218486ots.17.1627722546365; Sat, 31 Jul 2021 02:09:06 -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: Marco Elver Date: Sat, 31 Jul 2021 11:08:54 +0200 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 , Nick Desaulniers , Fangrui Song , 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 Sat, 31 Jul 2021 at 04:33, 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 Acked-by: Marco Elver For KASAN module_ctors are very much required to support detecting globals out-of-bounds: https://reviews.llvm.org/D81390 For KASAN the test would have revealed that at the latest. KCSAN does not yet have much use for the module_ctors, but it may change in future, so keeping them all was the right call. Thanks, -- Marco > --- > > 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 >