Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp673941rdb; Sat, 30 Sep 2023 23:53:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG8q/55HV0+STJwRWOO9PATbwKLwCMq/mIf1B1v8dXeo+SbmAI/vduQjxZZCQWzwy1lPDgq X-Received: by 2002:a17:90a:f283:b0:26f:ac36:623a with SMTP id fs3-20020a17090af28300b0026fac36623amr13217043pjb.3.1696143192944; Sat, 30 Sep 2023 23:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696143192; cv=none; d=google.com; s=arc-20160816; b=sE42kVWt3Vz9m0+p4C/83vm9YpPeaEYAKSKFv3zsa0jvgJiWWMVEge5kOIk5fCcWYX K+P1SiQD4cvilr+g+DyQPJnUc29UPn6ChJE0e4DHKjSKgf6yEO2li07GoETCtLEyo3LI 9VrqLp1Us1TztzCRwkLhA5yrfnEoO4b0NMQ4zUjRBp3z4HxIFFRd/UUXSfuK8rdrA+ju KDh8re1o27fFhPDhtFLHzly1g1SDoET6Nhwze3nnpOYoq5GfmO1ul1wnBAm5sGGgtJ3L GM5TdSDynS5PaySpH2/4r0rNEU0eSUH6ROKhNbbvaBzlxkRTTcjxR28omZxKUEeoC+sH DOgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ZuglWOHeRktdc1SI7fZMrBNHt7pae0GyCoYbfoLsddc=; fh=GGaA72IXO4fZzs4cBhG/plrufhn7BtTOX5zknCEwsCI=; b=LWG7c5G+0acI5TgRHLdlrheQbdsD5CoNmVeGc8nt6/mI+XshAhwK71xGDgBUrSLVz3 Cg0+IofSRKURGSMIguh/Eh31qC7H+87YywDuZcJlXe4WHiyMJiS9w45kreRd0R3Nj93o 5g3t736D0tWce/PfxO/TT2Am1vcAoiNelrDL8QvjdL6mOW12NQ21mijOayttp21VZAUz isWtnRobq6HfYdSJcYzK0BPxqbKMXtNK1p0b8pnmU12fv4ngCVyoH65fnRw0hYmSUtTH ScQ98vhgrROL4GML3SBHq5wX+AMiziqEwVSDG3RRvg5zd7fGoCKW2GCJ3p8K26GPe3Hf lQCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=GFdvOHVq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id s11-20020a17090a5d0b00b00277277fd2besi5039515pji.190.2023.09.30.23.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 23:53:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=GFdvOHVq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 968018271408; Sat, 30 Sep 2023 23:52:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234373AbjJAGnw (ORCPT + 99 others); Sun, 1 Oct 2023 02:43:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233771AbjJAGnv (ORCPT ); Sun, 1 Oct 2023 02:43:51 -0400 Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C153BE for ; Sat, 30 Sep 2023 23:43:49 -0700 (PDT) Received: from eig-obgw-5005a.ext.cloudfilter.net ([10.0.29.234]) by cmsmtp with ESMTP id mm6OqmEFFaLCxmqBAqyBMm; Sun, 01 Oct 2023 06:43:48 +0000 Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with ESMTPS id mqB9qnwFw1J29mqB9qxDhP; Sun, 01 Oct 2023 06:43:48 +0000 X-Authority-Analysis: v=2.4 cv=Ko9eZEaN c=1 sm=1 tr=0 ts=65191524 a=1YbLdUo/zbTtOZ3uB5T3HA==:117 a=P7XfKmiOJ4/qXqHZrN7ymg==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=bhdUkHdE2iEA:10 a=wYkD_t78qR0A:10 a=VwQbUJbxAAAA:8 a=NEAV23lmAAAA:8 a=HvF037n1xESchLcPDVoA:9 a=QEXdDO2ut3YA:10 a=AjGcO6oz07-iQ99wixmX: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=ZuglWOHeRktdc1SI7fZMrBNHt7pae0GyCoYbfoLsddc=; b=GFdvOHVqx5Ih/kinRsGsl14I4H XwgD7x624J2I2bdWybbFp0blj7IipDqTb2ve8qeM1Zr6SStvdA1RDj4fLKTA+gu+Px53PQkTEfhPA F8Tdj5L0w+fk1NcqtKULEGRfDKe/H/V3lDCCDS81uwTDIVSeCIwuGj/Rr51EDxyHU4mQoTYnjRS7z Een0yBKUVeStFKGXsILzuV55OhL0zibUcfe4sRvsi54GMD5jthFMPrKwLdJY4gHBpPRkyP8SvuaFJ ZOO2FqckXRE0UWVQngqNNafYK6Jhr8b7I5R4gQhhYBNf/529jWdDw2iPKECUyLMULWp7JFPZM4X6r KLmBhQDg==; Received: from [94.239.20.48] (port=48958 helo=[192.168.1.98]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1qmqB8-001P7H-25; Sun, 01 Oct 2023 01:43:46 -0500 Message-ID: <935d0577-4a6a-eb84-6ae0-f1efa4352b5b@embeddedor.com> Date: Sun, 1 Oct 2023 08:43:41 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by Content-Language: en-US To: Christophe JAILLET , Ian Abbott , H Hartley Sweeten , Kees Cook , "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Tom Rix Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev References: <5c3b7459b820e22e2ac6ce892d4aadcc119cc919.1696065263.git.christophe.jaillet@wanadoo.fr> From: "Gustavo A. R. Silva" In-Reply-To: <5c3b7459b820e22e2ac6ce892d4aadcc119cc919.1696065263.git.christophe.jaillet@wanadoo.fr> 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: 94.239.20.48 X-Source-L: No X-Exim-ID: 1qmqB8-001P7H-25 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.1.98]) [94.239.20.48]:48958 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 74 X-Org: HG=hgshared;ORG=hostgator; X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfFvCx0n8uqFRLdcr1B1V85l6hz8vm+soMv7BEoMrbY6SxEw4j4NvcKF7LEPM4g+rrfHxrPszJivqXJdSHiRhQcRXnYUiR+DvykPXc2O07zwY4+C8DoIi HNOAkoX4Ig6bQ4voXxyz55esckoPersTaFs2PwB23jRggYSBLHkNZtieAzY/WylJ6y8Un8xUfEkb5O1On8QXVlbTeZEOqRTRSKOYDcNXmVtLudeK9gaK1XE8 X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Sat, 30 Sep 2023 23:52:39 -0700 (PDT) On 9/30/23 11:14, Christophe JAILLET 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). > > Signed-off-by: Christophe JAILLET Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > This patch is part of a work done in parallel of what is currently worked > on by Kees Cook. > > My patches are only related to corner cases that do NOT match the > semantic of his Coccinelle script[1]. > > In this case, it is been spotted because of comedi_alloc_spriv(). > All other usages of struct comedi_lrange seem to be static definition of > the structure that explicitly set the .length field. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > --- > include/linux/comedi/comedidev.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/comedi/comedidev.h b/include/linux/comedi/comedidev.h > index 0a1150900ef3..c08416a7364b 100644 > --- a/include/linux/comedi/comedidev.h > +++ b/include/linux/comedi/comedidev.h > @@ -633,7 +633,7 @@ extern const struct comedi_lrange range_unknown; > */ > struct comedi_lrange { > int length; > - struct comedi_krange range[]; > + struct comedi_krange range[] __counted_by(length); > }; > > /**