From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A5977664AC; Tue, 23 Jan 2024 01:58:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705975109; cv=none; b=nJdips2xLpX8NhODTsRNR9iY6iRPnNE/1QZOCQvaRyiEK3eCnfqOHvtSHC6a/YtKmZ8GFqiAxpl8eug9epk6BrKJ8DmOcmnT1aPqHOifeT7bUrubQIvyMan0XHpEHzguSH9k8DarESJ6mVZOabjOgRmu7fpf/Wjp0fbCO+ibsck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705975109; c=relaxed/simple; bh=AYl7/igbFHCfqeCFskm2ne5qNWDjeM6XuypPVo1bs94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XZQ27fuhhnA0RL8xGonFPVip6j/413csNFiH+pLLTHDL5GrpVIlySc1q2NbHW0NgDEjqQxQyNYqPHbdYNoKdyjM7A1gv47pspGGuflkw92k8K6JRYQZFbIdFRdCyq+iBKGZICtkd1HyCQLqThZFWSS8RBcYlJ7atcmQd6+aHA00= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GNadlIya; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GNadlIya" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53F5DC433C7; Tue, 23 Jan 2024 01:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705975109; bh=AYl7/igbFHCfqeCFskm2ne5qNWDjeM6XuypPVo1bs94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GNadlIyavunFYbRLhMs4QCGMhLo2wALUUzfcazcT2kUgc6uXA0PtoEfOrdgJIA1DR QOzhbO+ZLw4f2Pr86hoA/ZTPcDUvqKoJ5Q79MwhCgafb/0KYze/Ythj9dqnMadqwdS 0pCbwcyr/Ix/kHUenUu6YzmmTCFNtBVz84jXRE0c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nikita Zhandarovich , Alex Deucher , Sasha Levin Subject: [PATCH 6.6 242/583] drm/radeon/r100: Fix integer overflow issues in r100_cs_track_check() Date: Mon, 22 Jan 2024 15:54:53 -0800 Message-ID: <20240122235819.400757645@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235812.238724226@linuxfoundation.org> References: <20240122235812.238724226@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nikita Zhandarovich [ Upstream commit b5c5baa458faa5430c445acd9a17481274d77ccf ] It may be possible, albeit unlikely, to encounter integer overflow during the multiplication of several unsigned int variables, the result being assigned to a variable 'size' of wider type. Prevent this potential behaviour by converting one of the multiples to unsigned long. Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: 0242f74d29df ("drm/radeon: clean up CS functions in r100.c") Signed-off-by: Nikita Zhandarovich Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/radeon/r100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c index affa9e0309b2..cfeca2694d5f 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c @@ -2321,7 +2321,7 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track) switch (prim_walk) { case 1: for (i = 0; i < track->num_arrays; i++) { - size = track->arrays[i].esize * track->max_indx * 4; + size = track->arrays[i].esize * track->max_indx * 4UL; if (track->arrays[i].robj == NULL) { DRM_ERROR("(PW %u) Vertex array %u no buffer " "bound\n", prim_walk, i); @@ -2340,7 +2340,7 @@ int r100_cs_track_check(struct radeon_device *rdev, struct r100_cs_track *track) break; case 2: for (i = 0; i < track->num_arrays; i++) { - size = track->arrays[i].esize * (nverts - 1) * 4; + size = track->arrays[i].esize * (nverts - 1) * 4UL; if (track->arrays[i].robj == NULL) { DRM_ERROR("(PW %u) Vertex array %u no buffer " "bound\n", prim_walk, i); -- 2.43.0