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 68B61C30653 for ; Fri, 28 Jun 2024 02:52:06 +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:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rKRBHzZAJa8Y5uaYN9KzLXlsQxprz1t3tpmpYAAPIhA=; b=VLPznZ2UN8GakfL36/jN+fANy5 vEi1fzz19W0ilSO/nBsSt79DviAR1bc9r1YHNOkAQvSSo93NvLXEdlCr8YflnTcg2HItleaTIRvDW FFnd1S7J7LCvFzWCj/+DwvfYQReeLFM/NB2HTyA1+OWtOjGIhJ4n7HpK2az0/NL+6dF+LQSAaEIIk Q6l/lPnuNMPpGVX02XaUQ+6Fj1WRAyxrtw93Gylk6E/4xs8L+I5R70DPT9h/09E9DiBJENJkcTcvM UsfJyC+HA7meUF3opGuFu6StQIARUSEjK0L4mhxIzCHkXmw3Zvm8TAsZ+gjpfW8u6rquGnveAGAJr Ch9eQQjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sN1iM-0000000CMOF-3kfi; Fri, 28 Jun 2024 02:51:54 +0000 Received: from omta34.uswest2.a.cloudfilter.net ([35.89.44.33]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sN1iC-0000000CMMR-2810 for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2024 02:51:47 +0000 Received: from eig-obgw-6010a.ext.cloudfilter.net ([10.0.30.248]) by cmsmtp with ESMTPS id MwDssJc3XjZAYN1hystMEf; Fri, 28 Jun 2024 02:51:30 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id N1hwsBOU5y2LPN1hwsdQZD; Fri, 28 Jun 2024 02:51:28 +0000 X-Authority-Analysis: v=2.4 cv=CZoO5qrl c=1 sm=1 tr=0 ts=667e2530 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=frY+GlAHrI6frpeK1MvySw==:17 a=IkcTkHD0fZMA:10 a=T1WGqf2p2xoA:10 a=wYkD_t78qR0A:10 a=VwQbUJbxAAAA:8 a=NEAV23lmAAAA:8 a=_Wotqz80AAAA:8 a=ijWZ9xZranq7hUifA4EA:9 a=QEXdDO2ut3YA:10 a=AjGcO6oz07-iQ99wixmX:22 a=buJP51TR1BpY-zbLSsyS:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=rKRBHzZAJa8Y5uaYN9KzLXlsQxprz1t3tpmpYAAPIhA=; b=VrcU1cKb+9PGWke1O9Eg07jCns cEqyuC544UwG5leDIPUCgceMBYSUMRHn9IY1WY5WRoINOFKk0ysi/r30O9AZSsZidOw5RZiGijYJx UuxpvyG4Rx4IBZHnm+Axp5mHRB+6KrIWIrv4uQL3Ti++VdCLPxs9XtRdRleTYZFoVAQHaS++tysuP lm+mHRqfVMrfp6PQac+PwDQlp4cIniJFazfMlVbg9vsHkhOL+zsUaOr9K1WzDQz9ZB2hHMU47r7W0 6a4vvOmWKNa2K2CekofNvgNM7wDZvLU6PHbi5zjp/47osjSB0fLMDRNIb/1iWNCoD0UpbmdQCUF7p PlGiuv4Q==; Received: from [201.172.173.139] (port=40218 helo=[192.168.15.14]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96.2) (envelope-from ) id 1sN1hv-003DhV-1b; Thu, 27 Jun 2024 21:51:27 -0500 Message-ID: <4c347ab7-97f6-4e18-9aca-dcb48e8fc75a@embeddedor.com> Date: Thu, 27 Jun 2024 20:51:23 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] tty: mxser: Remove __counted_by from mxser_board.ports[] To: Kees Cook , 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 References: <20240529-drop-counted-by-ports-mxser-board-v1-1-0ab217f4da6d@kernel.org> <202406271009.4E90DF8@keescook> Content-Language: en-US From: "Gustavo A. R. Silva" In-Reply-To: <202406271009.4E90DF8@keescook> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 201.172.173.139 X-Source-L: No X-Exim-ID: 1sN1hv-003DhV-1b X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.15.14]) [201.172.173.139]:40218 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 5 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfCiqfOiEc23m6FB/r9f95FT3sQLuS6iCLTNcXlhZuQWgKx+32ltTPNEAgPEdzb93D8OjsSeNFf6Chk8ahoifkfNdHiIZs4Ngv3WUELPNHNR+/9DrICdW dzKjD3s3UDuaUFrAQ5VycONo2YoYw5WToo3+ZO5ZDIqLXsFHlvnW1ZyUPmSSb1SNVPjNmahpRWGc+bD25qQfxDbrxekZxqv+RwEgI89L4uEs4c2pXVqQtKyP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_195144_655353_6C502F79 X-CRM114-Status: GOOD ( 14.79 ) 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 27/06/24 11:14, Kees Cook wrote: > 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. :) +1 (It'd be great if you take it.) Also, it'd be great if somebody can confirm this is an acceptable fix for the issue: https://lore.kernel.org/linux-hardening/c80e41e6-793e-4311-8e15-f5eda91e723e@embeddedor.com/ Thanks -- Gustavo