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 14A1EE732DB for ; Thu, 28 Sep 2023 15:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231722AbjI1PSZ (ORCPT ); Thu, 28 Sep 2023 11:18:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232052AbjI1PST (ORCPT ); Thu, 28 Sep 2023 11:18:19 -0400 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08B00CFD; Thu, 28 Sep 2023 08:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; 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=trot3+TGWG2OOMY4ChPeFe3zf2LJzFBVfmF3pbXC7Xo=; b=higqqnDmzxmr+X3cfpKInvzj3o BqvWpQGHvH67nWnfc0XAoOqx9PXGwtMHNh9pxk0oebmPzjEX7R+4f1blAH9+4S5qw796Lv7aWaopn OPEn6RhhEua/OPFIH6MXBzs3xY7lHtUt4TfCx9LWA934JiaFnKl0qFh0Ub9wyXDq+MkAtH+KdS4Fs iT7lhSmKl2qB1wdOkkBOoUayyFaiRkkAAvxfl1txVMTS8BQaJQ6dwujlhoA/q8pHzkc5mItIlOlSp DNC4wfQi03pP2QScb9qLX4GTmyrx8Ej+PdIPFaND/La/DZ03zb1Y7aNBQFiRh8eLvGG0z1FOzaW4j Y90I6VGQ==; Received: from [177.34.168.16] (helo=[192.168.0.8]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1qlskm-009K4n-35; Thu, 28 Sep 2023 17:16:36 +0200 Message-ID: <708d9fa0-0957-796a-ecc1-9ad4fdae6339@igalia.com> Date: Thu, 28 Sep 2023 12:16:16 -0300 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 9/9] drm/v3d: Annotate struct v3d_perfmon with __counted_by Content-Language: en-US To: Kees Cook , David Airlie Cc: Tejas Upadhyay , Emma Anholt , Tom Rix , llvm@lists.linux.dev, dri-devel@lists.freedesktop.org, Chris Wilson , Prike Liang , Huang Rui , Gerd Hoffmann , Andrzej Hajda , Marijn Suijten , Matthew Brost , Karol Herbst , Neil Armstrong , amd-gfx@lists.freedesktop.org, Kuogee Hsieh , Nathan Chancellor , VMware Graphics Reviewers , Ben Skeggs , Andi Shyti , nouveau@lists.freedesktop.org, David Airlie , virtualization@lists.linux-foundation.org, linux-hardening@vger.kernel.org, Lijo Lazar , Yifan Zhang , linux-arm-msm@vger.kernel.org, intel-gfx@lists.freedesktop.org, Kevin Wang , Abhinav Kumar , Melissa Wen , Dmitry Baryshkov , Gurchetan Singh , Maxime Ripard , Rodrigo Vivi , Evan Quan , Sean Paul , Tvrtko Ursulin , Xiaojian Du , Le Ma , freedreno@lists.freedesktop.org, Bjorn Andersson , "Pan, Xinhui" , Nick Desaulniers , linux-kernel@vger.kernel.org, Alex Deucher , Nirmoy Das , Lang Yu , =?UTF-8?Q?Christian_K=c3=b6nig?= , John Harrison , Hawking Zhang References: <20230922173110.work.084-kees@kernel.org> <20230922173216.3823169-9-keescook@chromium.org> From: Maira Canal In-Reply-To: <20230922173216.3823169-9-keescook@chromium.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Hi Kees, On 9/22/23 14:32, 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 v3d_perfmon. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: Emma Anholt > Cc: Melissa Wen > Cc: David Airlie > Cc: Daniel Vetter > Cc: dri-devel@lists.freedesktop.org > Signed-off-by: Kees Cook Reviewed-by: Maíra Canal Best Regards, - Maíra > --- > drivers/gpu/drm/v3d/v3d_drv.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h > index 7f664a4b2a75..106454f28956 100644 > --- a/drivers/gpu/drm/v3d/v3d_drv.h > +++ b/drivers/gpu/drm/v3d/v3d_drv.h > @@ -59,7 +59,7 @@ struct v3d_perfmon { > * values can't be reset, but you can fake a reset by > * destroying the perfmon and creating a new one. > */ > - u64 values[]; > + u64 values[] __counted_by(ncounters); > }; > > struct v3d_dev {