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 44B445BAD4; Tue, 23 Jan 2024 01:45:53 +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=1705974353; cv=none; b=uPvQ3ImIhche3tMW1C5HnbuKlwXUWuRTQXCp2KC4UyngU+hzHeZ8QpcyKJucUR41bjPzV6Y9k8DTWRSxt+ngvhS+7BzlDrBTopfz2srKlMOIm5sNdqsDgyUqIp+j37BCktd3XGAvZGLMmm1M4C1dpsM76yG01KvRXMrP99+uVos= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705974353; c=relaxed/simple; bh=e9Z9CMYMJV92S8DutiGS81hHQpzh4UY2NzYW95FUX1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QCMv6GJxrJcuZmw+Zb9gEWADDMRb5el49aSr3aEyD+Y2Iz5Iw+/vIS/zJVigsTwgg/hRQdEVKBEkoaREcbizGvX+ykN8HYUdDmG0LILGA/9NCPNPnyW5Tm7+f8uhWnOsgeCnmBQ6zrxjRrlFromgnTsHZTLCP8FNF6MxBzIN7G0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=mxM0xSro; 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="mxM0xSro" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A0C0C43390; Tue, 23 Jan 2024 01:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705974353; bh=e9Z9CMYMJV92S8DutiGS81hHQpzh4UY2NzYW95FUX1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mxM0xSroCLTr/Mq4CSgqjv3WbQ5siH6YOY2RZO1WKgPU+0GDJk1poHxKmLJf2bS0F xN4/jZyzzL2FLQ2HY89I21FG5CAvmd+kiFA+teFW2sMKomrCuBJij3A60m+VCVK4bJ P5rRMqMnYEeSE/GQv+G9B/wwew3zSAt67nfzcjB0= 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 5.15 188/374] drm/radeon/r100: Fix integer overflow issues in r100_cs_track_check() Date: Mon, 22 Jan 2024 15:57:24 -0800 Message-ID: <20240122235751.163048656@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235744.598274724@linuxfoundation.org> References: <20240122235744.598274724@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 5.15-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 2dd85ba1faa2..d3ad98bd2590 100644 --- a/drivers/gpu/drm/radeon/r100.c +++ b/drivers/gpu/drm/radeon/r100.c @@ -2320,7 +2320,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); @@ -2339,7 +2339,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