Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp24660rwb; Mon, 26 Sep 2022 08:51:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5mUtpQ31pF3APQqn8W5Yb5XaiwU72O7dJ0uAAHgGxU+ZYv+gtKi5yc1zAyyRkifCZAMHyJ X-Received: by 2002:a63:5714:0:b0:43c:4a0d:f94d with SMTP id l20-20020a635714000000b0043c4a0df94dmr14798977pgb.488.1664207470011; Mon, 26 Sep 2022 08:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664207470; cv=none; d=google.com; s=arc-20160816; b=Pc+TOdavTOXS+qNZq7pxhZqik9U9lwWvVk/hWEg48sKGD7Tx9kKIjLRVPnqvpAxk3b hr7lxw98LoUViFvkvy50+1mox0jNsFvUSYr9v2vsGgEzBeG3skYRkrhn5FOGVOvzbyjR verXM5RYQCKMIyQzvxBPj23h+KVpzS+EhCAbqo/cfLTjaR2P1ZOAf7tTvROBSp7upIhP Dw4jN6F6RhojuYIaeqX/UCZPC6POLPTv8vydhX4UA8EzNvtf18Zxe3qMbcnWDL+dfGwx 6f+AbVUriNnkdeOzxzVsuPmXv99Q94aCZVTmF+CbAn7UMJMIphAnO11K8L1tSUdj46OC pPOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=61ZAPE2tcYQ5YYHbcR24/NBKtOYBxVakWkQsDSI1My4=; b=Qi4gMUBxFpdv7l313by7HnmmpO2GUlQuRVCgMF+S6Nrauw2Hq1f42ySvJnO2C4VZJR 7qSu88v6IrLFzVp0Ob7AIofvOzqmfTSe6wcyf4WeAjaY/R3kXsqjZdr2UQpWND6arUWC T2XmOaVmvfmeFs+PZYSvCllgSW1QDMGlifWaSJwYgSPUH0mSHoyVpwvBwmR/Ee6YYFHI FPiMn5vRxLPYEtPOrCKF3ej5jOevbvznUrRyG2bdMzSFJmVanN7JN72PWnXSgWUpLvSs e7A1rlwOBC5MpQoJD7TMYgi6PKgSw66GAXuz5gi4kS/abW6aj8s17GHcM6NvAomlbRT7 ctSw== 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 nu3-20020a17090b1b0300b002009da5d10asi14021311pjb.128.2022.09.26.08.50.44; Mon, 26 Sep 2022 08:51:09 -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 S234337AbiIZOMb (ORCPT + 99 others); Mon, 26 Sep 2022 10:12:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234437AbiIZOLs (ORCPT ); Mon, 26 Sep 2022 10:11:48 -0400 Received: from mail.nfschina.com (unknown [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0D95B5EDC6; Mon, 26 Sep 2022 05:23:00 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id C4E331E80D6C; Mon, 26 Sep 2022 19:15:18 +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 HM1C-YBnYyoV; Mon, 26 Sep 2022 19:15:16 +0800 (CST) Received: from [172.30.38.124] (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id D82A01E80D3D; Mon, 26 Sep 2022 19:15:15 +0800 (CST) Subject: Re: [PATCH] drm/msm/gem: Use size_add() against integer overflow 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 References: <20220926092315.17193-1-liqiong@nfschina.com> From: liqiong Message-ID: <80db9ee7-481e-9793-87a6-83a9be6836ec@nfschina.com> Date: Mon, 26 Sep 2022 19:19:17 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20220926092315.17193-1-liqiong@nfschina.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 在 2022年09月26日 17:23, Li Qiong 写道: > "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); Sorry, This patch a mistake, drop it , please.