Message ID | 20231018153147.167393-1-hamza.mahfooz@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp4876669vqb; Wed, 18 Oct 2023 08:32:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFLWw4M91MXadbsp7RPc64+w0eFqcdipoTrvwpuSbxjxpxAJP5uhw0u29FTj6SBZmryFYeA X-Received: by 2002:a17:902:760d:b0:1c6:2b3d:d918 with SMTP id k13-20020a170902760d00b001c62b3dd918mr5737201pll.3.1697643171690; Wed, 18 Oct 2023 08:32:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697643171; cv=pass; d=google.com; s=arc-20160816; b=YyT8cHU28BlN5lcgWQXFl3ffP073TXZDES7PEFg3o33I0wADydjMuB8EKVsr5rpiBR oB1S11zGBYon2uZ7ZGmnzFB3Pryx+38aNAoVzO/+6qQiy8Bh+y02dRZ4Wr438t2YKMqy NN0EQ4umB7lFqy9qEXRJnG3vlaDOtgAWRW36ETMaFB1uCzlYHzSIIl2CRRO3Dh3I/E/1 uIKkGicUfx8jiM9U3w+bSRvNXcAP5Ku0R6teNu5dMDm1MDU0u8FB0jXzF7p6co6ddH+c YI3yZZQcL87mJsRuiecmui+UqUrOP9hp7gvzBRXAdPXLOftoUs5s+XapXbVOE0h1Sc/b wAYg== ARC-Message-Signature: i=2; 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=t4EGmEG7/6VTSsdQ95kDL3H+dHVvpGu9d8qKc+oIY+I=; fh=0PnjhOJ24SnMLzYtKNrFO0j0HqDX3SBRyOrM3f29YRM=; b=c03t/OFjetkE9YLOZ6WNqGDuuRTnrXEdgNSkQ2kJtuT9A1Y7wuX/E68Xs4qvQY5awn 6eOTh7DcdIv/fHwTmdzGCJCdYUUE5b610d2qeRD1/SI1Jaa2eYtbD+TAE9kOLIpfPnZQ FbCpYSmey52uuEnlTyrhJ9LnQZnAtkYKYnKMWb8dE5PiV28ukgtHWVRtaeaeQQp7m1yx tQANBdaa1WNMTgfj/i15HKibuiumCGFl38bxuZ6kLxiDH2HdHXMv0eUDnUgY/Jv9vU5n rqrT9k0s8ZCOtVOwF4JUGgqxQPMD2yAiYmYT782h880UieYU6IFNVQuA/hjb3ps4yd9+ q4fQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Cl5teZ2e; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id u9-20020a17090341c900b001c754f13381si89298ple.455.2023.10.18.08.32.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 08:32:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Cl5teZ2e; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 92052820D5D0; Wed, 18 Oct 2023 08:32:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344066AbjJRPcj (ORCPT <rfc822;zwp10758@gmail.com> + 23 others); Wed, 18 Oct 2023 11:32:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231472AbjJRPch (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 18 Oct 2023 11:32:37 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2067.outbound.protection.outlook.com [40.107.94.67]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E64F7114 for <linux-kernel@vger.kernel.org>; Wed, 18 Oct 2023 08:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=clNpQy5ZybGfdVjI2sKzIxRKmWpuzX2t0fMpvx+gtGr6SdUPC4mHrXl5pKMa8b8DqLnPfteTwDyz5c0OaQFge4/w+Gsm3R5UvaQxoyDzrGmJs/Vp/F5HCBwwnaUme88ndNW3u6vUA9LRRZc6LsddGgat8OubVIfSJyfaHFDJKMuabd6RkKuprPmBwoMqgb1mlBGxlM1qgl1AIc0Y17eCJJYIjAj/oGjmQXOcvp2IPW596LhXumYxTIGMCK+6n6ZRNhTzJ/6Cc90iilwhunel7douEx4Jh9lha9kABb8qq1h+2E/N/EM6QmyAhs/hrcvNFmdfZZykckfwC+ubAZWyVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=t4EGmEG7/6VTSsdQ95kDL3H+dHVvpGu9d8qKc+oIY+I=; b=AgXkfxaz5NN2az36eZOBWUJ3V1J6QcnydNd0R4y148BY+dpzaz/gzvL1G4ExrEUuRJci9+dlt42o331CYIcWJ6bFhCTSKvpJ343JmLh+yRPi3uZ3BEYmIoE9zZfswBfm79Y/p3RuYAJPEgfHfXUY9j8wK4IXdhWoSyCqHuUyt1bwLPC7Edh92FjiCIYZgxcOrMP0EFTa3wnhwg9wl8YzKksp9F72OrfEB/mChcmP0kmOpmYpML5IjbbOTf3BjwA73cHEwcJwIkbaU3wDKmxqbEtL+pAk/Y+pmo1kUEjZlY0baJ4ojqHpKNg1WFHRdAdkm3cW1OE8g31pk7fTRRQjjA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t4EGmEG7/6VTSsdQ95kDL3H+dHVvpGu9d8qKc+oIY+I=; b=Cl5teZ2eVqGH/sCiuMwYQzFpmIrzDnu/BxbHiIASf/XVswi86yp1E+xQxUHWzcGlhvbwoWPg28J7hrqI3kr2E66VC1FklXRJ6PzANwpmYhfAj5Upc0zzUmWdorc5vvhpxaFg2tz6RyTj3zkHVEZImjLxmvYy/tNpC0cj7VkC/Pk= Received: from CH2PR18CA0024.namprd18.prod.outlook.com (2603:10b6:610:4f::34) by IA1PR12MB6018.namprd12.prod.outlook.com (2603:10b6:208:3d6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Wed, 18 Oct 2023 15:32:33 +0000 Received: from DS3PEPF000099D6.namprd04.prod.outlook.com (2603:10b6:610:4f:cafe::f0) by CH2PR18CA0024.outlook.office365.com (2603:10b6:610:4f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.21 via Frontend Transport; Wed, 18 Oct 2023 15:32:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D6.mail.protection.outlook.com (10.167.17.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Wed, 18 Oct 2023 15:32:32 +0000 Received: from hamza-pc.localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Wed, 18 Oct 2023 10:32:31 -0500 From: Hamza Mahfooz <hamza.mahfooz@amd.com> To: <linux-kernel@vger.kernel.org> CC: Rodrigo Siqueira <rodrigo.siqueira@amd.com>, Harry Wentland <harry.wentland@amd.com>, Alex Deucher <alexander.deucher@amd.com>, "Hamza Mahfooz" <hamza.mahfooz@amd.com>, Andrey Ryabinin <ryabinin.a.a@gmail.com>, Alexander Potapenko <glider@google.com>, Andrey Konovalov <andreyknvl@gmail.com>, Dmitry Vyukov <dvyukov@google.com>, Vincenzo Frascino <vincenzo.frascino@arm.com>, Marco Elver <elver@google.com>, "Nathan Chancellor" <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, <kasan-dev@googlegroups.com>, <llvm@lists.linux.dev> Subject: [PATCH] lib: Kconfig: disable dynamic sanitizers for test builds Date: Wed, 18 Oct 2023 11:31:47 -0400 Message-ID: <20231018153147.167393-1-hamza.mahfooz@amd.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D6:EE_|IA1PR12MB6018:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a9b12ee-24d8-449f-8024-08dbcfef7267 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mctP/W0JJzx5e8Gr0LMtnjvwecDuaiSjxQc0JAwdrUEgI52ao7heP2qJs/AjRaI4uxNjKcIaX+a1XmQMzQlJtdnbVrrGycazbHE1wn96wX6pI0Q2cfZIw2CiXtq1rthkYADckm0zVE2TePGJpAHpiPKoAXoBhWfnyX+pOmXs9UOSC+d0fbquVKZigbwzmUVMYBKcXz0gNi/89TjBK9jAKvq2BsPenHLB64J2/lDXjmQenYpwl4yD8Wa35NiE7nSVE8HnDo76kO5loD6dRNuwNmdNKBk1Xt3OGN7QeqUIno1XnRwTpQpnwnFx3KHzYOq6EST32iFZ2sucXBby52HRrrYUKDqrCW4Jm58KWtbYfISxDwAE0aBoQhDBbzX52bem1tvFaQuz4X5LKDK+Ps2Tfk0achvSMrv/2l+prssuff5qgOjo/nSloRtApFj/5maql8HfesCs/5u2C7oGxlomGWQCheLWWzZDh3e6V46io/T8Nro5/6FQE3A8dDDmzR1noVwOKUaXFgA/8ivrDPKE2iylFq9+5TYhqnkMKmFZ1hFGtWkALLSIEe0PdlNcc3DhAHgoGJOn5hMh3G7bPD+v869QZ3S2Un8xw1QvLav2vTL6IEmOjndxKQO5qJbL3VPQ/K6EosnmjiYUbsXy+knDtKWAJQVOlPs+bdNLZY4gAavafsMD7gAqgQF3SGLKugGTdDCe7RtgFjowSarCHVFN5U1S3Q3+l5a7ySo0pGs446zEBOzjk1SSCxuz3oMBcX4nCzvUAczYtEA42WlHwUW96IedgvNk8m+W9qIZaNHOIKQ= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(136003)(39860400002)(376002)(396003)(346002)(230922051799003)(186009)(1800799009)(82310400011)(64100799003)(451199024)(36840700001)(40470700004)(46966006)(478600001)(40460700003)(70206006)(70586007)(6916009)(54906003)(336012)(36756003)(40480700001)(16526019)(81166007)(426003)(1076003)(26005)(2616005)(86362001)(83380400001)(356005)(82740400003)(36860700001)(2906002)(7416002)(316002)(47076005)(41300700001)(6666004)(4326008)(5660300002)(8676002)(8936002)(44832011)(36900700001)(16060500005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 15:32:32.5794 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a9b12ee-24d8-449f-8024-08dbcfef7267 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D6.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6018 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 18 Oct 2023 08:32:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780107886223577126 X-GMAIL-MSGID: 1780107886223577126 |
Series |
lib: Kconfig: disable dynamic sanitizers for test builds
|
|
Commit Message
Hamza Mahfooz
Oct. 18, 2023, 3:31 p.m. UTC
kasan, kcsan and kmsan all have the tendency to blow up the stack
and there isn't a lot of value in having them enabled for test builds,
since they are intended to be useful for runtime debugging. So, disable
them for test builds.
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
---
lib/Kconfig.kasan | 1 +
lib/Kconfig.kcsan | 1 +
lib/Kconfig.kmsan | 1 +
3 files changed, 3 insertions(+)
Comments
On Wed, 18 Oct 2023 at 17:32, 'Hamza Mahfooz' via kasan-dev <kasan-dev@googlegroups.com> wrote: > > kasan, kcsan and kmsan all have the tendency to blow up the stack > and there isn't a lot of value in having them enabled for test builds, > since they are intended to be useful for runtime debugging. So, disable > them for test builds. > > Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> > --- > lib/Kconfig.kasan | 1 + > lib/Kconfig.kcsan | 1 + > lib/Kconfig.kmsan | 1 + > 3 files changed, 3 insertions(+) Do you have links to discussions that motivate this change? This has been discussed in the past. One recommendation is to adjust the build/test scripts to exclude some combination of configs if they are causing issues. Or we increase CONFIG_FRAME_WARN if one of them is enabled (KMSAN sets it to 0, 32-bit KASAN increases it a bit). That being said, we're aware of KASAN having had more issues and there are some suboptions that have been disabled because of that (like KASAN_STACK). I'm not sure if Clang's KASAN instrumentation has had some recent improvements (we did investigate it, but I can't recall what the outcome was [1]) - maybe try a more recent compiler? However, KCSAN and KMSAN shouldn't have any issues (if KMSAN is enabled, FRAME_WARN is 0). And having build tests with them enabled isn't useless at all: we're making sure that these tools (even though only for debugging), still work. We _want_ them to work during random build testing! Please share the concrete problem you're having, because this change will make things worse for everyone in the long run. [1] https://github.com/llvm/llvm-project/issues/38157 > diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan > index fdca89c05745..fbd85c4872c0 100644 > --- a/lib/Kconfig.kasan > +++ b/lib/Kconfig.kasan > @@ -38,6 +38,7 @@ menuconfig KASAN > CC_HAS_WORKING_NOSANITIZE_ADDRESS) || \ > HAVE_ARCH_KASAN_HW_TAGS > depends on (SLUB && SYSFS && !SLUB_TINY) || (SLAB && !DEBUG_SLAB) > + depends on !COMPILE_TEST > select STACKDEPOT_ALWAYS_INIT > help > Enables KASAN (Kernel Address Sanitizer) - a dynamic memory safety This also disables KASAN_HW_TAGS, which is actually enabled in production kernels and does not use any compiler instrumentation. > diff --git a/lib/Kconfig.kcsan b/lib/Kconfig.kcsan > index 609ddfc73de5..7bcefdbfb46f 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 > + depends on !COMPILE_TEST > select CONSTRUCTORS > select STACKTRACE > help > diff --git a/lib/Kconfig.kmsan b/lib/Kconfig.kmsan > index ef2c8f256c57..eb05c885d3fd 100644 > --- a/lib/Kconfig.kmsan > +++ b/lib/Kconfig.kmsan > @@ -13,6 +13,7 @@ config KMSAN > depends on HAVE_ARCH_KMSAN && HAVE_KMSAN_COMPILER > depends on SLUB && DEBUG_KERNEL && !KASAN && !KCSAN > depends on !PREEMPT_RT > + depends on !COMPILE_TEST KMSAN already selects FRAME_WARN of 0 and should not cause you any issues during build testing. Nack.
On Wed, Oct 18, 2023 at 9:22 AM Marco Elver <elver@google.com> wrote: > > That being said, we're aware of KASAN having had more issues and there > are some suboptions that have been disabled because of that (like > KASAN_STACK). I'm not sure if Clang's KASAN instrumentation has had > some recent improvements (we did investigate it, but I can't recall > what the outcome was [1]) - maybe try a more recent compiler? However, > KCSAN and KMSAN shouldn't have any issues (if KMSAN is enabled, > FRAME_WARN is 0). And having build tests with them enabled isn't > useless at all: we're making sure that these tools (even though only > for debugging), still work. We _want_ them to work during random build > testing! > > Please share the concrete problem you're having, because this change > will make things worse for everyone in the long run. > > [1] https://github.com/llvm/llvm-project/issues/38157 Some recent issues I discovered in clang that exacerbate stack usage in general, which is then amplified by KASAN: 1. https://github.com/llvm/llvm-project/issues/68746 2. https://github.com/llvm/llvm-project/issues/68747 Those are next up on my to fix list after what I'm working on now. I suspect that those aren't the last issues now that I've found a thread to pull on.
On 10/18/23 12:22, Marco Elver wrote: > On Wed, 18 Oct 2023 at 17:32, 'Hamza Mahfooz' via kasan-dev > <kasan-dev@googlegroups.com> wrote: >> >> kasan, kcsan and kmsan all have the tendency to blow up the stack >> and there isn't a lot of value in having them enabled for test builds, >> since they are intended to be useful for runtime debugging. So, disable >> them for test builds. >> >> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> >> --- >> lib/Kconfig.kasan | 1 + >> lib/Kconfig.kcsan | 1 + >> lib/Kconfig.kmsan | 1 + >> 3 files changed, 3 insertions(+) > > Do you have links to discussions that motivate this change? This has > been discussed in the past. One recommendation is to adjust the Sure, you can checkout: https://lore.kernel.org/amd-gfx/CADnq5_OyO9CHqahFvdnx7-8s9654udgdfhUntyxfjae+iHey0Q@mail.gmail.com/T/#m5d227dc1ef07b1f4953312287dce4568666c5e09 > build/test scripts to exclude some combination of configs if they are > causing issues. Or we increase CONFIG_FRAME_WARN if one of them is > enabled (KMSAN sets it to 0, 32-bit KASAN increases it a bit). > > That being said, we're aware of KASAN having had more issues and there > are some suboptions that have been disabled because of that (like > KASAN_STACK). I'm not sure if Clang's KASAN instrumentation has had > some recent improvements (we did investigate it, but I can't recall > what the outcome was [1]) - maybe try a more recent compiler? However, > KCSAN and KMSAN shouldn't have any issues (if KMSAN is enabled, This patch was initially motivated by KCSAN (i.e. I am able to get it to blow up the stack with a minimal .config). I don't mind dropping the other ones since I only included them because Nathan implied that they could cause similar issues. > FRAME_WARN is 0). And having build tests with them enabled isn't > useless at all: we're making sure that these tools (even though only > for debugging), still work. We _want_ them to work during random build > testing! > > Please share the concrete problem you're having, because this change > will make things worse for everyone in the long run. > > [1] https://github.com/llvm/llvm-project/issues/38157 > >> diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan >> index fdca89c05745..fbd85c4872c0 100644 >> --- a/lib/Kconfig.kasan >> +++ b/lib/Kconfig.kasan >> @@ -38,6 +38,7 @@ menuconfig KASAN >> CC_HAS_WORKING_NOSANITIZE_ADDRESS) || \ >> HAVE_ARCH_KASAN_HW_TAGS >> depends on (SLUB && SYSFS && !SLUB_TINY) || (SLAB && !DEBUG_SLAB) >> + depends on !COMPILE_TEST >> select STACKDEPOT_ALWAYS_INIT >> help >> Enables KASAN (Kernel Address Sanitizer) - a dynamic memory safety > > This also disables KASAN_HW_TAGS, which is actually enabled in > production kernels and does not use any compiler instrumentation. > >> diff --git a/lib/Kconfig.kcsan b/lib/Kconfig.kcsan >> index 609ddfc73de5..7bcefdbfb46f 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 >> + depends on !COMPILE_TEST >> select CONSTRUCTORS >> select STACKTRACE >> help >> diff --git a/lib/Kconfig.kmsan b/lib/Kconfig.kmsan >> index ef2c8f256c57..eb05c885d3fd 100644 >> --- a/lib/Kconfig.kmsan >> +++ b/lib/Kconfig.kmsan >> @@ -13,6 +13,7 @@ config KMSAN >> depends on HAVE_ARCH_KMSAN && HAVE_KMSAN_COMPILER >> depends on SLUB && DEBUG_KERNEL && !KASAN && !KCSAN >> depends on !PREEMPT_RT >> + depends on !COMPILE_TEST > > KMSAN already selects FRAME_WARN of 0 and should not cause you any > issues during build testing. > > Nack.
On Wed, 18 Oct 2023 at 18:43, Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: > > On 10/18/23 12:22, Marco Elver wrote: > > On Wed, 18 Oct 2023 at 17:32, 'Hamza Mahfooz' via kasan-dev > > <kasan-dev@googlegroups.com> wrote: > >> > >> kasan, kcsan and kmsan all have the tendency to blow up the stack > >> and there isn't a lot of value in having them enabled for test builds, > >> since they are intended to be useful for runtime debugging. So, disable > >> them for test builds. > >> > >> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> > >> --- > >> lib/Kconfig.kasan | 1 + > >> lib/Kconfig.kcsan | 1 + > >> lib/Kconfig.kmsan | 1 + > >> 3 files changed, 3 insertions(+) > > > > Do you have links to discussions that motivate this change? This has > > been discussed in the past. One recommendation is to adjust the > > Sure, you can checkout: > https://lore.kernel.org/amd-gfx/CADnq5_OyO9CHqahFvdnx7-8s9654udgdfhUntyxfjae+iHey0Q@mail.gmail.com/T/#m5d227dc1ef07b1f4953312287dce4568666c5e09 I would add this as a Link context to the patch. > > build/test scripts to exclude some combination of configs if they are > > causing issues. Or we increase CONFIG_FRAME_WARN if one of them is > > enabled (KMSAN sets it to 0, 32-bit KASAN increases it a bit). > > > > That being said, we're aware of KASAN having had more issues and there > > are some suboptions that have been disabled because of that (like > > KASAN_STACK). I'm not sure if Clang's KASAN instrumentation has had > > some recent improvements (we did investigate it, but I can't recall > > what the outcome was [1]) - maybe try a more recent compiler? However, > > KCSAN and KMSAN shouldn't have any issues (if KMSAN is enabled, > > This patch was initially motivated by KCSAN (i.e. I am able to get it to > blow up the stack with a minimal .config). I don't mind dropping the > other ones since I only included them because Nathan implied that they > could cause similar issues. !COMPILE_TEST is not the solution. Clearly from the link you provided build testing is helpful in catching early issues, so that these tools remain usable for everyone. But we know they use a little more stack, and the warnings need to be adjusted accordingly. My suggestion is to just increase FRAME_WARN for KCSAN, or set it to 0 (like for KMSAN). My guess is that first trying to increase it is the safer option. > > FRAME_WARN is 0). And having build tests with them enabled isn't > > useless at all: we're making sure that these tools (even though only > > for debugging), still work. We _want_ them to work during random build > > testing! > > > > Please share the concrete problem you're having, because this change > > will make things worse for everyone in the long run. > > > > [1] https://github.com/llvm/llvm-project/issues/38157 > > > >> diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan > >> index fdca89c05745..fbd85c4872c0 100644 > >> --- a/lib/Kconfig.kasan > >> +++ b/lib/Kconfig.kasan > >> @@ -38,6 +38,7 @@ menuconfig KASAN > >> CC_HAS_WORKING_NOSANITIZE_ADDRESS) || \ > >> HAVE_ARCH_KASAN_HW_TAGS > >> depends on (SLUB && SYSFS && !SLUB_TINY) || (SLAB && !DEBUG_SLAB) > >> + depends on !COMPILE_TEST > >> select STACKDEPOT_ALWAYS_INIT > >> help > >> Enables KASAN (Kernel Address Sanitizer) - a dynamic memory safety > > > > This also disables KASAN_HW_TAGS, which is actually enabled in > > production kernels and does not use any compiler instrumentation. > > > >> diff --git a/lib/Kconfig.kcsan b/lib/Kconfig.kcsan > >> index 609ddfc73de5..7bcefdbfb46f 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 > >> + depends on !COMPILE_TEST > >> select CONSTRUCTORS > >> select STACKTRACE > >> help > >> diff --git a/lib/Kconfig.kmsan b/lib/Kconfig.kmsan > >> index ef2c8f256c57..eb05c885d3fd 100644 > >> --- a/lib/Kconfig.kmsan > >> +++ b/lib/Kconfig.kmsan > >> @@ -13,6 +13,7 @@ config KMSAN > >> depends on HAVE_ARCH_KMSAN && HAVE_KMSAN_COMPILER > >> depends on SLUB && DEBUG_KERNEL && !KASAN && !KCSAN > >> depends on !PREEMPT_RT > >> + depends on !COMPILE_TEST > > > > KMSAN already selects FRAME_WARN of 0 and should not cause you any > > issues during build testing. > > > > Nack. > -- > Hamza >
On Wed, Oct 18, 2023 at 06:22:14PM +0200, Marco Elver wrote: > On Wed, 18 Oct 2023 at 17:32, 'Hamza Mahfooz' via kasan-dev > <kasan-dev@googlegroups.com> wrote: <snip> > > diff --git a/lib/Kconfig.kmsan b/lib/Kconfig.kmsan > > index ef2c8f256c57..eb05c885d3fd 100644 > > --- a/lib/Kconfig.kmsan > > +++ b/lib/Kconfig.kmsan > > @@ -13,6 +13,7 @@ config KMSAN > > depends on HAVE_ARCH_KMSAN && HAVE_KMSAN_COMPILER > > depends on SLUB && DEBUG_KERNEL && !KASAN && !KCSAN > > depends on !PREEMPT_RT > > + depends on !COMPILE_TEST > > KMSAN already selects FRAME_WARN of 0 and should not cause you any > issues during build testing. Yeah, this particular case is a bug in the AMDGPU dml2 Makefile, where CONFIG_FRAME_WARN=0 is not respected. diff --git a/drivers/gpu/drm/amd/display/dc/dml2/Makefile b/drivers/gpu/drm/amd/display/dc/dml2/Makefile index f35ed8de260d..66431525f2a0 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml2/Makefile @@ -61,7 +61,7 @@ ifneq ($(CONFIG_FRAME_WARN),0) frame_warn_flag := -Wframe-larger-than=2048 endif -CFLAGS_$(AMDDALPATH)/dc/dml2/display_mode_core.o := $(dml2_ccflags) -Wframe-larger-than=2048 +CFLAGS_$(AMDDALPATH)/dc/dml2/display_mode_core.o := $(dml2_ccflags) $(frame_warn_flag) CFLAGS_$(AMDDALPATH)/dc/dml2/display_mode_util.o := $(dml2_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml2/dml2_wrapper.o := $(dml2_ccflags) CFLAGS_$(AMDDALPATH)/dc/dml2/dml2_utils.o := $(dml2_ccflags) I will try to send that patch soon, unless one of the AMDGPU folks wants to beat me to it. Cheers, Nathan
diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index fdca89c05745..fbd85c4872c0 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan @@ -38,6 +38,7 @@ menuconfig KASAN CC_HAS_WORKING_NOSANITIZE_ADDRESS) || \ HAVE_ARCH_KASAN_HW_TAGS depends on (SLUB && SYSFS && !SLUB_TINY) || (SLAB && !DEBUG_SLAB) + depends on !COMPILE_TEST select STACKDEPOT_ALWAYS_INIT help Enables KASAN (Kernel Address Sanitizer) - a dynamic memory safety diff --git a/lib/Kconfig.kcsan b/lib/Kconfig.kcsan index 609ddfc73de5..7bcefdbfb46f 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 + depends on !COMPILE_TEST select CONSTRUCTORS select STACKTRACE help diff --git a/lib/Kconfig.kmsan b/lib/Kconfig.kmsan index ef2c8f256c57..eb05c885d3fd 100644 --- a/lib/Kconfig.kmsan +++ b/lib/Kconfig.kmsan @@ -13,6 +13,7 @@ config KMSAN depends on HAVE_ARCH_KMSAN && HAVE_KMSAN_COMPILER depends on SLUB && DEBUG_KERNEL && !KASAN && !KCSAN depends on !PREEMPT_RT + depends on !COMPILE_TEST select STACKDEPOT select STACKDEPOT_ALWAYS_INIT help