From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B21B7107B8 for ; Mon, 25 Sep 2023 17:50:06 +0000 (UTC) Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95B0F180 for ; Mon, 25 Sep 2023 10:50:04 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3ae0135c4deso4255706b6e.3 for ; Mon, 25 Sep 2023 10:50:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695664204; x=1696269004; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LrNZUYK9GVon3CstC3PAw8y74HnTAoBSBfYauDl4OzM=; b=PLobzVaKliHwG+r2YWO73hENA1yrUAsyTU/h9lAFy5hCMYuhBPCLFuzyJDn0oVEo35 2NuL8BcoSHqKwUDhJY1ahZePrb9yaJ7Hl6HYrxPCuVrQz7nNRmTHc6f6zFFSdu+Unw7G lpHY5BJz0LK1Kq0/TpHF7nyWypBj3pd07ViJ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695664204; x=1696269004; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LrNZUYK9GVon3CstC3PAw8y74HnTAoBSBfYauDl4OzM=; b=spWZUFMCc9GEwLqHZ2Flx2hA+LSJkTKzSScLzSNUo5X/54oODVili2LY2aUz75XWRQ 4xAP8Y08+K/A2LkYvPPhBZMhqoT61p9xlwZYBukrd/Cy8UTqHL9KMA99j7xHqoaMxg0Q vq9fwN9p3rcPgwYJ0ruRnGm+dxd6D4o68GDprc46vUwIUMohDmwBAHUULoHZpYj9JvE/ mtx9SyBjDJjLg85V5+h5h0twoUoVmJe0Wp8CyUNFnKKlMKZVdj31QbSsTHkamVNlCnZP uLOBRLAY1nmchRCDGWvmDNso7cV4mS2qSg9DGtX9M94iKycKcLyrPgzPxzCKYj6zawGl IzUg== X-Gm-Message-State: AOJu0YyRTpItbIczeGRRTZ5kLsa0C1Ln0QO8wuMr5vNTof76Yn1pRs9A v6grPwcoEdG4M3lhm6B1XycyFg== X-Google-Smtp-Source: AGHT+IGie+Z/VwhJ6V3LKWh5OI/Dj3Px8pRaI7N33JgrgsWWDGZ81eWlnH9NeD8qxw1CQkfx2CSwHA== X-Received: by 2002:a05:6808:351:b0:3ad:fcd4:275e with SMTP id j17-20020a056808035100b003adfcd4275emr9044080oie.35.1695664203734; Mon, 25 Sep 2023 10:50:03 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id j12-20020a63b60c000000b00577d53c50f7sm7143781pgf.75.2023.09.25.10.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 10:50:03 -0700 (PDT) Date: Mon, 25 Sep 2023 10:50:02 -0700 From: Kees Cook To: Andrzej Hajda Cc: David Airlie , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Daniel Vetter , Chris Wilson , John Harrison , Andi Shyti , Matthew Brost , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Emma Anholt , Evan Quan , Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , "Pan, Xinhui" , Xiaojian Du , Huang Rui , Kevin Wang , Hawking Zhang , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , Bjorn Andersson , Ben Skeggs , Karol Herbst , Lyude Paul , Maxime Ripard , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Zack Rusin , VMware Graphics Reviewers , Melissa Wen , Nathan Chancellor , Nick Desaulniers , Tom Rix , Le Ma , Lijo Lazar , Yifan Zhang , Prike Liang , Lang Yu , Tejas Upadhyay , Nirmoy Das , Neil Armstrong , Kuogee Hsieh , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, nouveau@lists.freedesktop.org, virtualization@lists.linux-foundation.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: Re: [PATCH 3/9] drm/i915/selftests: Annotate struct perf_series with __counted_by Message-ID: <202309251043.2D1F7D08@keescook> References: <20230922173110.work.084-kees@kernel.org> <20230922173216.3823169-3-keescook@chromium.org> Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net On Mon, Sep 25, 2023 at 12:08:36PM +0200, Andrzej Hajda wrote: > > > On 22.09.2023 19: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 perf_series. > > > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > > > Cc: Jani Nikula > > Cc: Joonas Lahtinen > > Cc: Rodrigo Vivi > > Cc: Tvrtko Ursulin > > Cc: David Airlie > > Cc: Daniel Vetter > > Cc: Chris Wilson > > Cc: John Harrison > > Cc: Andi Shyti > > Cc: Matthew Brost > > Cc: intel-gfx@lists.freedesktop.org > > Cc: dri-devel@lists.freedesktop.org > > Signed-off-by: Kees Cook > > I am surprised this is the only finding in i915, I would expected more. I'm sure there are more, but it's likely my Coccinelle pattern didn't catch it. There are many many flexible arrays in drm. :) $ grep -nRH '\[\];$' drivers/gpu/drm include/uapi/drm | grep -v :extern | wc -l 122 If anyone has some patterns I can add to the Coccinelle script, I can take another pass at it. > Anyway: > > Reviewed-by: Andrzej Hajda Thank you! -Kees -- Kees Cook