Message ID | 20230215091503.1490152-1-arnd@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp90295wrn; Wed, 15 Feb 2023 01:26:12 -0800 (PST) X-Google-Smtp-Source: AK7set9gg9WHwWUDGKyTqJJMS5QSawbFPuvFWPjL/ENLqUfevMkGTcJn5t6yc522KwduBTgrQ64j X-Received: by 2002:a05:6a20:a02a:b0:c2:fab0:3cac with SMTP id p42-20020a056a20a02a00b000c2fab03cacmr1428367pzj.0.1676453172346; Wed, 15 Feb 2023 01:26:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676453172; cv=none; d=google.com; s=arc-20160816; b=NyDm/DtxAxao5lj/cYDOrk56B1tLTMzQrYJB4YqwN8HGT1Arg04Xg0lMF4GG/3YMpv rgBHCLlhFk73N22spjkFq8530IKdePsr6t8RHlLE0EPEXA/91kg7HLMsMosHyJZnZusJ oH+b/ehMB5nOlLMcExleTHDXNMh3MxHgHvU/BSj7nUfDeoCm+0K1SCseheoiMY5K8OSB 3q7TEUrNYbcVpgGJXf/y69s5KzobV+y4g8kIMhQguP/fjZBlXhsJ0a+UZ3e0V8KpUF4w 1qX8xIQEPbBKeb/Qt9cCDC5ro0MAoGV/fozJrSg90FDwvkvaB5YK68L0AHROpOKrOg1G Qj3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=tVnX8LRLrV28bZnN0HkIOQtiDzMRz2i47aCP9xbgkyc=; b=y4sFXGjvMLL79f/M5WZZuHEL2LhEfNi3UGcLStsO02BlW6bIEtoq4msHbEumUFk6v5 /W5MygZqbk1Lw4KVXKUXjp6odb9MtnXUM9Gtz2za2EfhE3mkmEjJwoUWbOdE1eXmruz0 DXXrk9eG1VccoNq2BXGsjGgklNA+z10VjIqslMN/wdhlN93dOKfWbYZZ7nCzZNpVOWL8 S0XZ6eEtp1CwK++k2XH5a/3B+YKApjd4Lha9d3bV2x1AE3874Cm4O74Yqh/G+/kPSpqW VpnKwZJ2oaWvCbszxpUgjFqpfyX0IhAvKmK6MiWn7Ir4ZZlCLOBWsw4p4vGBK6IUbr5r L4bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AUqnqPEa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a63b941000000b004fbce6aad18si6193846pgo.390.2023.02.15.01.25.59; Wed, 15 Feb 2023 01:26:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AUqnqPEa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233700AbjBOJPU (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Wed, 15 Feb 2023 04:15:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233062AbjBOJPS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 15 Feb 2023 04:15:18 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20BAD1C580 for <linux-kernel@vger.kernel.org>; Wed, 15 Feb 2023 01:15:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 606E7B81DD3 for <linux-kernel@vger.kernel.org>; Wed, 15 Feb 2023 09:15:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 194F5C433EF; Wed, 15 Feb 2023 09:15:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676452514; bh=y7cRkpJo09cGA0dkXsSsNSqsjGzXn7zaL3SZgVnqhDk=; h=From:To:Cc:Subject:Date:From; b=AUqnqPEahiAxrb0RqO+5l9ghbt0rDwjtL3IygPOI7nTrg+eUwn37hXxWnpUQCuKiX LWX7o+FYS/mGpvEY6i9wttSPeLH71n2+y9xe4xycq1YJ/wIxEKLAfvxmlh9Ipfn6PC rGlgvBaFe2p5zO0MZE6RkWyAzE2BdBzRwcXPvewrLPXdk7Y6I13jFAUbfHfte1PutH zQPBQtEtT2qLBrNnGzxhT6oZZ4V46CnS1htnGkgoJz35WXA0JCZNrkeVYxpUrCo68f YvvupsLYlN+qumTyiZ2BpxGvDlaLH2ShHOJDwfzviLpmhYIB8ryEFU3Eev11h+c2RL qTPgF1xvxpQeQ== From: Arnd Bergmann <arnd@kernel.org> To: Marco Elver <elver@google.com> Cc: Arnd Bergmann <arnd@arndb.de>, Kees Cook <keescook@chromium.org>, Dmitry Vyukov <dvyukov@google.com>, Josh Poimboeuf <jpoimboe@kernel.org>, "Peter Zijlstra (Intel)" <peterz@infradead.org>, Miroslav Benes <mbenes@suse.cz>, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH] kcsan: select CONFIG_CONSTRUCTORS Date: Wed, 15 Feb 2023 10:14:48 +0100 Message-Id: <20230215091503.1490152-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757888561691924044?= X-GMAIL-MSGID: =?utf-8?q?1757888561691924044?= |
Series |
kcsan: select CONFIG_CONSTRUCTORS
|
|
Commit Message
Arnd Bergmann
Feb. 15, 2023, 9:14 a.m. UTC
From: Arnd Bergmann <arnd@arndb.de> Building a kcsan enabled kernel for x86_64 with gcc-11 results in a lot of build warnings or errors without CONFIG_CONSTRUCTORS: x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/copy_mc.o' x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/cpu.o' x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/csum-partial_64.o' x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/csum-wrappers_64.o' x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/insn-eval.o' x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/insn.o' x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/misc.o' The same thing has been reported for mips64. I can't reproduce it for any other compiler version, so I don't know if constructors are always required here or if this is a gcc-11 specific implementation detail. I see no harm in always enabling constructors here, and this reliably fixes the build warnings for me. Link: https://lore.kernel.org/lkml/202204181801.r3MMkwJv-lkp@intel.com/T/ Cc: Kees Cook <keescook@chromium.org> See-also: 3e6631485fae ("vmlinux.lds.h: Keep .ctors.* with .ctors") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- lib/Kconfig.kcsan | 1 + 1 file changed, 1 insertion(+)
Comments
On Wed, 15 Feb 2023 at 10:15, Arnd Bergmann <arnd@kernel.org> wrote: > > From: Arnd Bergmann <arnd@arndb.de> > > Building a kcsan enabled kernel for x86_64 with gcc-11 results in a lot > of build warnings or errors without CONFIG_CONSTRUCTORS: > > x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/copy_mc.o' > x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/cpu.o' > x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/csum-partial_64.o' > x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/csum-wrappers_64.o' > x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/insn-eval.o' > x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/insn.o' > x86_64-linux-ld: error: unplaced orphan section `.ctors.65436' from `arch/x86/lib/misc.o' > > The same thing has been reported for mips64. I can't reproduce it for > any other compiler version, so I don't know if constructors are always > required here or if this is a gcc-11 specific implementation detail. > > I see no harm in always enabling constructors here, and this reliably > fixes the build warnings for me. > > Link: https://lore.kernel.org/lkml/202204181801.r3MMkwJv-lkp@intel.com/T/ > Cc: Kees Cook <keescook@chromium.org> > See-also: 3e6631485fae ("vmlinux.lds.h: Keep .ctors.* with .ctors") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Marco Elver <elver@google.com> Looks like KASAN does select CONSTRUCTORS already, so KCSAN should as well. Do you have a tree to take this through, or should it go through -rcu as usual for KCSAN patches? Thanks, -- Marco > --- > lib/Kconfig.kcsan | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/lib/Kconfig.kcsan b/lib/Kconfig.kcsan > index 4dedd61e5192..609ddfc73de5 100644 > --- a/lib/Kconfig.kcsan > +++ b/lib/Kconfig.kcsan > @@ -14,6 +14,7 @@ menuconfig KCSAN > bool "KCSAN: dynamic data race detector" > depends on HAVE_ARCH_KCSAN && HAVE_KCSAN_COMPILER > depends on DEBUG_KERNEL && !KASAN > + select CONSTRUCTORS > select STACKTRACE > help > The Kernel Concurrency Sanitizer (KCSAN) is a dynamic > -- > 2.39.1 >
On Wed, Feb 15, 2023, at 10:25, Marco Elver wrote: > On Wed, 15 Feb 2023 at 10:15, Arnd Bergmann <arnd@kernel.org> wrote: > Looks like KASAN does select CONSTRUCTORS already, so KCSAN should as well. > > Do you have a tree to take this through, or should it go through -rcu > as usual for KCSAN patches? I don't have a tree for taking these build fixes, so it would be good if you could forward it as appropriate. Thanks, Arnd
On Wed, Feb 15, 2023 at 10:48:11AM +0100, Arnd Bergmann wrote: > On Wed, Feb 15, 2023, at 10:25, Marco Elver wrote: > > On Wed, 15 Feb 2023 at 10:15, Arnd Bergmann <arnd@kernel.org> wrote: > > > Looks like KASAN does select CONSTRUCTORS already, so KCSAN should as well. > > > > Do you have a tree to take this through, or should it go through -rcu > > as usual for KCSAN patches? > > I don't have a tree for taking these build fixes, so it would be good if you could forward it as appropriate. Queued and pushed, thank you both! Is this ready for the upcoming merge window, or would you rather that I hold off until the v6.4 merge window? (I am tempted to treat this as a bug fix, thus sending it earlier rather than later, but figured I should ask.) Thanx, Paul
On Wed, 15 Feb 2023 at 23:42, Paul E. McKenney <paulmck@kernel.org> wrote: > > On Wed, Feb 15, 2023 at 10:48:11AM +0100, Arnd Bergmann wrote: > > On Wed, Feb 15, 2023, at 10:25, Marco Elver wrote: > > > On Wed, 15 Feb 2023 at 10:15, Arnd Bergmann <arnd@kernel.org> wrote: > > > > > Looks like KASAN does select CONSTRUCTORS already, so KCSAN should as well. > > > > > > Do you have a tree to take this through, or should it go through -rcu > > > as usual for KCSAN patches? > > > > I don't have a tree for taking these build fixes, so it would be good if you could forward it as appropriate. > > Queued and pushed, thank you both! > > Is this ready for the upcoming merge window, or would you rather that > I hold off until the v6.4 merge window? (I am tempted to treat this > as a bug fix, thus sending it earlier rather than later, but figured I > should ask.) I'd consider it a bug fix. If it survives the usual -next exposure, no harm in sending it as a fix. Thanks, -- Marco
On Thu, Feb 16, 2023 at 08:00:00AM +0100, Marco Elver wrote: > On Wed, 15 Feb 2023 at 23:42, Paul E. McKenney <paulmck@kernel.org> wrote: > > > > On Wed, Feb 15, 2023 at 10:48:11AM +0100, Arnd Bergmann wrote: > > > On Wed, Feb 15, 2023, at 10:25, Marco Elver wrote: > > > > On Wed, 15 Feb 2023 at 10:15, Arnd Bergmann <arnd@kernel.org> wrote: > > > > > > > Looks like KASAN does select CONSTRUCTORS already, so KCSAN should as well. > > > > > > > > Do you have a tree to take this through, or should it go through -rcu > > > > as usual for KCSAN patches? > > > > > > I don't have a tree for taking these build fixes, so it would be good if you could forward it as appropriate. > > > > Queued and pushed, thank you both! > > > > Is this ready for the upcoming merge window, or would you rather that > > I hold off until the v6.4 merge window? (I am tempted to treat this > > as a bug fix, thus sending it earlier rather than later, but figured I > > should ask.) > > I'd consider it a bug fix. If it survives the usual -next exposure, no > harm in sending it as a fix. It passed overnight tests, so I have sent it along to -next. If there are no issues, I will push it by the end of this coming week (which is the first weke of the merge window). Thanx, Paul
diff --git a/lib/Kconfig.kcsan b/lib/Kconfig.kcsan index 4dedd61e5192..609ddfc73de5 100644 --- a/lib/Kconfig.kcsan +++ b/lib/Kconfig.kcsan @@ -14,6 +14,7 @@ menuconfig KCSAN bool "KCSAN: dynamic data race detector" depends on HAVE_ARCH_KCSAN && HAVE_KCSAN_COMPILER depends on DEBUG_KERNEL && !KASAN + select CONSTRUCTORS select STACKTRACE help The Kernel Concurrency Sanitizer (KCSAN) is a dynamic