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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 DD633E7E632 for ; Tue, 26 Sep 2023 13:02:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AB42B10E3D9; Tue, 26 Sep 2023 13:02:43 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2D39710E3D7 for ; Tue, 26 Sep 2023 13:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695733359; x=1727269359; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=m5zreZo5wVRQuugDEEqaXm7c4/FdxN3AprXTSuhg0aI=; b=R0iSCy3YqmpYhraV4QQDmaB6a08WrFCBJUi5kdRVRX7M85GQayXdCuSI Cd5veGMGzDQ4GrMF0/D/xVbAAfWvtktGxRWdDJRgbdW0cWhx4jJQ9xkas V3D/MkI+yYs4TwyfZW48FiqxOgxpyib/IE1renvcF/BLzLXHisKofdG2f BzVP2bAiBQDAU19miwp1ghRyLKH/ql24726ohNMRNA8uVHroXX+7AhVGZ mIEeHvAYik+tA936RGFZjUbKar+0KBdGMGkCWpzFdxDHfb4x/tjMJr6Kj R3BcxPeDXHkzKDaJEFQVSLZehLVOADMC2ehsJ9BDM2rVZ8A6Nkc9BpaPw A==; X-IronPort-AV: E=McAfee;i="6600,9927,10843"; a="366617024" X-IronPort-AV: E=Sophos;i="6.03,177,1694761200"; d="scan'208";a="366617024" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 05:55:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.03,177,1694761200"; d="scan'208";a="139495" Received: from hblancoa-mobl2.ger.corp.intel.com (HELO localhost.localdomain) ([10.252.50.200]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Sep 2023 05:55:56 -0700 From: Francois Dugast To: intel-xe@lists.freedesktop.org Date: Tue, 26 Sep 2023 12:55:11 +0000 Message-Id: <20230926125540.7-2-francois.dugast@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926125540.7-1-francois.dugast@intel.com> References: <20230926125540.7-1-francois.dugast@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Intel-xe] [PATCH v3 01/30] drm/xe: Fix array bounds check for queries X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Francois Dugast , Rodrigo Vivi Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" From: Umesh Nerlige Ramappa Queries are 0-indexed, so a query with value N is invalid if the ARRAY_SIZE is N. Modify the check to account for that. Fixes: 22504d560287 ("drm/xe: Introduce a new DRM driver for Intel GPUs") Signed-off-by: Umesh Nerlige Ramappa Reviewed-by: Niranjana Vishwanathapura Signed-off-by: Francois Dugast Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/xe/xe_query.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/xe/xe_query.c b/drivers/gpu/drm/xe/xe_query.c index a951205100fe..e0c2203e428e 100644 --- a/drivers/gpu/drm/xe/xe_query.c +++ b/drivers/gpu/drm/xe/xe_query.c @@ -381,7 +381,7 @@ int xe_query_ioctl(struct drm_device *dev, void *data, struct drm_file *file) XE_IOCTL_DBG(xe, query->reserved[0] || query->reserved[1])) return -EINVAL; - if (XE_IOCTL_DBG(xe, query->query > ARRAY_SIZE(xe_query_funcs))) + if (XE_IOCTL_DBG(xe, query->query >= ARRAY_SIZE(xe_query_funcs))) return -EINVAL; idx = array_index_nospec(query->query, ARRAY_SIZE(xe_query_funcs)); -- 2.34.1