From patchwork Fri Jun 23 21:14:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6055725vqr; Fri, 23 Jun 2023 14:43:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Sm6Cn+tgJRxnjnNVYSowUxzCJRhqYVL54r9ZbqqJPOj99RiFrzkJzl6knDZqFshYceED+ X-Received: by 2002:a17:902:868f:b0:1b3:ec08:f8e2 with SMTP id g15-20020a170902868f00b001b3ec08f8e2mr234953plo.49.1687556590330; Fri, 23 Jun 2023 14:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556590; cv=none; d=google.com; s=arc-20160816; b=zqs1xZzgFCSe926JcD5LkvI3e5I78hssgb46zd4CnySCEcvfLjn08KUBRj9zhzBwwA YL+rGEnPJUryOoaXnimYPWRxEfysjZMku5p3cI3ABeWtjTsUtjXuKjS6jXmMnXXXTsYR D8cBIk4XNea6EJnVqcDXWQvTKgOeZkIoUhcmOMJgqVQ8zXX+Dpnjb1SqDu90XmI8qDJ1 iQN0B/bJWHHNq37g924J8cB3mqpQt88ipuPplqeh020IIGcv2Q/oCU9Idr134rzgqFf6 IyZ2hDfwG8PrrK4Ha/stqSNwuiRH3xadt7F+bxDrNY6Gi8P9cXE1WrgbkgWqeIc2tjrO q+zA== 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=q8fH1XyQxmARYocJhPPGMcs4NWJZYuZGeywIVulmPQY=; fh=hDtFpMQzPzneqOM4qBUUOVoMkJlN7PCDODc8ZRjU6qo=; b=Jou0n+dEbR+qzjQ88dQm9M0Pvt73TiyTqiLWbQzmNmAABJjZ1oX3ooQ3BCIpOrpszO 3UPzXuUL5SU3Z8KrbGbzhShXXx2UyTbGmTfy4tar1EZemLUS0TTmzzo3ESa9EEmaMoAG bTw+WJ039mUfpWT9lIPrQYDZF9gRyzFb+jb5x+gITLCB2hNxnyv8uan2q2Qa1ZsNzZz0 O+sXts7uipaOjv+RBDz+WkczDL9cwFNVQtxatdx5s7Gn1poXYNhcrNkIVRgt2X9tgM/c ugHB/huXaibphxMwiXnLKhfV1CP1LadxvYSdJTfhSAiKuoZ3w6GZlyXhmglAOwepTOhj MfSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b="XKE/KhM+"; 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 d19-20020a170902b71300b001b66f00d40csi61416pls.351.2023.06.23.14.42.58; Fri, 23 Jun 2023 14:43:10 -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="XKE/KhM+"; 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 S232760AbjFWVPV (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231978AbjFWVPP (ORCPT ); Fri, 23 Jun 2023 17:15:15 -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 B46A0189; Fri, 23 Jun 2023 14:15:13 -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=q8fH1XyQxmARYocJhPPGMcs4NWJZYuZGeywIVulmPQY=; b=XKE/KhM+KKZI5szWCteFS3slNnUiCyWgU1iD3fRNxS81/HolDJ7JHSnu ee7gU71NB+eagWOB21InP0QJvpVyyckPjHtFnS7moz3Ok8Ov4u84nz1ze VICUC1wGomN3ti0kodaswdijsh6e/o9njQ1p+PCQLi1gZTrhcknLfNiPT k=; 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="59686162" 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: Jeroen de Borst Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Praveen Kaligineedi , Shailend Chand , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/26] gve: use array_size Date: Fri, 23 Jun 2023 23:14:35 +0200 Message-Id: <20230623211457.102544-5-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 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=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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769531339108846068?= X-GMAIL-MSGID: =?utf-8?q?1769531339108846068?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ size_t e1,e2; expression COUNT; identifier alloc = {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Simon Horman --- drivers/net/ethernet/google/gve/gve_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/google/gve/gve_tx.c b/drivers/net/ethernet/google/gve/gve_tx.c index 813da572abca..d77ebbb24936 100644 --- a/drivers/net/ethernet/google/gve/gve_tx.c +++ b/drivers/net/ethernet/google/gve/gve_tx.c @@ -248,7 +248,7 @@ static int gve_tx_alloc_ring(struct gve_priv *priv, int idx) tx->mask = slots - 1; /* alloc metadata */ - tx->info = vzalloc(sizeof(*tx->info) * slots); + tx->info = vzalloc(array_size(slots, sizeof(*tx->info))); if (!tx->info) return -ENOMEM;