From patchwork Wed Feb 15 09:14:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 57443 Return-Path: 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 + 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 ); 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 ; 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 ; 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 To: Marco Elver Cc: Arnd Bergmann , Kees Cook , Dmitry Vyukov , Josh Poimboeuf , "Peter Zijlstra (Intel)" , Miroslav Benes , 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 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: 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?= From: Arnd Bergmann 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 See-also: 3e6631485fae ("vmlinux.lds.h: Keep .ctors.* with .ctors") Signed-off-by: Arnd Bergmann Reviewed-by: Marco Elver --- 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