Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp577219rwb; Mon, 26 Sep 2022 03:09:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6hogWfu80106e4rWejYaZzreIYeVFMoe5qEwgaMsoH88xVUo0cNydpqh4vzKQfdUjPYIxG X-Received: by 2002:a17:907:320c:b0:77b:6f08:9870 with SMTP id xg12-20020a170907320c00b0077b6f089870mr17491807ejb.249.1664186986989; Mon, 26 Sep 2022 03:09:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664186986; cv=none; d=google.com; s=arc-20160816; b=HasKOT/rZuZr6gqhveW3nM3RMImFyZtpR5zdjcGeK9Hv/k+r8UbnO1AZU/J86Rllg/ a0ujXCgPBLnDEJGiLigcviuOJVIUVbIoL9q1qOuOZXe/Xfi8UTFf6S4kU4YPE9BC/lOS oWDfqV2zswAG5OHoRVYczw223D6Wx4e7mmNLqNqZO/YqgUQ6FYr4HiCJjpxvH0lfn+sW B/QJVRK5V+XGsYK3CbAp6D+NJoh4EEZFq4k9wpRpgr9kFWGAqEU62UCRoUSzuXDimwMS q9Lk9m9N0E6dTXGQlsnUlt1OzbNgdXiBezpVjdD+24N1sy2H1ZvbP/Xkwb/Xr0APr5R6 24qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=whH/i2tAOJT2ltergKYZtk8PaViolhHIQ04UzIgDcgI=; b=FsvfdWK8/GRlPT0Hy7+VtufB3nSLtEtn4pGPL0GXbnJlqKoPdwnA2j08bkJzV5vIN1 7k0/Wzkow3aEy3Sh1ute/vUCPfJs05jpLsALfeO4eu3ZQE54pNfInKcJRdFP0W88Wqe+ rlzVVsITktjeJEEyZX1Oki08LTTMsIULTLVizc/8xktNQw+jju3aQNhYrR3pmnL24HVX cZsEsNZiplArzpbdnKeCFTFm6vgT2zeYEQ2dAqKwZpklJ11jF2cUqzpeDNdFn57lGO1l +stGajefLg7M31NCGvknOgWFadWuPYku+yT8m/io1kukIJa75M7Y0kD1oLOis4ySWZdg Bl1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb39-20020a1709071ca700b0077ed84da316si17055706ejc.217.2022.09.26.03.09.21; Mon, 26 Sep 2022 03:09:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234340AbiIZJ0W (ORCPT + 99 others); Mon, 26 Sep 2022 05:26:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234251AbiIZJZq (ORCPT ); Mon, 26 Sep 2022 05:25:46 -0400 Received: from mail.nfschina.com (mail.nfschina.com [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B5E31E0CD; Mon, 26 Sep 2022 02:24:49 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id F2DCF1E80D99; Mon, 26 Sep 2022 17:20:46 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RtFvrhUFBcKz; Mon, 26 Sep 2022 17:20:44 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id AC4901E80D96; Mon, 26 Sep 2022 17:20:43 +0800 (CST) From: Li Qiong To: Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , David Airlie , Daniel Vetter Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, Yu Zhe , Li Qiong Subject: [PATCH] drm/msm/gem: Use size_add() against integer overflow Date: Mon, 26 Sep 2022 17:23:15 +0800 Message-Id: <20220926092315.17193-1-liqiong@nfschina.com> X-Mailer: git-send-email 2.11.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "struct_size() + n" may cause a integer overflow, use size_add() to handle it. Signed-off-by: Li Qiong --- drivers/gpu/drm/msm/msm_gem_submit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c index c9e4aeb14f4a..3dec87e46e50 100644 --- a/drivers/gpu/drm/msm/msm_gem_submit.c +++ b/drivers/gpu/drm/msm/msm_gem_submit.c @@ -30,8 +30,8 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev, uint64_t sz; int ret; - sz = struct_size(submit, bos, nr_bos) + - ((u64)nr_cmds * sizeof(submit->cmd[0])); + sz = size_add(struct_size(submit, bos, nr_bos), + ((u64)nr_cmds * sizeof(submit->cmd[0]))); if (sz > SIZE_MAX) return ERR_PTR(-ENOMEM); -- 2.11.0