Message ID | 20230623211457.102544-6-Julia.Lawall@inria.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6049572vqr; Fri, 23 Jun 2023 14:26:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wGhogcWSxO/Mwi0zR1ws+kzkV6930cm61IrcnChPVzzGlldIT/24U3rb0eA5r36sVlQUp X-Received: by 2002:aca:2109:0:b0:39c:9173:31f1 with SMTP id 9-20020aca2109000000b0039c917331f1mr23320768oiz.28.1687555606600; Fri, 23 Jun 2023 14:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555606; cv=none; d=google.com; s=arc-20160816; b=obrd70hYT6pprP2p8vAK/7GaEewTW/BSF8wvww5CQeJJOYL/qhLHR5y9KFmTdgVG9c WUyTp3aURzjwDW1X0xKNQSUdJvEcfBPqbOnMOHUW6O0yaeuNl1YRBRzr6lmgMtoGNBKF VVjZvYmjUumL+fw/4td1u+36ZIb2tzIG5MWVtCJpsU7jYgzj1/huMQ38HoJndEgiAmqF NXGMUMqKv30t3g/xGLn+W3cKALd/HR2iziD9Z/AJLTiocm//CSoQ4UhuoWKXu7Z0ibDD aRTCBc/3CspMQTrIbU9qNzPDpC1N7oYBvK05RV98QNkszpvHWoPmOzYs2EuALG8PsWZt 7z8g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8o1B2LX7Hh8TNSfFwUWyg0VffJUQJIzGAe2D6u+TlYM=; fh=fPN19taMOkcn+N410fgaeLFenvdK4hsDVESvGetjJCg=; b=mNusw9BpH/4bEF67JuHbnJm3QVyoGvUR27MoT/OkZENSgHEbhi4m8NCxbRgok1ZoIT zbtY4JRVbaZw42D+Wm6KQQNm0iKJkC1bsMDRI4LIN12GOPiL0dbrr0kIsa6jTiRiEO9P uRfzKYHNNHMWfCNCI5naXC9HN75HT8g+KhRSrxl5gRj2IOAdB0fM+cYhCMe/1xa51rEd 9G+VLEP3NFhMr821iqSPbJaQRKDFuwRTVsyY+CRKyfeXIgYAK1XJzUYsx9BnlzjyCy2+ BPLADvut/+7LdgammIsF3HeWGUzN870t/2jUbUSbcaC9K7uQ4S3ofPILfhtAxaf/jfVO SM5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=W3acjQz8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a17090ad78900b00260fcf90085si325013pju.97.2023.06.23.14.26.19; Fri, 23 Jun 2023 14:26: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; dkim=pass header.i=@inria.fr header.s=dc header.b=W3acjQz8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232923AbjFWVUO (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Fri, 23 Jun 2023 17:20:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233011AbjFWVTv (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 23 Jun 2023 17:19:51 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0B1B2949; Fri, 23 Jun 2023 14:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8o1B2LX7Hh8TNSfFwUWyg0VffJUQJIzGAe2D6u+TlYM=; b=W3acjQz81RgrW6TdUMeb4r5oVbvfBcJvglLvPyOomZw/Gz8zv3C2ybyt AQ/zZDn6VqQdCUL//CFztcf75hpwVKw2+UgTxjLTK+AnY3+yTDXwXfmru sa5l3mQ45KeFeCJR8op6gb0OOs7TVWJiQ+Tivrh+kEULUahwlkii+ThaU E=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.01,153,1684792800"; d="scan'208";a="59686163" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2023 23:15:10 +0200 From: Julia Lawall <Julia.Lawall@inria.fr> To: Cheng Xu <chengyou@linux.alibaba.com> Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Kai Shen <kaishen@linux.alibaba.com>, Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/26] RDMA/erdma: use array_size Date: Fri, 23 Jun 2023 23:14:36 +0200 Message-Id: <20230623211457.102544-6-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230623211457.102544-1-Julia.Lawall@inria.fr> References: <20230623211457.102544-1-Julia.Lawall@inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530307699653313?= X-GMAIL-MSGID: =?utf-8?q?1769530307699653313?= |
Series |
use array_size
|
|
Commit Message
Julia Lawall
June 23, 2023, 9:14 p.m. UTC
Use array_size to protect against multiplication overflows.
The changes were done using the following Coccinelle semantic patch:
// <smpl>
@@
expression E1, E2;
constant C1, C2;
identifier alloc = {vmalloc,vzalloc};
@@
(
alloc(C1 * C2,...)
|
alloc(
- (E1) * (E2)
+ array_size(E1, E2)
,...)
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
---
drivers/infiniband/hw/erdma/erdma_verbs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 6/24/23 5:14 AM, Julia Lawall wrote: > Use array_size to protect against multiplication overflows. > > The changes were done using the following Coccinelle semantic patch: > > // <smpl> > @@ > expression E1, E2; > constant C1, C2; > identifier alloc = {vmalloc,vzalloc}; > @@ > > ( > alloc(C1 * C2,...) > | > alloc( > - (E1) * (E2) > + array_size(E1, E2) > ,...) > ) > // </smpl> > > Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> > > --- > drivers/infiniband/hw/erdma/erdma_verbs.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Thanks, Acked-by: Cheng Xu <chengyou@linux.alibaba.com>
diff --git a/drivers/infiniband/hw/erdma/erdma_verbs.c b/drivers/infiniband/hw/erdma/erdma_verbs.c index 83e1b0d55977..c49160f6ff27 100644 --- a/drivers/infiniband/hw/erdma/erdma_verbs.c +++ b/drivers/infiniband/hw/erdma/erdma_verbs.c @@ -462,8 +462,8 @@ static int init_kernel_qp(struct erdma_dev *dev, struct erdma_qp *qp, dev->func_bar + (ERDMA_SDB_SHARED_PAGE_INDEX << PAGE_SHIFT); kqp->hw_rq_db = dev->func_bar + ERDMA_BAR_RQDB_SPACE_OFFSET; - kqp->swr_tbl = vmalloc(qp->attrs.sq_size * sizeof(u64)); - kqp->rwr_tbl = vmalloc(qp->attrs.rq_size * sizeof(u64)); + kqp->swr_tbl = vmalloc(array_size(qp->attrs.sq_size, sizeof(u64))); + kqp->rwr_tbl = vmalloc(array_size(qp->attrs.rq_size, sizeof(u64))); if (!kqp->swr_tbl || !kqp->rwr_tbl) goto err_out;