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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 178FFCD379F for ; Fri, 15 Sep 2023 20:29:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694809774; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=rEUiEN0Pl7ogqbgx0u6pBDeJCZzkv7JsRR1CjHuM0WA=; b=Dn+d8o9XNf5qJPxmC5peqX2/2m6GrLXcJ0HMj4HULVf1/2w0DeTYBfNAIAuiJsiQGWb23Z iOfdqJbHzY9Nvoc/pJMqwjOQJV8dJMeeKoaDP7Ij7b40+T3CRh6TBVcBVTjrNtSYMW/B0F EQ+XFZBIgAwRr/MqsplTOzmpQxHYKP0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-82-IlcXZOaGM2WdN3x2pynBJQ-1; Fri, 15 Sep 2023 16:29:31 -0400 X-MC-Unique: IlcXZOaGM2WdN3x2pynBJQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7AAED101B047; Fri, 15 Sep 2023 20:29:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1101A40F2D4B; Fri, 15 Sep 2023 20:29:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9387F194658C; Fri, 15 Sep 2023 20:29:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 525BF1946588 for ; Fri, 15 Sep 2023 20:29:22 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2BEAD40F2D2A; Fri, 15 Sep 2023 20:29:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2479540F2D26 for ; Fri, 15 Sep 2023 20:29:22 +0000 (UTC) Received: from us-smtp-inbound-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 047E7811E8D for ; Fri, 15 Sep 2023 20:29:22 +0000 (UTC) Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-520-6dDfyq2kOeK6lIbJYOFnZw-7; Fri, 15 Sep 2023 16:29:20 -0400 X-MC-Unique: 6dDfyq2kOeK6lIbJYOFnZw-7 Received: from eig-obgw-6005a.ext.cloudfilter.net ([10.0.30.201]) by cmsmtp with ESMTP id hAPcqOleYWU1chFPqqTYLS; Fri, 15 Sep 2023 20:27:50 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id hFPpqkBrDxtb5hFPqqfLYy; Fri, 15 Sep 2023 20:27:50 +0000 X-Authority-Analysis: v=2.4 cv=IOERtyjG c=1 sm=1 tr=0 ts=6504be46 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=WzbPXH4gqzPVN0x6HrNMNA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=zNV7Rl7Rt7sA:10 a=wYkD_t78qR0A:10 a=NEAV23lmAAAA:8 a=20KFwNOVAAAA:8 a=VwQbUJbxAAAA:8 a=cm27Pg_UAAAA:8 a=1rGUjaHSoLxGkM6IGjIA:9 a=QEXdDO2ut3YA:10 a=AjGcO6oz07-iQ99wixmX:22 a=xmb-EsYY8bH0VWELuYED:22 Received: from 187-162-21-192.static.axtel.net ([187.162.21.192]:51030 helo=[192.168.15.8]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1qhFPo-002Jct-1H; Fri, 15 Sep 2023 15:27:48 -0500 Message-ID: <6bf23c7f-9f7f-1d9e-9aa0-e163608447ae@embeddedor.com> Date: Fri, 15 Sep 2023 14:28:44 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 To: Kees Cook , Alasdair Kergon References: <20230915200335.never.098-kees@kernel.org> From: "Gustavo A. R. Silva" In-Reply-To: <20230915200335.never.098-kees@kernel.org> 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 - redhat.com X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.21.192 X-Source-L: No X-Exim-ID: 1qhFPo-002Jct-1H X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-21-192.static.axtel.net ([192.168.15.8]) [187.162.21.192]:51030 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 81 X-Org: HG=hgshared;ORG=hostgator X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfFT82+bAQcKRgb47UPtlxrdgiUOktdZfyBixs8Tyjp/geYUf7RkgVAkQYqugqdLHPIXUXzw1sZwJsXdhvGaZyIwXRr8VmvzE3BJiJEaljOa2rztd77Ge 43IFSAu3G/fxoK9ZJyfEN8m5qGX5cQOdZ0T5sTXi28gXsXpNPXpI6RuUod/hyXyrNSA+bJIGLNgDSsp8or3duM0no6Oj9m1AaXY= X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Subject: Re: [dm-devel] [PATCH] dm raid: Annotate struct raid_set with __counted_by X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mike Snitzer , llvm@lists.linux.dev, Nick Desaulniers , linux-kernel@vger.kernel.org, Nathan Chancellor , dm-devel@redhat.com, linux-hardening@vger.kernel.org, Tom Rix Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: embeddedor.com Content-Language: en-US Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" On 9/15/23 14:03, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). > > As found with Coccinelle[1], add __counted_by for struct raid_set. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Alasdair Kergon > Cc: Mike Snitzer > Cc: dm-devel@redhat.com > Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > drivers/md/dm-raid.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c > index 5f9991765f27..9755788e8b78 100644 > --- a/drivers/md/dm-raid.c > +++ b/drivers/md/dm-raid.c > @@ -254,7 +254,7 @@ struct raid_set { > int mode; > } journal_dev; > > - struct raid_dev dev[]; > + struct raid_dev dev[] __counted_by(raid_disks); > }; > > static void rs_config_backup(struct raid_set *rs, struct rs_layout *l) -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C9B6CD37A9 for ; Fri, 15 Sep 2023 20:28:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233362AbjIOU15 (ORCPT ); Fri, 15 Sep 2023 16:27:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237295AbjIOU14 (ORCPT ); Fri, 15 Sep 2023 16:27:56 -0400 Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AB92AF for ; Fri, 15 Sep 2023 13:27:51 -0700 (PDT) Received: from eig-obgw-5010a.ext.cloudfilter.net ([10.0.29.199]) by cmsmtp with ESMTP id h9MaqKSnyEoVshFPrqHpd2; Fri, 15 Sep 2023 20:27:51 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id hFPpqyb31Yg1hhFPqqQMog; Fri, 15 Sep 2023 20:27:50 +0000 X-Authority-Analysis: v=2.4 cv=KsReZEaN c=1 sm=1 tr=0 ts=6504be46 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=WzbPXH4gqzPVN0x6HrNMNA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=zNV7Rl7Rt7sA:10 a=wYkD_t78qR0A:10 a=NEAV23lmAAAA:8 a=20KFwNOVAAAA:8 a=VwQbUJbxAAAA:8 a=cm27Pg_UAAAA:8 a=1rGUjaHSoLxGkM6IGjIA:9 a=QEXdDO2ut3YA:10 a=AjGcO6oz07-iQ99wixmX:22 a=xmb-EsYY8bH0VWELuYED: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=a6FgjMylHXWTpHsDUs+9t/FgxU+P0Q11ISaPe1Rcv8w=; b=xWE1ePG1pJ/MBNbTKML7mWpv7+ hTvnsr9J5+w66OSudqoVfFSRzjW5ualO3+2HxahufVMkVae2VyPglsd2DeLXLnuV1Ne268PVqoGBF gzuKSPgYIz+MgtmJ26p20dnfLIo8DVRgTtenBjGhRAdS2bJkRkrHDxTBcIuUxSVjYrRF49gs3R7ua Ms4rqhUu2JQbzLFgPadTU4xcpViBtzieu9urP9YXMOfwBdpmznz+9rr/BLun/ZoSUCOGOjhB1NZ6s mqxNn7VZdQMxomnxvX9BExnhmVSfJ0i9xHBOyYo9Tb+JkulIc3GUeS+WVY2uAjoqv0pbx1mT0eyBI HuQ4ktjA==; Received: from 187-162-21-192.static.axtel.net ([187.162.21.192]:51030 helo=[192.168.15.8]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1qhFPo-002Jct-1H; Fri, 15 Sep 2023 15:27:48 -0500 Message-ID: <6bf23c7f-9f7f-1d9e-9aa0-e163608447ae@embeddedor.com> Date: Fri, 15 Sep 2023 14:28:44 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] dm raid: Annotate struct raid_set with __counted_by Content-Language: en-US To: Kees Cook , Alasdair Kergon Cc: Mike Snitzer , dm-devel@redhat.com, Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org References: <20230915200335.never.098-kees@kernel.org> From: "Gustavo A. R. Silva" In-Reply-To: <20230915200335.never.098-kees@kernel.org> 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 - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 187.162.21.192 X-Source-L: No X-Exim-ID: 1qhFPo-002Jct-1H X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 187-162-21-192.static.axtel.net ([192.168.15.8]) [187.162.21.192]:51030 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 75 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfHfxSmECqgWkk4cfLaI7fMCA3BiEVHjVBOOaKs+PYIt3+rvix6jQgUTTLKsYSG7WvYGDzKn1alpMOd3DihSxZkjm2zacnx66G25je1yqa3SbGM5KCy43 ycs2FaqQ0VvXTze2jQK1khaGrgwSckg3ZY1S7eli4yMKo8QqwoEHPECdMJJs/KlGvAFFR3dJp4WZq8HGu+2DHL6B4ZaqagRGGAio6BfU8EnR96hvNIjIy1do Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On 9/15/23 14:03, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). > > As found with Coccinelle[1], add __counted_by for struct raid_set. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Alasdair Kergon > Cc: Mike Snitzer > Cc: dm-devel@redhat.com > Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > drivers/md/dm-raid.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c > index 5f9991765f27..9755788e8b78 100644 > --- a/drivers/md/dm-raid.c > +++ b/drivers/md/dm-raid.c > @@ -254,7 +254,7 @@ struct raid_set { > int mode; > } journal_dev; > > - struct raid_dev dev[]; > + struct raid_dev dev[] __counted_by(raid_disks); > }; > > static void rs_config_backup(struct raid_set *rs, struct rs_layout *l)