Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp3035974rdb; Fri, 22 Sep 2023 16:29:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEodI4O8P+yih2Nb6iLSoH6xlRQFDPQkRMCBV/hekC2qeyxNXDMJtU9pJbF5n7K1qtZQL3M X-Received: by 2002:a05:6a20:1614:b0:13e:1d49:7249 with SMTP id l20-20020a056a20161400b0013e1d497249mr1081047pzj.2.1695425394866; Fri, 22 Sep 2023 16:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695425394; cv=none; d=google.com; s=arc-20160816; b=pl+7XLeQy+bnAN7exHnDo4ApHsIeoZvCOSI1+uGkC7I3iBecjmZfrd0H7BeoRLFXc0 4ZfkYFHJAHLYmh5Qqdq/fg9DGUikoJLb+Sj24Oi3URMkda1pX2slxU1ww6HqeubtYTTr +reSX8xczKY71T96h3tEBe1uFi3XMiFjeDK/NRoVhMEiwMwkxlc3W9xi31r3VuyQyG0n FiTWozcrF+aVTh7+SE2Iz1T/f/QcrVn5A+sNvW0dvNZ9FLcHBmJ0bgli153c4wrqGO5T YMio17jWHE/bKtROv2kcMkNWtASJF2VUyD2Rx80DlDqPneFDknT3NWRUyCZZTFDcFetZ pMQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0+TspM6FqnyWCQqgdT3WqLoCMBUMYLUrvB7POKzIF40=; fh=cr5Wwxux3dYHHq1zs7a07aCFZGZKu3SzwqqckWqiY+w=; b=0e9ijXNbLXiw+FZcKgNoCX2+PlBhg2GM7GxyqTmI+3Z2lcEOmcBrkeOzyQV9zebnuZ +cHPHi5DoL0rK0+9+QpOpCcfpN7PFDtqs2x2gQNVvmYEOp/37nAKh8p64I3OaJ8cm30a VIVgz7yisORulSbLjs1s5TksiIFaniwjvD7Nv4UtKEsoVcPPhn0BUhusxXM8uPdS6xMT YEwwl3Qg/HqVpdGJt/SNAlTidwFYB1hceOBpjeDeBOCxM7Pa/GPo4UyHxYu3rlfa0KD0 zNeagBcXag7on8qF7LS5uvcYlasJeg535dpcf5kzoGgpR2uzFvhvgZgp0zJke1dW0HQ+ M+rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FCq3PIT3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id eb17-20020a056a004c9100b00690158afc78si4727114pfb.284.2023.09.22.16.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 16:29:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=FCq3PIT3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 2F6AE82AE379; Fri, 22 Sep 2023 10:33:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233383AbjIVRdV (ORCPT + 99 others); Fri, 22 Sep 2023 13:33:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233176AbjIVRcr (ORCPT ); Fri, 22 Sep 2023 13:32:47 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A19ECFC for ; Fri, 22 Sep 2023 10:32:24 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c1ff5b741cso22793885ad.2 for ; Fri, 22 Sep 2023 10:32:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403944; x=1696008744; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0+TspM6FqnyWCQqgdT3WqLoCMBUMYLUrvB7POKzIF40=; b=FCq3PIT3w40R5PU6BHA+wllkS5eBw780rg5jc3kJhpk72bmDVp1nfTKqc+uIKQ6ZLK LIqyxjO0cU1BbM4E8UxPiKjmC3wul/Cnh5VU5m02whkK7qL+eDDzDGDdkbW7UuxC7s9i Sgn1S2DF5xuYZyWAPBkYsCa6Hwixaey4/kPfs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403944; x=1696008744; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0+TspM6FqnyWCQqgdT3WqLoCMBUMYLUrvB7POKzIF40=; b=ETUIvPQ8Xju2jTHzKsmuyhKsu+S4eMMNzlFdFUMTJOs9Til/axYhOI1TyRdqTFN5bz MkgJcVYJJu9mduI6Q0M946FaovoZHCg6IILMznjISOe68iaCe8C5KjEKwKgPCAb/5hoC FJnUofKa0u+U+O9FOh30qFWJNLY7V4Q7eGcpAaweatJien4FNlhdcpAzY/y+2xVoS3c7 /zs92XB2aC/T9s5NmMMrJ/UxsyH8c/8k8a/Kc2cIQG7DXO57+qodFHY2wyFch1fonuVA /Od2wk4lJC8J2yFcKm8bOO31jYgCXK9zcZlOX1HkC96C60y9Pyh8x4G5wWNzWgL2iI8k 6Mwg== X-Gm-Message-State: AOJu0Yy6Xl7aHNtThb8yFzjsKw/U/BJNOyySmHGgl1gZrQj2T3rI7jt5 n56KVbtQKeuYvnAUpBZw03HW0Q== X-Received: by 2002:a17:90a:a095:b0:26b:e27:8bc2 with SMTP id r21-20020a17090aa09500b0026b0e278bc2mr327022pjp.45.1695403944421; Fri, 22 Sep 2023 10:32:24 -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 a11-20020a17090abe0b00b00271c5811019sm3479258pjs.38.2023.09.22.10.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:32:22 -0700 (PDT) From: Kees Cook To: David Airlie Cc: Kees Cook , Emma Anholt , Maxime Ripard , Daniel Vetter , dri-devel@lists.freedesktop.org, Evan Quan , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , Xiaojian Du , Huang Rui , Kevin Wang , Hawking Zhang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , Chris Wilson , John Harrison , Andi Shyti , Matthew Brost , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , Bjorn Andersson , Ben Skeggs , Karol Herbst , Lyude Paul , 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 , Andrzej Hajda , Neil Armstrong , Kuogee Hsieh , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-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: [PATCH 6/9] drm/vc4: Annotate struct vc4_perfmon with __counted_by Date: Fri, 22 Sep 2023 10:32:11 -0700 Message-Id: <20230922173216.3823169-6-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922173110.work.084-kees@kernel.org> References: <20230922173110.work.084-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1277; i=keescook@chromium.org; h=from:subject; bh=4ERTESaqnYz8ImDqyHPyzXy0AuquVom9vq+hq0gy89g=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc+eg2zdwhFFl6K23RVdCG+VU9OV+t2/BviGN QnAc1heAtyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3PngAKCRCJcvTf3G3A JvO0D/4+c0QkeKEEEd/HWEG0VvFv4kIlOeqfDMOPwJ1QkN1jVwlbiQVdn9lWjRgUq77jqzdpagc 0e9qirU7jL0cbTe+JOBsFEQkZYwnIV0EUxV5Wb9g3csLF1vPRQafhR8984UzEKRtulAS9kQTSMT xYBkkYy+pbMJZNux38iCGgJFdWD057RPEazeM0Aatd5kaNk0HGNFRG/lz7HPcD9XIged7BCjFe4 O5fJlM/WnYAAAK2cZn9AtONFzhR65gyQwb4pt0CXxC/kBS6pb6GBT8V9AsVWH8zu6CsMIVjafAT OdJEF/tJGI7jp48gN51zXgv1VAdOAJOLBc/kciYavjyryrGgXYANueMuiXx+r42kxUG0yZkO3/X uq+N33+UiId1hMftODv6WGPcCbwFJtgAfev1bfSRgKYiKQyjWPcbW5NPGeYVKKsvsew1qqGZWpN ASd96EwnB4kIHBeIp1k14aTdlgBVRePuuE2Vrf/gjb9uTNMh605/Yq2hNu83sG0S0fKskR2pH6r /VbQ9GYa6Dm3r4bYE6S0RRzMROjl3MXFBv4R99QF1UUF4V4iGgkcUUE3tdB+iCxIW1I5SuGR620 4ajKmF3Z9xPkw56NlVdKBjnhCKGSlHNQv+Rh5xh0IeFJzR6f8SO8/u45ADDZHCkCqxoc7tiLP68 zupfltyyH8r66bw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:33:30 -0700 (PDT) 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 vc4_perfmon. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Emma Anholt Cc: Maxime Ripard Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel@lists.freedesktop.org Signed-off-by: Kees Cook --- drivers/gpu/drm/vc4/vc4_drv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h index bf66499765fb..ab61e96e7e14 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h @@ -76,7 +76,7 @@ struct vc4_perfmon { * Note that counter values can't be reset, but you can fake a reset by * destroying the perfmon and creating a new one. */ - u64 counters[]; + u64 counters[] __counted_by(ncounters); }; struct vc4_dev { -- 2.34.1