Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13035320rwd; Fri, 23 Jun 2023 14:42:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7cS3HbiZ3atDfddpT1U7yqxzEAvKpwF9g+KQrtzRgOW52M4zBaq92G24pniFsHkE1/Rgba X-Received: by 2002:a05:6808:1d9:b0:3a0:567f:35f5 with SMTP id x25-20020a05680801d900b003a0567f35f5mr7478485oic.47.1687556565526; Fri, 23 Jun 2023 14:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556565; cv=none; d=google.com; s=arc-20160816; b=i3jFBE+kf0sL/7Mjw4vXpqD3TVQCkGg5CAbWpaLjInkGBRwGiMc8k7S8r604r69epM YdnqABU+PTQgBpc+sJqPelAaJf2sO/rtr2ha6kEFRoHLxcaCq1J8HBmRvmpFJBY4Hj2o lR1tpSy0RMO+PbZ37xE/aV3Qtuf37/3veuHqf+bRvgQULS5OrqT7G+qlvN75geD2743W Hl2OxpTwPGzyG4aAd+YjjbkyPXwxPbMEMV8O+7Ra7FJrux7e7qOBUulEK2KXL/YEGWSO 4nY9JgUJMeKcfE51ihqFsyeU0q9TaFh29fDvM0ZfD1/ABsQxx6P1EkVcalSYcEPKf0tv FKVw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a17090a1b0c00b00260a7aee610si2451628pjq.152.2023.06.23.14.42.33; Fri, 23 Jun 2023 14:42:45 -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 S232921AbjFWVUN (ORCPT + 99 others); Fri, 23 Jun 2023 17:20:13 -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 ); 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 To: Cheng Xu Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Kai Shen , Jason Gunthorpe , Leon Romanovsky , 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: X-Mailing-List: linux-kernel@vger.kernel.org Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/infiniband/hw/erdma/erdma_verbs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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;