Message ID | 20231018182412.80291-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 ib8csp4985658vqb; Wed, 18 Oct 2023 11:24:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGafQgoIpLIUKKasWcDWh/0QqfRbLaIPfLzdq6OUzuBeB3zLtmxOFld+JGr7j52Z4oIpl7J X-Received: by 2002:a17:903:41cc:b0:1b8:8682:62fb with SMTP id u12-20020a17090341cc00b001b8868262fbmr9047811ple.4.1697653496696; Wed, 18 Oct 2023 11:24:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697653496; cv=pass; d=google.com; s=arc-20160816; b=nVHWckR2XZ9ltjuqUyJS0ivC8NOgR2XC2POVfi+vCB0VDIE6lzharpIpMGr3RSUIdA 3PhUhUyHQOJoHjoPx0/G0Malvh5io2YWfzhqm9O+18f2apfUXblOr7oLpCRSnbenx2Bj lCVncPpzRsqxgz99l4TZgP+IVsKen08UCCorrNgDHE5HW23lB4/g9KXAevwlFQ1CGOVI GPElQeTu29wcAE/T28oK+ltfEsK4kVRKs2HhvbBqIow+NXTTkCgsM6FUOIpFbt06GxtH 1Qc3wB2pdlNCbjk4IwnX/j04b9WDUuyQDB+5z5vdByxOlc2V2uZL2lINDtNfilOxLhEk e0hg== 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=jScZYWimXlTit2PeLxDoPXYv52JO/PE1vC/Fa5Rnt0Y=; fh=nHR6PQcExCVN2QP7D7cUK4/5HC+IFh/f17nRiWX7JB8=; b=C57iyBO6SRBOiUWMmPt3b+knM14J97Elx8YAnzzLcHwlMk1fOpGbmjFj3y3oLOrS2+ 9dMdqrKAJGPjJ0yxLlPtkQDS+KUR0EJMAvax01N+4mE83jEMTZ/gLj7N9ZVFVXenXiJd wlL+Mdnk/8nqaxA3jTrAH86qX+PLElCwS5EpLtEwA0wodPJrZNtqz5ALfRmb8n8kH8y2 v0cnZz5XpLAhmiJa6UcKdkL1YF7EMH1TQOuzKHyxZuMlf83iwCMd5S+ZW2irXTA5c1Hp VmzTZse1lGUUjsf8byuk6BeU+Mpr6CEXMBLvkFbR9Vjbs/DFnzd07JdSzrn89paxpR+O aSAA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=syhjjikt; 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.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id v68-20020a626147000000b00690fe3ec830si4300094pfb.55.2023.10.18.11.24.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 11:24:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=syhjjikt; 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.32 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 agentk.vger.email (Postfix) with ESMTP id 20F6080FF290; Wed, 18 Oct 2023 11:24:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231687AbjJRSYk (ORCPT <rfc822;zwp10758@gmail.com> + 24 others); Wed, 18 Oct 2023 14:24:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230421AbjJRSYi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 18 Oct 2023 14:24:38 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2082.outbound.protection.outlook.com [40.107.223.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79896116; Wed, 18 Oct 2023 11:24:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=k0RDx3bJPuCuBJ9wynzkEBReHn2FM01wskBg08zW4k9V4hjoGzIBZ6iWqadB9rnMDu5iGydNZifRhGoIs0GntiUGELwFhzErhpB/MJlAxySQbuhhLSfNYAUxBxULWIQYUz7c2l8HOJtACvchRpLS2NDaKhrrrLpGdPTQbHrnrV8zZ2f94jqYySiA5mBoBUbnnMZpvo9naN5JCddt/9cyKJnOloOY71iBQkU14nefjLTm0+dM77eKhrSbAgOWSFemktvUWCeh0R95oiGTU4hqyH92hmkpTWTzl7ghczUvV0dMpEMKWsVGwWGxTpFAOhea+IKryO6xhTW1JunwKAkH5A== 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=jScZYWimXlTit2PeLxDoPXYv52JO/PE1vC/Fa5Rnt0Y=; b=bj7Idmsu7l0NHk+AZki6axPNnT054dNkN7sk1ujZuZqO7z34bEbvvuNYxHXYKpx1nCV9eNJBzxmu9nbPQ97uyl1qkxB57dnrxplrvcn07BZ4u/hODkGJm3p6f+rmNXHfv1UCCJxhsdnMLL+baGOviKbiwH8iEuO2RRHuFNLy9E8eFBg5nMQaiRUAzu8pzQYqeDvpPZmVtWYBjF/5kFEXo8jT9HuxlrFBgmMvVdYrQVN2FXReZ54vmZWQMBfYXDWdPsYhYCWImxeYsKi9gXpxRZzJmKAPdvsh8PppizG3ut0v8ywjtIef5lckxMqnSFfmz/0BWem3JlxXu6ie1PzApQ== 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=jScZYWimXlTit2PeLxDoPXYv52JO/PE1vC/Fa5Rnt0Y=; b=syhjjikt4Yt/2efI3mWdo53bjjE5ZMpNojlmLNJtGqWdc2PfUQlkmR7dTruM9fTEwl40QULVVUf/wzR7M03+Ch5kX867fk6xTVfB45JyXMwLFsm+MNfXTeU8wpAazSzDI2dvEkln0ul5YmJewKsOuVcdyp2yUU4x8TJMDoen5g4= Received: from DM5PR07CA0118.namprd07.prod.outlook.com (2603:10b6:4:ae::47) by MW5PR12MB5624.namprd12.prod.outlook.com (2603:10b6:303:19d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24; Wed, 18 Oct 2023 18:24:34 +0000 Received: from DS2PEPF00003441.namprd04.prod.outlook.com (2603:10b6:4:ae:cafe::57) by DM5PR07CA0118.outlook.office365.com (2603:10b6:4:ae::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.23 via Frontend Transport; Wed, 18 Oct 2023 18:24:33 +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 DS2PEPF00003441.mail.protection.outlook.com (10.167.17.68) 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 18:24:33 +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 13:24: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>, "Arnd Bergmann" <arnd@arndb.de>, Hamza Mahfooz <hamza.mahfooz@amd.com>, <stable@vger.kernel.org>, Miguel Ojeda <ojeda@kernel.org>, Alex Gaynor <alex.gaynor@gmail.com>, Wedson Almeida Filho <wedsonaf@gmail.com>, "Boqun Feng" <boqun.feng@gmail.com>, Gary Guo <gary@garyguo.net>, =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= <bjorn3_gh@protonmail.com>, Nick Terrell <terrelln@fb.com>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, Andrew Morton <akpm@linux-foundation.org>, "Masami Hiramatsu (Google)" <mhiramat@kernel.org>, Randy Dunlap <rdunlap@infradead.org>, Kees Cook <keescook@chromium.org>, Zhaoyang Huang <zhaoyang.huang@unisoc.com>, Li Hua <hucool.lihua@huawei.com>, Alexander Potapenko <glider@google.com>, "Geert Uytterhoeven" <geert+renesas@glider.be>, Rae Moar <rmoar@google.com>, <rust-for-linux@vger.kernel.org>, <bpf@vger.kernel.org>, <llvm@lists.linux.dev> Subject: [PATCH] lib/Kconfig.debug: disable FRAME_WARN for kasan and kcsan Date: Wed, 18 Oct 2023 14:24:11 -0400 Message-ID: <20231018182412.80291-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: DS2PEPF00003441:EE_|MW5PR12MB5624:EE_ X-MS-Office365-Filtering-Correlation-Id: 1cee09fa-d92a-48b9-a4c4-08dbd0077a59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2Vc+GWlelbTTNNamBK4X1a4rfZn66Ci9zkdzmBPKtU7edErhOLabCqUjeV5l9mgB+2h/nP1CNNYbYCF+nIi4eH/+WXoKgswnmlli1AMp2sj5KPKUzCqCcmugQ9vTfuyUcwguxar4mCJTD5TW3rxhjks2nEEoHXIkQZUtLBgL0XTi4R/rewaSBsjkC/IF3m+Y3XFC+7/deeTbSLen9eL5eDaJqLDALQvcuMlWbRJK+I/DtbDq20Jckeajx5a8YxEG5VrMsaoUhB6cC40Pl+h88PZJIsUHbvGluXtK6Zwc08v0Kk/xdxC2CSiVQXPW1phfznrEPGeztFilzzb8oUtPOwzYr9A5g27ViOmtHBXPzjpSI1OndLeEfijHzjZuyIBMloeTs55YotRbY/wgQN3bhODadfKFiWZbz6ZAIOyb9nD3phi8d3S4ggdXIeK28sJoWzyC3/YpIC/Mh9UiuWL1yF6aCT5Pmdzn7fsSVvpH3jd7P0YPm1oTXcuM/Fro0I82aH7sTCnYVGQWC/yEi0PV9fdWifGzCfh0i/x0AZTP0jCUYhs4EEQjCCr5WkWtcQZnVZgzdQQgjoB9cEJAACiBfAxvoy8nuqh94MaukuC8JooZs8WOLB/kxw2KEkQHs9YVUJtKh7O3WqiaBZ9AOBtA/2ZyS38OIPUufxQoDO/F2u8I3UvceItruwI5QorhQcwtVocTxx2jF1OTR8/mZ1a86bAdugbgLO47cIFBN3KzZE7ncEsgGGLwPtH6OlKSqHgAqTvFZvR/IPwEyWuZUZbtyU6RDOGuKqvqUU80SvC3JlXGQp/y8V/9kKXrDEYoEznd 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)(396003)(346002)(376002)(136003)(39860400002)(230922051799003)(186009)(1800799009)(64100799003)(82310400011)(451199024)(36840700001)(40470700004)(46966006)(47076005)(4744005)(36860700001)(40460700003)(6666004)(7416002)(83380400001)(70586007)(70206006)(40480700001)(54906003)(6916009)(316002)(2906002)(41300700001)(8676002)(8936002)(4326008)(16526019)(26005)(356005)(44832011)(82740400003)(81166007)(86362001)(478600001)(5660300002)(336012)(36756003)(2616005)(1076003)(426003)(36900700001)(16060500005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2023 18:24:33.8319 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1cee09fa-d92a-48b9-a4c4-08dbd0077a59 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: DS2PEPF00003441.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5624 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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 18 Oct 2023 11:24:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780118712982767542 X-GMAIL-MSGID: 1780118712982767542 |
Series |
lib/Kconfig.debug: disable FRAME_WARN for kasan and kcsan
|
|
Commit Message
Hamza Mahfooz
Oct. 18, 2023, 6:24 p.m. UTC
With every release of LLVM, both of these sanitizers eat up more and
more of the stack. So, set FRAME_WARN to 0 if either of them is enabled
for a given build.
Cc: stable@vger.kernel.org
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
---
lib/Kconfig.debug | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Comments
Hi Hamza, On Wed, Oct 18, 2023 at 8:24 PM Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: > With every release of LLVM, both of these sanitizers eat up more and > more of the stack. So, set FRAME_WARN to 0 if either of them is enabled > for a given build. > > Cc: stable@vger.kernel.org > Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> Thanks for your patch! > --- a/lib/Kconfig.debug > +++ b/lib/Kconfig.debug > @@ -429,11 +429,10 @@ endif # DEBUG_INFO > config FRAME_WARN > int "Warn for stack frames larger than" > range 0 8192 > - default 0 if KMSAN > + default 0 if KASAN || KCSAN || KMSAN Are kernels with KASAN || KCSAN || KMSAN enabled supposed to be bootable? Stack overflows do cause crashes. > default 2048 if GCC_PLUGIN_LATENT_ENTROPY > default 2048 if PARISC > default 1536 if (!64BIT && XTENSA) > - default 1280 if KASAN && !64BIT > default 1024 if !64BIT > default 2048 if 64BIT > help Gr{oetje,eeting}s, Geert
On 10/18/23 14:29, Geert Uytterhoeven wrote: > Hi Hamza, > > On Wed, Oct 18, 2023 at 8:24 PM Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: >> With every release of LLVM, both of these sanitizers eat up more and >> more of the stack. So, set FRAME_WARN to 0 if either of them is enabled >> for a given build. >> >> Cc: stable@vger.kernel.org >> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> > > Thanks for your patch! > >> --- a/lib/Kconfig.debug >> +++ b/lib/Kconfig.debug >> @@ -429,11 +429,10 @@ endif # DEBUG_INFO >> config FRAME_WARN >> int "Warn for stack frames larger than" >> range 0 8192 >> - default 0 if KMSAN >> + default 0 if KASAN || KCSAN || KMSAN > > Are kernels with KASAN || KCSAN || KMSAN enabled supposed to be bootable? They are all intended to be used for runtime debugging, so I'd imagine so. > Stack overflows do cause crashes. It is worth noting that FRAME_WARN has been disabled for KMSAN for quite a while and as far as I can tell no one has complained. > >> default 2048 if GCC_PLUGIN_LATENT_ENTROPY >> default 2048 if PARISC >> default 1536 if (!64BIT && XTENSA) >> - default 1280 if KASAN && !64BIT >> default 1024 if !64BIT >> default 2048 if 64BIT >> help > > Gr{oetje,eeting}s, > > Geert >
Hi Hamza, On Wed, Oct 18, 2023 at 8:39 PM Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: > On 10/18/23 14:29, Geert Uytterhoeven wrote: > > On Wed, Oct 18, 2023 at 8:24 PM Hamza Mahfooz <hamza.mahfooz@amd.com> wrote: > >> With every release of LLVM, both of these sanitizers eat up more and > >> more of the stack. So, set FRAME_WARN to 0 if either of them is enabled > >> for a given build. > >> > >> Cc: stable@vger.kernel.org > >> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com> > > > > Thanks for your patch! > > > >> --- a/lib/Kconfig.debug > >> +++ b/lib/Kconfig.debug > >> @@ -429,11 +429,10 @@ endif # DEBUG_INFO > >> config FRAME_WARN > >> int "Warn for stack frames larger than" > >> range 0 8192 > >> - default 0 if KMSAN > >> + default 0 if KASAN || KCSAN || KMSAN > > > > Are kernels with KASAN || KCSAN || KMSAN enabled supposed to be bootable? > > They are all intended to be used for runtime debugging, so I'd imagine so. Then I strongly suggest putting a nonzero value here. As you write that "with every release of LLVM, both of these sanitizers eat up more and more of the stack", don't you want to have at least some canary to detect when "more and more" is guaranteed to run into problems? > > Stack overflows do cause crashes. > > It is worth noting that FRAME_WARN has been disabled for KMSAN for quite > a while and as far as I can tell no one has complained. ROTFL... > >> default 2048 if GCC_PLUGIN_LATENT_ENTROPY > >> default 2048 if PARISC > >> default 1536 if (!64BIT && XTENSA) > >> - default 1280 if KASAN && !64BIT > >> default 1024 if !64BIT > >> default 2048 if 64BIT > >> help Gr{oetje,eeting}s, Geert
> > > Are kernels with KASAN || KCSAN || KMSAN enabled supposed to be bootable? > > > > They are all intended to be used for runtime debugging, so I'd imagine so. > > Then I strongly suggest putting a nonzero value here. As you write > that "with every release of LLVM, both of these sanitizers eat up more and more > of the stack", don't you want to have at least some canary to detect > when "more and more" is guaranteed to run into problems? FRAME_WARN is a poor canary. First, it does not necessarily indicate that a build is faulty (a single bloated stack frame won't crash the system). Second, devs are unlikely to fix a function because its stack frame is too big under some exotic tool+compiler combination. So the remaining option would be to just increase the frame size every time a new function surpasses the limit.
On Thu, Oct 19, 2023, at 12:04, Alexander Potapenko wrote: >> > > Are kernels with KASAN || KCSAN || KMSAN enabled supposed to be bootable? >> > >> > They are all intended to be used for runtime debugging, so I'd imagine so. >> >> Then I strongly suggest putting a nonzero value here. As you write >> that "with every release of LLVM, both of these sanitizers eat up more and more >> of the stack", don't you want to have at least some canary to detect >> when "more and more" is guaranteed to run into problems? > > FRAME_WARN is a poor canary. First, it does not necessarily indicate > that a build is faulty (a single bloated stack frame won't crash the > system). I agree it's flawed, but it does catch a lot of bugs, both in the driver and the compiler. What we should probably have is some better runtime debugging in addition to FRAME_WARN, but it's better than nothing. One idea that I've suggested in the past is to add a soft stack limit that is lower than THREAD_SIZE, using VMAP_STACK with a custom stack start and a read-only page at the end to catch a thread exceeding the soft limit and print a backtrace before marking the page writable. > Second, devs are unlikely to fix a function because its stack frame is > too big under some exotic tool+compiler combination. I've probably sent hundreds of fixes for these in the past. Most of the time there is an actual driver bug, and almost always the driver maintainers are responsive and treat the report with the appropriate urgency: even if only some configurations actually push it over the limit, the general case is some data structure that is hundreds of bytes long and was not actually meant to be on the stack. The gcc bug reports also usually get addressed quickly, though we've had problems with clang not making progress on known bugs for years. It sounds like Nick has made some important progress on clang very recently, so we should be able to raise the minimum clang version for kasan and kcsan once there is a known good release. > So the remaining option would be to just increase the frame size every > time a new function surpasses the limit. That is clearly not an option, though we could try to add Kconfig dependencies that avoid the known bad combinations, such as annotating the AMD GPU driver as depends on (CC_IS_GCC || CLANG_VERSION >=180000) || !(KASAN || KCSAN) Arnd
On Thu, Oct 19, 2023 at 02:53:01PM +0200, Arnd Bergmann wrote: > On Thu, Oct 19, 2023, at 12:04, Alexander Potapenko wrote: > > So the remaining option would be to just increase the frame size every > > time a new function surpasses the limit. > > That is clearly not an option, though we could try to > add Kconfig dependencies that avoid the known bad combinations, > such as annotating the AMD GPU driver as > > depends on (CC_IS_GCC || CLANG_VERSION >=180000) || !(KASAN || KCSAN) This would effectively disable the AMDGPU driver for allmodconfig, which is somewhat unfortunate as it is an easy testing target. Taking a step back, this is all being done because of a couple of warnings in the AMDGPU code. If fixing those in the source is too much effort (I did note [1] that GCC is at the current limit for that file even with Rodrigo's series applied [2]), couldn't we just take the existing workaround that this Makefile has for this file and its high stack usage and just extend it slightly for clang? diff --git a/drivers/gpu/drm/amd/display/dc/dml2/Makefile b/drivers/gpu/drm/amd/display/dc/dml2/Makefile index 66431525f2a0..fd49e3526c0d 100644 --- a/drivers/gpu/drm/amd/display/dc/dml2/Makefile +++ b/drivers/gpu/drm/amd/display/dc/dml2/Makefile @@ -58,7 +58,7 @@ endif endif ifneq ($(CONFIG_FRAME_WARN),0) -frame_warn_flag := -Wframe-larger-than=2048 +frame_warn_flag := -Wframe-larger-than=$(if $(CONFIG_CC_IS_CLANG),3072,2048) endif CFLAGS_$(AMDDALPATH)/dc/dml2/display_mode_core.o := $(dml2_ccflags) $(frame_warn_flag) That would address the immediate concern of the warning breaking builds with CONFIG_WERROR=y while not raising the limit for other files in the kernel (just this one file in AMDGPU) and avoiding disabling the whole driver. The number could be lower, I think ~2500 bytes is the most usage I see with Rodrigo's series applied, so maybe 2800 would be a decent limit? Once there is a fix in the compiler, this expression could be changed to use clang-min-version or something of that sort. [1]: https://lore.kernel.org/20231017172231.GA2348194@dev-arch.thelio-3990X/ [2]: https://lore.kernel.org/20231016142031.241912-1-Rodrigo.Siqueira@amd.com/ Cheers, Nathan
On 10/19/23 11:56, Nathan Chancellor wrote: > On Thu, Oct 19, 2023 at 02:53:01PM +0200, Arnd Bergmann wrote: >> On Thu, Oct 19, 2023, at 12:04, Alexander Potapenko wrote: >>> So the remaining option would be to just increase the frame size every >>> time a new function surpasses the limit. >> >> That is clearly not an option, though we could try to >> add Kconfig dependencies that avoid the known bad combinations, >> such as annotating the AMD GPU driver as >> >> depends on (CC_IS_GCC || CLANG_VERSION >=180000) || !(KASAN || KCSAN) > > This would effectively disable the AMDGPU driver for allmodconfig, which > is somewhat unfortunate as it is an easy testing target. > > Taking a step back, this is all being done because of a couple of > warnings in the AMDGPU code. If fixing those in the source is too much > effort (I did note [1] that GCC is at the current limit for that file > even with Rodrigo's series applied [2]), couldn't we just take the > existing workaround that this Makefile has for this file and its high > stack usage and just extend it slightly for clang? I personally don't mind fixing these issues in the driver, but the fact that they the creep back every time a new major version of Clang rolls out (that has been true for the past couple of years at the very least), makes it rather annoying to deal with. > > diff --git a/drivers/gpu/drm/amd/display/dc/dml2/Makefile b/drivers/gpu/drm/amd/display/dc/dml2/Makefile > index 66431525f2a0..fd49e3526c0d 100644 > --- a/drivers/gpu/drm/amd/display/dc/dml2/Makefile > +++ b/drivers/gpu/drm/amd/display/dc/dml2/Makefile > @@ -58,7 +58,7 @@ endif > endif > > ifneq ($(CONFIG_FRAME_WARN),0) > -frame_warn_flag := -Wframe-larger-than=2048 > +frame_warn_flag := -Wframe-larger-than=$(if $(CONFIG_CC_IS_CLANG),3072,2048) > endif > > CFLAGS_$(AMDDALPATH)/dc/dml2/display_mode_core.o := $(dml2_ccflags) $(frame_warn_flag) > > That would address the immediate concern of the warning breaking builds > with CONFIG_WERROR=y while not raising the limit for other files in the > kernel (just this one file in AMDGPU) and avoiding disabling the whole > driver. The number could be lower, I think ~2500 bytes is the most usage > I see with Rodrigo's series applied, so maybe 2800 would be a decent > limit? Once there is a fix in the compiler, this expression could be > changed to use clang-min-version or something of that sort. > > [1]: https://lore.kernel.org/20231017172231.GA2348194@dev-arch.thelio-3990X/ > [2]: https://lore.kernel.org/20231016142031.241912-1-Rodrigo.Siqueira@amd.com/ > > Cheers, > Nathan
On Thu, Oct 19, 2023 at 04:17:26PM -0400, Hamza Mahfooz wrote: > On 10/19/23 11:56, Nathan Chancellor wrote: > > On Thu, Oct 19, 2023 at 02:53:01PM +0200, Arnd Bergmann wrote: > > > On Thu, Oct 19, 2023, at 12:04, Alexander Potapenko wrote: > > > > So the remaining option would be to just increase the frame size every > > > > time a new function surpasses the limit. > > > > > > That is clearly not an option, though we could try to > > > add Kconfig dependencies that avoid the known bad combinations, > > > such as annotating the AMD GPU driver as > > > > > > depends on (CC_IS_GCC || CLANG_VERSION >=180000) || !(KASAN || KCSAN) > > > > This would effectively disable the AMDGPU driver for allmodconfig, which > > is somewhat unfortunate as it is an easy testing target. > > > > Taking a step back, this is all being done because of a couple of > > warnings in the AMDGPU code. If fixing those in the source is too much > > effort (I did note [1] that GCC is at the current limit for that file > > even with Rodrigo's series applied [2]), couldn't we just take the > > existing workaround that this Makefile has for this file and its high > > stack usage and just extend it slightly for clang? > > I personally don't mind fixing these issues in the driver, but the fact > that they the creep back every time a new major version of Clang rolls > out (that has been true for the past couple of years at the very > least), makes it rather annoying to deal with. I am not sure I agree with that characterization of the situation. clang has been pretty consistent for the most part (which is certainly on us), as all versions that the kernel supports warns about this code. I believe it is more so the fact that there is a new copy of the dcn code added every year that has none of the fixes applied from earlier generations... It is not just me that has fixed issues like this, just run 'git log --grep=stack drivers/gpu/drm/amd/display'. It is not just clang that complains about the code when sanitizers are turned on, GCC does as well since Stephen reported them. Cheers, Nathan > > diff --git a/drivers/gpu/drm/amd/display/dc/dml2/Makefile b/drivers/gpu/drm/amd/display/dc/dml2/Makefile > > index 66431525f2a0..fd49e3526c0d 100644 > > --- a/drivers/gpu/drm/amd/display/dc/dml2/Makefile > > +++ b/drivers/gpu/drm/amd/display/dc/dml2/Makefile > > @@ -58,7 +58,7 @@ endif > > endif > > ifneq ($(CONFIG_FRAME_WARN),0) > > -frame_warn_flag := -Wframe-larger-than=2048 > > +frame_warn_flag := -Wframe-larger-than=$(if $(CONFIG_CC_IS_CLANG),3072,2048) > > endif > > CFLAGS_$(AMDDALPATH)/dc/dml2/display_mode_core.o := $(dml2_ccflags) $(frame_warn_flag) > > > > That would address the immediate concern of the warning breaking builds > > with CONFIG_WERROR=y while not raising the limit for other files in the > > kernel (just this one file in AMDGPU) and avoiding disabling the whole > > driver. The number could be lower, I think ~2500 bytes is the most usage > > I see with Rodrigo's series applied, so maybe 2800 would be a decent > > limit? Once there is a fix in the compiler, this expression could be > > changed to use clang-min-version or something of that sort. > > > > [1]: https://lore.kernel.org/20231017172231.GA2348194@dev-arch.thelio-3990X/ > > [2]: https://lore.kernel.org/20231016142031.241912-1-Rodrigo.Siqueira@amd.com/ > > > > Cheers, > > Nathan > -- > Hamza >
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 39d1d93164bd..15ad742729ca 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -429,11 +429,10 @@ endif # DEBUG_INFO config FRAME_WARN int "Warn for stack frames larger than" range 0 8192 - default 0 if KMSAN + default 0 if KASAN || KCSAN || KMSAN default 2048 if GCC_PLUGIN_LATENT_ENTROPY default 2048 if PARISC default 1536 if (!64BIT && XTENSA) - default 1280 if KASAN && !64BIT default 1024 if !64BIT default 2048 if 64BIT help