From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93F2FC2BD09 for ; Thu, 27 Jun 2024 17:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=af1w/XgT4kO1HT7nsWR5BvM1HsM/h6cpZoU/QolRseM=; b=JrI1Etpgxh5WKyYfMxTaB4alHa lyT/pQ1Mf4jdVMxWOFNGBPqAHXz82xSYv5FqFZhgo0nIMd2NPwtkud/uXvg81RA7m3WfhoKXu3h2D 0cJO1Ai2uSv76ushEXY6BHyuqy3mvjEQdg3f9QMtyqnMdpbBbgCus368+T6JYfdrg3sg/uuCO4Vb1 hKK3uyUEtHKWRSgzbZcT9MhEAWjeeaQNncEkqLyzuh4QdCIprva16XhCtU+LHs3wtq13X4XKmIUI/ btRGLZjOK3/4huAPBHS2s1aAjPJHV0zhc2ZRZFwLpMKXh/w+UcMgSIdWB19YH5vOFXVh7CBmQENOn Vf8X+3Fw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMshO-0000000BA6O-00pZ; Thu, 27 Jun 2024 17:14:18 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMshE-0000000BA2g-3rtW for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 17:14:10 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 14F7DCE3384; Thu, 27 Jun 2024 17:14:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09DF5C2BD10; Thu, 27 Jun 2024 17:14:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719508446; bh=tNR6ArIGiHkLTpGQkaqhID9T8qBWrrtgctZsjePiA8k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RtAcu1FGJ6P2bbf/X4dsur5Hnf5L/FVULlmeohzDRYKuz6ePZ+uKKYm74H3EdgNmo XlWBAZeCr43+0xZjyJrKO78GGKQ785KXaJGxLHBbA+7vLgm8dj5LPhJLEdRfFSeXwr FzJSivkdhNDkiLgaKBQA001ga1cAY/Tp37wpV9noXkqcWyZ4fBhv6RIsjNPqYLiIbx R/u4GNIbrvU1JRSvc2fyK2KxRnnepks0MHIywrbegr/DKmu06qiHTZnd/A5lsnwNny j6JSGuPX7j0jJww7j2jrCZvvQKOucgU4nDRiE3PYJCL0T8PFOfIc4lDIGr76Iam4Dn AvxHsaRMYypIw== Date: Thu, 27 Jun 2024 10:14:05 -0700 From: Kees Cook To: Greg Kroah-Hartman Cc: Jiri Slaby , Nathan Chancellor , "Gustavo A. R. Silva" , Bill Wendling , Justin Stitt , linux-serial@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev, patches@lists.linux.dev, stable@vger.kernel.org Subject: Re: [PATCH] tty: mxser: Remove __counted_by from mxser_board.ports[] Message-ID: <202406271009.4E90DF8@keescook> References: <20240529-drop-counted-by-ports-mxser-board-v1-1-0ab217f4da6d@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240529-drop-counted-by-ports-mxser-board-v1-1-0ab217f4da6d@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_101409_167741_AD1E242D X-CRM114-Status: GOOD ( 19.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, May 29, 2024 at 02:29:42PM -0700, Nathan Chancellor wrote: > Work for __counted_by on generic pointers in structures (not just > flexible array members) has started landing in Clang 19 (current tip of > tree). During the development of this feature, a restriction was added > to __counted_by to prevent the flexible array member's element type from > including a flexible array member itself such as: > > struct foo { > int count; > char buf[]; > }; > > struct bar { > int count; > struct foo data[] __counted_by(count); > }; > > because the size of data cannot be calculated with the standard array > size formula: > > sizeof(struct foo) * count > > This restriction was downgraded to a warning but due to CONFIG_WERROR, > it can still break the build. The application of __counted_by on the > ports member of 'struct mxser_board' triggers this restriction, > resulting in: > > drivers/tty/mxser.c:291:2: error: 'counted_by' should not be applied to an array with element of unknown size because 'struct mxser_port' is a struct type with a flexible array member. This will be an error in a future compiler version [-Werror,-Wbounds-safety-counted-by-elt-type-unknown-size] > 291 | struct mxser_port ports[] __counted_by(nports); > | ^~~~~~~~~~~~~~~~~~~~~~~~~ > 1 error generated. > > Remove this use of __counted_by to fix the warning/error. However, > rather than remove it altogether, leave it commented, as it may be > possible to support this in future compiler releases. > > Cc: stable@vger.kernel.org > Closes: https://github.com/ClangBuiltLinux/linux/issues/2026 > Fixes: f34907ecca71 ("mxser: Annotate struct mxser_board with __counted_by") > Signed-off-by: Nathan Chancellor Since this fixes a build issue under Clang, can we please land this so v6.7 and later will build again? Gustavo is still working on the more complete fix (which was already on his radar, so it won't be lost). If it's easier/helpful, I can land this via the hardening tree? I was the one who sent the bad patch originally. :) Thanks! -Kees -- Kees Cook