From patchwork Wed Nov 29 15:22:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Zhandarovich X-Patchwork-Id: 171423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a5a7:0:b0:403:3b70:6f57 with SMTP id d7csp412369vqn; Wed, 29 Nov 2023 07:22:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IGVgSj+8KeQ18V+t9kcwIeDu/XGc9m7EyA9z7by/x8V57NTLPZqP1blzfkJpJjrZfQg1x4Z X-Received: by 2002:a17:902:e74d:b0:1cf:a54f:148a with SMTP id p13-20020a170902e74d00b001cfa54f148amr21212021plf.48.1701271346905; Wed, 29 Nov 2023 07:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701271346; cv=none; d=google.com; s=arc-20160816; b=uqnB23cNoxj99Bef5FyULJ65cG9c5bkSfJklVyGpIlG/rCBf3+FgOCRKZhgk0aPt5T VlnK06i7U8XW0shBi4w94liG8aut4y16AF4oRo/Tjo2ysPa6JrhTJadKRSRJqJsOwHuL BJDNbVyjWtfGSPBcS7X8nbl8LYkRkk8Gaq0CgprSNMBuy1AkgrlM8RPwy/08HPiOSUOq h1VAt9ASfRkgm0S6f66YnwH93RdNDB7OnVqb5kOM/tmIsBdLC/CEAcY0m+sHS1lIlLZN hoI7BZv2y0YYXG/fHu8w3P3+j+5etcnE2lMzURYyaXFkB63SH372O19ANAphaB6/h3K5 kPtA== 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 :message-id:date:subject:cc:to:from; bh=X5tF/C78GbrYRRYzcZPHdME/M08k+d9ci2xHb/MrWI0=; fh=4q22HGY2eDjQm55VTqpfb+Hmc/Gy9Op0J9PRh2oVBhc=; b=JHl55fA9pKF++Tk1uHF+KO7gGdhc0pnY3UiAIk51g5f1r9F2sdTTSLPLyrrP3HYSQ5 rBXuaGSFoJlhXXZORCcRT8dR45/9icW/WJ3GC92vBVAfODxypuOtiLRXObo8PAn6bdlW Z6Nm0w4lGSs4aiZTjycaSdVt1yK2Ut2V9WxPs2gMbdt2jt/ToVc7Fq89YVs5qja9lpNA a/FvJzcqEBdZd6qCJEsGd1YcXHH2PIDYqUVH2fdcdb6z6TBQBCrsk2Xk10Iy5PkY14mm G4a3swhoRvsylf/bIyVowJlkQbDDQO/Py7esEL+SzUEpl6wjFEsNoVncl92SmG4ZD9Jf FKRg== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id jc11-20020a17090325cb00b001ca24970584si12879068plb.572.2023.11.29.07.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 07:22:26 -0800 (PST) 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; 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 Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1C5DB80401B7; Wed, 29 Nov 2023 07:22:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234820AbjK2PWP (ORCPT + 99 others); Wed, 29 Nov 2023 10:22:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234629AbjK2PWN (ORCPT ); Wed, 29 Nov 2023 10:22:13 -0500 Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D371A3 for ; Wed, 29 Nov 2023 07:22:18 -0800 (PST) Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.159) with Microsoft SMTP Server (TLS) id 14.3.498.0; Wed, 29 Nov 2023 18:22:17 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Wed, 29 Nov 2023 18:22:17 +0300 From: Nikita Zhandarovich To: Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= CC: Nikita Zhandarovich , "Pan, Xinhui" , David Airlie , Daniel Vetter , , , Subject: [PATCH] drm/radeon/r100: Fix integer overflow issues in r100_cs_track_check() Date: Wed, 29 Nov 2023 07:22:12 -0800 Message-ID: <20231129152212.7879-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.0.253.138] X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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]); Wed, 29 Nov 2023 07:22:24 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783912304022119288 X-GMAIL-MSGID: 1783912304022119288 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 --- 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);