From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD6DAC001B0 for ; Fri, 23 Jun 2023 21:15:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230330AbjFWVPQ (ORCPT ); Fri, 23 Jun 2023 17:15:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbjFWVPN (ORCPT ); Fri, 23 Jun 2023 17:15:13 -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 669CC189; Fri, 23 Jun 2023 14:15:11 -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=jd3h5W+nQqo5i0Obf5JwrqgVHs0D/GmiD6Eb1h7EYkk=; b=o2bPTbjyvGhNakcmvltIzFi/S0dJfu9Nh1VS5e0zg/1JS++mceceIzEZ O7PNODtaLw2mJg4i9aMMzB7XRGoym9HrXS1pKqYtQ7Vsg2bbwPMfmlTgt dxCKI7WizKNgfJ8IyzurReMpwe4ujwBPvCygX56mzwX70LBSaRsT9N9j4 I=; 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="59686159" 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: linux-kernel@vger.kernel.org Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org Subject: [PATCH 01/26] lib/test_vmalloc.c: use array_size Date: Fri, 23 Jun 2023 23:14:32 +0200 Message-Id: <20230623211457.102544-2-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) @@ expression E1, E2; constant C1, C2; identifier alloc =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- lib/test_vmalloc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/test_vmalloc.c b/lib/test_vmalloc.c index 3718d9886407..d02a47e0a72b 100644 --- a/lib/test_vmalloc.c +++ b/lib/test_vmalloc.c @@ -156,7 +156,7 @@ static int random_size_alloc_test(void) =20 for (i =3D 0; i < test_loop_count; i++) { n =3D get_random_u32_inclusive(1, 100); - p =3D vmalloc(n * PAGE_SIZE); + p =3D vmalloc(array_size(n, PAGE_SIZE)); =20 if (!p) return -1; @@ -175,7 +175,7 @@ static int long_busy_list_alloc_test(void) int rv =3D -1; int i; =20 - ptr =3D vmalloc(sizeof(void *) * 15000); + ptr =3D vmalloc(array_size(15000, sizeof(void *))); if (!ptr) return rv; =20 @@ -221,11 +221,11 @@ static int full_fit_alloc_test(void) junk_length =3D fls(num_online_cpus()); junk_length *=3D (32 * 1024 * 1024 / PAGE_SIZE); =20 - ptr =3D vmalloc(sizeof(void *) * junk_length); + ptr =3D vmalloc(array_size(junk_length, sizeof(void *))); if (!ptr) return rv; =20 - junk_ptr =3D vmalloc(sizeof(void *) * junk_length); + junk_ptr =3D vmalloc(array_size(junk_length, sizeof(void *))); if (!junk_ptr) { vfree(ptr); return rv; @@ -271,7 +271,7 @@ static int fix_size_alloc_test(void) if (use_huge) ptr =3D vmalloc_huge((nr_pages > 0 ? nr_pages:1) * PAGE_SIZE, GFP_KERNE= L); else - ptr =3D vmalloc((nr_pages > 0 ? nr_pages:1) * PAGE_SIZE); + ptr =3D vmalloc(array_size(nr_pages > 0 ? nr_pages : 1, PAGE_SIZE)); =20 if (!ptr) return -1; @@ -293,7 +293,7 @@ pcpu_alloc_test(void) size_t size, align; int i; =20 - pcpu =3D vmalloc(sizeof(void __percpu *) * 35000); + pcpu =3D vmalloc(array_size(35000, sizeof(void __percpu *))); if (!pcpu) return -1; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30849EB64DD for ; Fri, 23 Jun 2023 21:19:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232620AbjFWVTC (ORCPT ); Fri, 23 Jun 2023 17:19:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbjFWVSb (ORCPT ); Fri, 23 Jun 2023 17:18:31 -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 D82ED294E; Fri, 23 Jun 2023 14:17:47 -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=6uQt9cKBk2Sag9c2YWWjAaGPZs3k3Hvob+itlodbJvE=; b=uUeK7v84Q78fePqXn2J06hqIJHU44vOesDD7hu1wYYvYAjqJ0J/cmLDe UQgoZjPb5/RNMRv/6e8PHGv3hzro41BQHfbx/RndVD2XB7GRo04sYh6fK tpHpLxNHWHvUskJqhO23GItuTkGYflimreyRkgYm+KNieGnnWye4tIA+W c=; 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="59686160" 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: Veerasenareddy Burru Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Abhijit Ayarekar , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/26] octeon_ep: use array_size Date: Fri, 23 Jun 2023 23:14:33 +0200 Message-Id: <20230623211457.102544-3-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Simon Horman --- drivers/net/ethernet/marvell/octeon_ep/octep_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c b/drivers/ne= t/ethernet/marvell/octeon_ep/octep_rx.c index 392d9b0da0d7..185b7e50ee77 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c @@ -158,7 +158,7 @@ static int octep_setup_oq(struct octep_device *oct, int= q_no) goto desc_dma_alloc_err; } =20 - oq->buff_info =3D vzalloc(oq->max_count * OCTEP_OQ_RECVBUF_SIZE); + oq->buff_info =3D vzalloc(array_size(oq->max_count, OCTEP_OQ_RECVBUF_SIZE= )); if (unlikely(!oq->buff_info)) { dev_err(&oct->pdev->dev, "Failed to allocate buffer info for OQ-%d\n", q_no); From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEBFEC001DD for ; Fri, 23 Jun 2023 21:15:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232576AbjFWVPT (ORCPT ); Fri, 23 Jun 2023 17:15:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231802AbjFWVPO (ORCPT ); Fri, 23 Jun 2023 17:15:14 -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 54677E65; 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=P1v6BJpujkRR/XkZZ2TcSC10Ee0xBDh3V/U/H44vDYA=; b=bZVjS8wAqRR6iyNa9gnoxPEfrIs2w7LvzRNlQSyygW9EHkgELuwGdiCI Y4w81WWcTQErSQ9Y2Mw6GBxoIfzicPKsH4u6eQxEzmdmBcgWgeGnZciAb ArLbVrFlB+O8EJ8HQdjVyipEMZiXaQ6itAc4jEyAgyCT/aRqz/x7K2K5a 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="59686161" 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: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/26] drm/gud: use array_size Date: Fri, 23 Jun 2023 23:14:34 +0200 Message-Id: <20230623211457.102544-4-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/gpu/drm/gud/gud_pipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/gud_pipe.c index dc16a92625d4..34df847bd829 100644 --- a/drivers/gpu/drm/gud/gud_pipe.c +++ b/drivers/gpu/drm/gud/gud_pipe.c @@ -390,7 +390,7 @@ static int gud_fb_queue_damage(struct gud_device *gdrm,= struct drm_framebuffer * mutex_lock(&gdrm->damage_lock); =20 if (!gdrm->shadow_buf) { - gdrm->shadow_buf =3D vzalloc(fb->pitches[0] * fb->height); + gdrm->shadow_buf =3D vzalloc(array_size(fb->pitches[0], fb->height)); if (!gdrm->shadow_buf) { mutex_unlock(&gdrm->damage_lock); return -ENOMEM; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BE4DC001B0 for ; Fri, 23 Jun 2023 21:15:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231622AbjFWVPX (ORCPT ); Fri, 23 Jun 2023 17:15:23 -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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {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/etherne= t/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 =3D slots - 1; =20 /* alloc metadata */ - tx->info =3D vzalloc(sizeof(*tx->info) * slots); + tx->info =3D vzalloc(array_size(slots, sizeof(*tx->info))); if (!tx->info) return -ENOMEM; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFEB6EB64DD for ; Fri, 23 Jun 2023 21:20:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232927AbjFWVUP (ORCPT ); Fri, 23 Jun 2023 17:20:15 -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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Acked-by: Cheng Xu --- 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 =3D dev->func_bar + ERDMA_BAR_RQDB_SPACE_OFFSET; =20 - kqp->swr_tbl =3D vmalloc(qp->attrs.sq_size * sizeof(u64)); - kqp->rwr_tbl =3D vmalloc(qp->attrs.rq_size * sizeof(u64)); + kqp->swr_tbl =3D vmalloc(array_size(qp->attrs.sq_size, sizeof(u64))); + kqp->rwr_tbl =3D vmalloc(array_size(qp->attrs.rq_size, sizeof(u64))); if (!kqp->swr_tbl || !kqp->rwr_tbl) goto err_out; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37573C001B1 for ; Fri, 23 Jun 2023 21:15:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232011AbjFWVP0 (ORCPT ); Fri, 23 Jun 2023 17:15:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232276AbjFWVPQ (ORCPT ); Fri, 23 Jun 2023 17:15:16 -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 4215C10F2; Fri, 23 Jun 2023 14:15:15 -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=v1C6X9Yx4yVXOAdKb8gSIcJ1cJexwLFD0Mhp8hyTXpM=; b=ibGdS6fGsGhc/uttTGaoiJpbUVLv1dQE53RQlyqWPi8I8jYsjA4QPhsG 69vuLyA1lvbPNf9DFQ9xV+59969GQRIT64vAPf+BtV5VoJBI5MAp5KGAg 4j/AIfruYXqvPQ99dB1Q5fqTn+WPSuJXNvhdtCBICTm1jBC06qptZY2WA c=; 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="59686164" 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: Sumit Semwal Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Benjamin Gaignard , Liam Mark , Laura Abbott , Brian Starkey , John Stultz , =?UTF-8?q?Christian=20K=C3=B6nig?= , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/26] dma-buf: system_heap: use array_size Date: Fri, 23 Jun 2023 23:14:37 +0200 Message-Id: <20230623211457.102544-7-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) // Signed-off-by: Julia Lawall Acked-by: John Stultz --- drivers/dma-buf/heaps/system_heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/sy= stem_heap.c index ee7059399e9c..fb7867599874 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -221,7 +221,7 @@ static void *system_heap_do_vmap(struct system_heap_buf= fer *buffer) { struct sg_table *table =3D &buffer->sg_table; int npages =3D PAGE_ALIGN(buffer->len) / PAGE_SIZE; - struct page **pages =3D vmalloc(sizeof(struct page *) * npages); + struct page **pages =3D vmalloc(array_size(npages, sizeof(struct page *))= ); struct page **tmp =3D pages; struct sg_page_iter piter; void *vaddr; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FCABC00528 for ; Fri, 23 Jun 2023 21:15:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232849AbjFWVPa (ORCPT ); Fri, 23 Jun 2023 17:15:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232386AbjFWVPR (ORCPT ); Fri, 23 Jun 2023 17:15:17 -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 8F786E65; Fri, 23 Jun 2023 14:15:15 -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=QJydWjDhcLcynf/rTVoWViPI3W7kgehSdj6sywGYPic=; b=X2xeK3QMt9anv3maJ1FcmZls+/wbC9tReX04ZeglJ8Tk/S/H1TRdiR4A N+T7YWnS5GqgRHq27/dWmJRtK5fZ7cwk083jSAk70KAam3mJz1yph40Bk np73UEzsOMOdKfYhMSymqaeTbOBQD/p+RhfoGUUicKqk24X4ASAYRe3pU s=; 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="59686165" 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:11 +0200 From: Julia Lawall To: Satish Kharat Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Sesidhar Baddela , Karan Tilak Kumar , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/26] scsi: fnic: use array_size Date: Fri, 23 Jun 2023 23:14:38 +0200 Message-Id: <20230623211457.102544-8-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/scsi/fnic/fnic_trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c index f3c3a26a1384..74d428c9f7d3 100644 --- a/drivers/scsi/fnic/fnic_trace.c +++ b/drivers/scsi/fnic/fnic_trace.c @@ -465,7 +465,7 @@ int fnic_trace_buf_init(void) fnic_max_trace_entries =3D (trace_max_pages * PAGE_SIZE)/ FNIC_ENTRY_SIZE_BYTES; =20 - fnic_trace_buf_p =3D (unsigned long)vzalloc(trace_max_pages * PAGE_SIZE); + fnic_trace_buf_p =3D (unsigned long)vzalloc(array_size(trace_max_pages, P= AGE_SIZE)); if (!fnic_trace_buf_p) { printk(KERN_ERR PFX "Failed to allocate memory " "for fnic_trace_buf_p\n"); From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3B3AC001B0 for ; Fri, 23 Jun 2023 21:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232359AbjFWVPe (ORCPT ); Fri, 23 Jun 2023 17:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232392AbjFWVPR (ORCPT ); Fri, 23 Jun 2023 17:15:17 -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 40E57189; Fri, 23 Jun 2023 14:15:15 -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=8WWGDy69qrtzavSblwBRgHQbwXA80r1Q53C16BTDHPg=; b=Nf2/PyVP65m4zS14KRN+iZPPDLs/1MtgDOLaD5cMvJhgt0f/01EceRnR jgPoDPxYGosXJu/ZTArJNQFAaCz5QS5fBWEzE7SX5MXsWerfQlC0Ssb1x C5j6BWtq+9VXv9wmH8wzYLLYHbEQB/XuYhxgc+ye2WpqAzpvKugTAcvbM 8=; 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="59686166" 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:11 +0200 From: Julia Lawall To: David Hildenbrand Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/26] virtio-mem: use array_size Date: Fri, 23 Jun 2023 23:14:39 +0200 Message-Id: <20230623211457.102544-9-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Acked-by: Michael S. Tsirkin Reviewed-by: David Hildenbrand Reviewed-by: Xuan Zhuo --- drivers/virtio/virtio_mem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index 835f6cc2fb66..a4dfe7aab288 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -399,7 +399,7 @@ static int virtio_mem_bbm_bb_states_prepare_next_bb(str= uct virtio_mem *vm) if (vm->bbm.bb_states && old_pages =3D=3D new_pages) return 0; =20 - new_array =3D vzalloc(new_pages * PAGE_SIZE); + new_array =3D vzalloc(array_size(new_pages, PAGE_SIZE)); if (!new_array) return -ENOMEM; =20 @@ -465,7 +465,7 @@ static int virtio_mem_sbm_mb_states_prepare_next_mb(str= uct virtio_mem *vm) if (vm->sbm.mb_states && old_pages =3D=3D new_pages) return 0; =20 - new_array =3D vzalloc(new_pages * PAGE_SIZE); + new_array =3D vzalloc(array_size(new_pages, PAGE_SIZE)); if (!new_array) return -ENOMEM; =20 @@ -588,7 +588,7 @@ static int virtio_mem_sbm_sb_states_prepare_next_mb(str= uct virtio_mem *vm) if (vm->sbm.sb_states && old_pages =3D=3D new_pages) return 0; =20 - new_bitmap =3D vzalloc(new_pages * PAGE_SIZE); + new_bitmap =3D vzalloc(array_size(new_pages, PAGE_SIZE)); if (!new_bitmap) return -ENOMEM; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0764EC001B0 for ; Fri, 23 Jun 2023 21:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232841AbjFWVU6 (ORCPT ); Fri, 23 Jun 2023 17:20:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232609AbjFWVUi (ORCPT ); Fri, 23 Jun 2023 17:20:38 -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 30BAC2D46; Fri, 23 Jun 2023 14:19:22 -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=GCWo4PVrP3ZeFd8PIff442f3VLqG/AMKNMFkIT9T6cA=; b=K02CyeC0TxO7IAr7a3O+52eMgvms+F1/AvW0vYiFyEyImYoyQe3rBgJa TpAOj/W+1u1Yyv5zigBnWDQbMKc4dofND330WeFJkbKNYeeW9PRFvUD6F JG+WW/GS1N7xtJpu/yozutxXj7AYxLY+aNccGkg1oAWTQTtopCJ72nAgU 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="59686167" 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:11 +0200 From: Julia Lawall To: Shannon Nelson Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Brett Creeley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/26] pds_core: use array_size Date: Fri, 23 Jun 2023 23:14:40 +0200 Message-Id: <20230623211457.102544-10-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Acked-by: Shannon Nelson Reviewed-by: Simon Horman --- drivers/net/ethernet/amd/pds_core/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/etherne= t/amd/pds_core/core.c index 483a070d96fa..d87f45a1ee2f 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -196,7 +196,7 @@ int pdsc_qcq_alloc(struct pdsc *pdsc, unsigned int type= , unsigned int index, dma_addr_t q_base_pa; int err; =20 - qcq->q.info =3D vzalloc(num_descs * sizeof(*qcq->q.info)); + qcq->q.info =3D vzalloc(array_size(num_descs, sizeof(*qcq->q.info))); if (!qcq->q.info) { err =3D -ENOMEM; goto err_out; @@ -219,7 +219,7 @@ int pdsc_qcq_alloc(struct pdsc *pdsc, unsigned int type= , unsigned int index, if (err) goto err_out_free_q_info; =20 - qcq->cq.info =3D vzalloc(num_descs * sizeof(*qcq->cq.info)); + qcq->cq.info =3D vzalloc(array_size(num_descs, sizeof(*qcq->cq.info))); if (!qcq->cq.info) { err =3D -ENOMEM; goto err_out_free_irq; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3B61EB64D7 for ; Fri, 23 Jun 2023 21:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232224AbjFWVPl (ORCPT ); Fri, 23 Jun 2023 17:15:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232478AbjFWVPS (ORCPT ); Fri, 23 Jun 2023 17:15:18 -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 F37E110F2; Fri, 23 Jun 2023 14:15:16 -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=yyXUjWCAlWpegeeP3K+qGmg2LllPAIpv/xP8Xpl32WI=; b=WNpEcGRn571MPELqxpUAnUaAd+wthMvgWsZeSBlG9+nslQAvB0467vBy +dT+w0mrKtvGj6kEa2+EL8nuFIopX4jUrAeLrjGVqXV7Bg9MGGiQHyXqm KujHAwsBPr9y9YnvcAFACQLjPrzg424iTWmZSHchsQwA6ZG8Jt6C5nZ2g A=; 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="59686168" 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:11 +0200 From: Julia Lawall To: Manivannan Sadhasivam Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/26] bus: mhi: host: use array_size Date: Fri, 23 Jun 2023 23:14:41 +0200 Message-Id: <20230623211457.102544-11-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Jeffrey Hugo Tested-by: Jeffrey Hugo --- drivers/bus/mhi/host/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/bus/mhi/host/init.c b/drivers/bus/mhi/host/init.c index f72fcb66f408..34a543a67068 100644 --- a/drivers/bus/mhi/host/init.c +++ b/drivers/bus/mhi/host/init.c @@ -759,8 +759,8 @@ static int parse_ch_cfg(struct mhi_controller *mhi_cntr= l, * so to avoid any memory possible allocation failures, vzalloc is * used here */ - mhi_cntrl->mhi_chan =3D vzalloc(mhi_cntrl->max_chan * - sizeof(*mhi_cntrl->mhi_chan)); + mhi_cntrl->mhi_chan =3D vzalloc(array_size(mhi_cntrl->max_chan, + sizeof(*mhi_cntrl->mhi_chan))); if (!mhi_cntrl->mhi_chan) return -ENOMEM; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AFADEB64D7 for ; Fri, 23 Jun 2023 21:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232777AbjFWVPo (ORCPT ); Fri, 23 Jun 2023 17:15:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232596AbjFWVPT (ORCPT ); Fri, 23 Jun 2023 17:15:19 -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 AC44810F1; Fri, 23 Jun 2023 14:15:17 -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=/TRxy0AuF5FOCiYvvmf3tnTeoM1gUmxAEjlXeC+Ek4Q=; b=VcpH1Vz0lqQVGPsxzochEoOjLBSc7ukpvC0FInUkitVeye74rVXmkSmp 1zR87l1hIw+Bcv7BD6j6LRDjNKx1pb8Z8uiDSlyxpiroLgRzEW8mz11z+ x0vo0RpBsnP8Y82mxqlPr9vofLYNF8zqIvipC0saNwk8j8BrYh7KafGGo o=; 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="59686169" 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:12 +0200 From: Julia Lawall To: Shannon Nelson Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Brett Creeley , drivers@pensando.io, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/26] ionic: use array_size Date: Fri, 23 Jun 2023 23:14:42 +0200 Message-Id: <20230623211457.102544-12-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Acked-by: Shannon Nelson Reviewed-by: Simon Horman --- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/= ethernet/pensando/ionic/ionic_lif.c index 957027e546b3..f2e2c6853536 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -560,7 +560,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsig= ned int type, new->q.dev =3D dev; new->flags =3D flags; =20 - new->q.info =3D vzalloc(num_descs * sizeof(*new->q.info)); + new->q.info =3D vzalloc(array_size(num_descs, sizeof(*new->q.info))); if (!new->q.info) { netdev_err(lif->netdev, "Cannot allocate queue info\n"); err =3D -ENOMEM; @@ -581,7 +581,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsig= ned int type, if (err) goto err_out; =20 - new->cq.info =3D vzalloc(num_descs * sizeof(*new->cq.info)); + new->cq.info =3D vzalloc(array_size(num_descs, sizeof(*new->cq.info))); if (!new->cq.info) { netdev_err(lif->netdev, "Cannot allocate completion queue info\n"); err =3D -ENOMEM; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 240CDC001B0 for ; Fri, 23 Jun 2023 21:15:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232507AbjFWVPt (ORCPT ); Fri, 23 Jun 2023 17:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232606AbjFWVPT (ORCPT ); Fri, 23 Jun 2023 17:15:19 -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 F38DC189; Fri, 23 Jun 2023 14:15:17 -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=x3yaNVdlz5Bh0UGifQdHJbRNelT3AqwxtCVAxF/u48k=; b=sNuULnbON7T/smAo1vy+hUeK7qzpB4L0U0WEzRGcLRjj35A0uv04T47r HhaE8Acqn6AyPeJcGYBY//20g98EBYjzxgvucmJdaMVYNEBf++OQ6gIGw sFqzU/KewLXJwN6gKkHVTf9uMYUZ0FSGbX1pUYVobDoMR7mMYrrbSVaKA 8=; 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="59686170" 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:12 +0200 From: Julia Lawall To: Chris Mason Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/26] btrfs: zoned: use array_size Date: Fri, 23 Jun 2023 23:14:43 +0200 Message-Id: <20230623211457.102544-13-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {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: Johannes Thumshirn Reviewed-by: Naohiro Aota --- fs/btrfs/zoned.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c index 39828af4a4e8..0550ce98dcae 100644 --- a/fs/btrfs/zoned.c +++ b/fs/btrfs/zoned.c @@ -464,8 +464,9 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device= , bool populate_cache) * use the cache. */ if (populate_cache && bdev_is_zoned(device->bdev)) { - zone_info->zone_cache =3D vzalloc(sizeof(struct blk_zone) * - zone_info->nr_zones); + zone_info->zone_cache =3D + vzalloc(array_size(zone_info->nr_zones, + sizeof(struct blk_zone))); if (!zone_info->zone_cache) { btrfs_err_in_rcu(device->fs_info, "zoned: failed to allocate zone cache for %s", From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32A58EB64DD for ; Fri, 23 Jun 2023 21:15:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232223AbjFWVPx (ORCPT ); Fri, 23 Jun 2023 17:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232483AbjFWVPV (ORCPT ); Fri, 23 Jun 2023 17:15:21 -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 9C8FD1997; Fri, 23 Jun 2023 14:15:18 -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=1HkDEW7AxSHLZvHADInYpWBN1+Bsf50V6Er9x8KFaJk=; b=BfrIEUyQFLrGM984hWuTDVJ9BMp+YgtR3JEATuk5EkoZBafGGqyDRXjy GAn3Um4ZVQx9UGrkJUHaG/3M/yr6kZYJ19tAksbvEPhtIVa8nQg5SsDSO jtf7phSjQezrORoUWJ63Ez5TVQ12NuIb2JdR80iGNsvJm0dJOPwU7L6oG U=; 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="59686171" 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:12 +0200 From: Julia Lawall To: Thierry Reding Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Krishna Reddy , Joerg Roedel , Will Deacon , Robin Murphy , Jonathan Hunter , linux-tegra@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 13/26] iommu/tegra: gart: use array_size Date: Fri, 23 Jun 2023 23:14:44 +0200 Message-Id: <20230623211457.102544-14-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/iommu/tegra-gart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index a482ff838b53..def222da83f1 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -348,8 +348,8 @@ struct gart_device *tegra_gart_probe(struct device *dev= , struct tegra_mc *mc) if (err) goto remove_sysfs; =20 - gart->savedata =3D vmalloc(resource_size(res) / GART_PAGE_SIZE * - sizeof(u32)); + gart->savedata =3D vmalloc(array_size(resource_size(res) / GART_PAGE_SIZE, + sizeof(u32))); if (!gart->savedata) { err =3D -ENOMEM; goto unregister_iommu; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1FAFEB64D7 for ; Fri, 23 Jun 2023 21:15:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232852AbjFWVP4 (ORCPT ); Fri, 23 Jun 2023 17:15:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232763AbjFWVPV (ORCPT ); Fri, 23 Jun 2023 17:15:21 -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 1FA112130; Fri, 23 Jun 2023 14:15:18 -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=BOvAIPV5b2s9XXgIiUCDYijQMWfGXsngYuXLkntqOho=; b=oBORICMjMDk+FYpoVEcjGxoLDyziR5NvwJoDKLiolbwFfa3Z4eFHZSHL 3pG0TVOrluOqz7J/IM5bq1h1zIS7MSBXvaH4CZLEPk5H/3YJyn9/lUOID kTMHVnE51EZb+5cjH5miFKu9o0CoNvS2Z/vQfu4QQczhF8KbVHXdbHf5t w=; 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="59686172" 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:12 +0200 From: Julia Lawall To: Bernard Metzler Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/26] RDMA/siw: use array_size Date: Fri, 23 Jun 2023 23:14:45 +0200 Message-Id: <20230623211457.102544-15-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Bernard Metzler --- drivers/infiniband/sw/siw/siw_qp.c | 4 ++-- drivers/infiniband/sw/siw/siw_verbs.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/sw/siw/siw_qp.c b/drivers/infiniband/sw/siw= /siw_qp.c index 81e9bbd9ebda..32ec85af0314 100644 --- a/drivers/infiniband/sw/siw/siw_qp.c +++ b/drivers/infiniband/sw/siw/siw_qp.c @@ -204,7 +204,7 @@ static int siw_qp_readq_init(struct siw_qp *qp, int irq= _size, int orq_size) { if (irq_size) { irq_size =3D roundup_pow_of_two(irq_size); - qp->irq =3D vzalloc(irq_size * sizeof(struct siw_sqe)); + qp->irq =3D vzalloc(array_size(irq_size, sizeof(struct siw_sqe))); if (!qp->irq) { qp->attrs.irq_size =3D 0; return -ENOMEM; @@ -212,7 +212,7 @@ static int siw_qp_readq_init(struct siw_qp *qp, int irq= _size, int orq_size) } if (orq_size) { orq_size =3D roundup_pow_of_two(orq_size); - qp->orq =3D vzalloc(orq_size * sizeof(struct siw_sqe)); + qp->orq =3D vzalloc(array_size(orq_size, sizeof(struct siw_sqe))); if (!qp->orq) { qp->attrs.orq_size =3D 0; qp->attrs.irq_size =3D 0; diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/= siw/siw_verbs.c index 398ec13db624..ddf83b638cb0 100644 --- a/drivers/infiniband/sw/siw/siw_verbs.c +++ b/drivers/infiniband/sw/siw/siw_verbs.c @@ -381,7 +381,7 @@ int siw_create_qp(struct ib_qp *ibqp, struct ib_qp_init= _attr *attrs, if (udata) qp->sendq =3D vmalloc_user(num_sqe * sizeof(struct siw_sqe)); else - qp->sendq =3D vzalloc(num_sqe * sizeof(struct siw_sqe)); + qp->sendq =3D vzalloc(array_size(num_sqe, sizeof(struct siw_sqe))); =20 if (qp->sendq =3D=3D NULL) { rv =3D -ENOMEM; @@ -414,7 +414,7 @@ int siw_create_qp(struct ib_qp *ibqp, struct ib_qp_init= _attr *attrs, qp->recvq =3D vmalloc_user(num_rqe * sizeof(struct siw_rqe)); else - qp->recvq =3D vzalloc(num_rqe * sizeof(struct siw_rqe)); + qp->recvq =3D vzalloc(array_size(num_rqe, sizeof(struct siw_rqe))); =20 if (qp->recvq =3D=3D NULL) { rv =3D -ENOMEM; @@ -1624,7 +1624,7 @@ int siw_create_srq(struct ib_srq *base_srq, srq->recvq =3D vmalloc_user(srq->num_rqe * sizeof(struct siw_rqe)); else - srq->recvq =3D vzalloc(srq->num_rqe * sizeof(struct siw_rqe)); + srq->recvq =3D vzalloc(array_size(srq->num_rqe, sizeof(struct siw_rqe))); =20 if (srq->recvq =3D=3D NULL) { rv =3D -ENOMEM; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 363A8C001B1 for ; Fri, 23 Jun 2023 21:16:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232679AbjFWVP7 (ORCPT ); Fri, 23 Jun 2023 17:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232827AbjFWVPX (ORCPT ); Fri, 23 Jun 2023 17:15:23 -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 D342D1993; Fri, 23 Jun 2023 14:15:19 -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=42OKv4WqZGQxlnFHmnIuYt+rtnNJuJHuQ6K07YbNUj8=; b=GXBNYgmL2uYfs6qFigazu5bHqzJHBpCz8l880MNXwd+9eRslqwZ3OOsI Mg6LYxvrebz27/FhrAyaK87WAa+UpTYqEiIKSJflTdI9YiVVutKzyTKHQ OMrvn1ry8QKjC8losr/ymVYFeWIWjK52PpQAd1FD2UAhzi/Qrd3wzTeZP s=; 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="59686173" 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:12 +0200 From: Julia Lawall To: Oded Gabbay Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/26] habanalabs: use array_size Date: Fri, 23 Jun 2023 23:14:46 +0200 Message-Id: <20230623211457.102544-16-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/accel/habanalabs/common/device.c | 3 ++- drivers/accel/habanalabs/common/state_dump.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/accel/habanalabs/common/device.c b/drivers/accel/haban= alabs/common/device.c index fabfc501ef54..8e2edefa6d3c 100644 --- a/drivers/accel/habanalabs/common/device.c +++ b/drivers/accel/habanalabs/common/device.c @@ -2572,7 +2572,8 @@ static void hl_capture_user_mappings(struct hl_device= *hdev, bool is_pmmu) */ vfree(pgf_info->user_mappings); pgf_info->user_mappings =3D - vzalloc(pgf_info->num_of_user_mappings * sizeof(struct hl_user_mapping)= ); + vzalloc(array_size(pgf_info->num_of_user_mappings, + sizeof(struct hl_user_mapping))); if (!pgf_info->user_mappings) { pgf_info->num_of_user_mappings =3D 0; goto finish; diff --git a/drivers/accel/habanalabs/common/state_dump.c b/drivers/accel/h= abanalabs/common/state_dump.c index 3a9931f24259..324cb7c9bc26 100644 --- a/drivers/accel/habanalabs/common/state_dump.c +++ b/drivers/accel/habanalabs/common/state_dump.c @@ -272,7 +272,7 @@ static u32 *hl_state_dump_read_sync_objects(struct hl_d= evice *hdev, u32 index) base_addr =3D sds->props[SP_SYNC_OBJ_BASE_ADDR] + sds->props[SP_NEXT_SYNC_OBJ_ADDR] * index; =20 - sync_objects =3D vmalloc(sds->props[SP_SYNC_OBJ_AMOUNT] * sizeof(u32)); + sync_objects =3D vmalloc(array_size(sds->props[SP_SYNC_OBJ_AMOUNT], sizeo= f(u32))); if (!sync_objects) return NULL; =20 @@ -453,8 +453,8 @@ hl_state_dump_alloc_read_sm_block_monitors(struct hl_de= vice *hdev, u32 index) s64 base_addr; /* Base addr can be negative */ int i; =20 - monitors =3D vmalloc(sds->props[SP_MONITORS_AMOUNT] * - sizeof(struct hl_mon_state_dump)); + monitors =3D vmalloc(array_size(sds->props[SP_MONITORS_AMOUNT], + sizeof(struct hl_mon_state_dump))); if (!monitors) return NULL; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87013C001B0 for ; Fri, 23 Jun 2023 21:16:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232762AbjFWVQE (ORCPT ); Fri, 23 Jun 2023 17:16:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232831AbjFWVPX (ORCPT ); Fri, 23 Jun 2023 17:15:23 -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 5ABAA10F1; Fri, 23 Jun 2023 14:15:19 -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=NBw5vlMSYDphuKB5VO9qUzXDvK0V7Xr95Q+k+nN/f84=; b=N3bMVT0Y+Wz5gL7ugjMaEKH0XK9iI00oy1rtPtin0vJJydKmTLv4sWIx f9+bOpvwsiKisFRe7CqTYof5bkdOr2VD7KZRPHvQT9tp4F5J5wmAQjGXP YzxOr1bylniwAlzHURkE8ebQwCSCW0fHOuPTsil5W0sJvnvzY6uhkWbNo 8=; 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="59686174" 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:12 +0200 From: Julia Lawall To: Zhenyu Wang Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/26] drm/i915/gvt: use array_size Date: Fri, 23 Jun 2023 23:14:47 +0200 Message-Id: <20230623211457.102544-17-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/gpu/drm/i915/gvt/gtt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c index 4ec85308379a..df52385ad436 100644 --- a/drivers/gpu/drm/i915/gvt/gtt.c +++ b/drivers/gpu/drm/i915/gvt/gtt.c @@ -1969,14 +1969,16 @@ static struct intel_vgpu_mm *intel_vgpu_create_ggtt= _mm(struct intel_vgpu *vgpu) return ERR_PTR(-ENOMEM); } =20 - mm->ggtt_mm.host_ggtt_aperture =3D vzalloc((vgpu_aperture_sz(vgpu) >> PAG= E_SHIFT) * sizeof(u64)); + mm->ggtt_mm.host_ggtt_aperture =3D + vzalloc(array_size(vgpu_aperture_sz(vgpu) >> PAGE_SHIFT, sizeof(u64))); if (!mm->ggtt_mm.host_ggtt_aperture) { vfree(mm->ggtt_mm.virtual_ggtt); vgpu_free_mm(mm); return ERR_PTR(-ENOMEM); } =20 - mm->ggtt_mm.host_ggtt_hidden =3D vzalloc((vgpu_hidden_sz(vgpu) >> PAGE_SH= IFT) * sizeof(u64)); + mm->ggtt_mm.host_ggtt_hidden =3D + vzalloc(array_size(vgpu_hidden_sz(vgpu) >> PAGE_SHIFT, sizeof(u64))); if (!mm->ggtt_mm.host_ggtt_hidden) { vfree(mm->ggtt_mm.host_ggtt_aperture); vfree(mm->ggtt_mm.virtual_ggtt); From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31B5DC001DC for ; Fri, 23 Jun 2023 21:16:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232591AbjFWVQH (ORCPT ); Fri, 23 Jun 2023 17:16:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232467AbjFWVP1 (ORCPT ); Fri, 23 Jun 2023 17:15:27 -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 A057C26AD; Fri, 23 Jun 2023 14:15:21 -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=wXbBUetUKejFi8ORS1ZEmLv+CVaFu9wgVarZrNCtRDg=; b=A7nI+7mmDYp4vn5z4kkLYBXiMxlrr33ougwoXx0f4+puZtMgzRMI38Cb iwPdflk66xXykD0tAUNTI14pS1/ojBvGdSuUXOF+87mtq7Va3p4CiAj1a Zg852BgxRKmageLq3un5UOCo4MRAXYuHL7ivNSsfcJV+Wg2Ts3E50849p U=; 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="59686175" 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:13 +0200 From: Julia Lawall To: Dmitry Vyukov Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Andrey Konovalov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: [PATCH 17/26] kcov: use array_size Date: Fri, 23 Jun 2023 23:14:48 +0200 Message-Id: <20230623211457.102544-18-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Dmitry Vyukov --- kernel/kcov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kcov.c b/kernel/kcov.c index 84c717337df0..631444760644 100644 --- a/kernel/kcov.c +++ b/kernel/kcov.c @@ -900,7 +900,7 @@ void kcov_remote_start(u64 handle) /* Can only happen when in_task(). */ if (!area) { local_unlock_irqrestore(&kcov_percpu_data.lock, flags); - area =3D vmalloc(size * sizeof(unsigned long)); + area =3D vmalloc(array_size(size, sizeof(unsigned long))); if (!area) { kcov_put(kcov); return; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6B7AEB64D7 for ; Fri, 23 Jun 2023 21:16:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231896AbjFWVQN (ORCPT ); Fri, 23 Jun 2023 17:16:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232856AbjFWVPc (ORCPT ); Fri, 23 Jun 2023 17:15:32 -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 E048726B9; Fri, 23 Jun 2023 14:15:21 -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=1b2qOiijM2SOFY49y/T4nNKOOzZTttGdtrLG5Lh64bI=; b=uyu8z8wzWEtEgebrWGzG9i5oWEcHT9BaIjP0Cs8YqJ4Dnb9025dIo99d UntoRq5hk/R+vCjtxjxaQzUluEwwNY91uXDdnCSwbykFbM7jOIMaPWqbb mmDU8w2Ro+9cTiPSvq7ACpxLUR8sUeZ+2YhiHhuPAojA3G8yl102Og3hU A=; 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="59686176" 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:13 +0200 From: Julia Lawall To: Claudiu Manoil Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/26] net: enetc: use array_size Date: Fri, 23 Jun 2023 23:14:49 +0200 Message-Id: <20230623211457.102544-19-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Simon Horman --- drivers/net/ethernet/freescale/enetc/enetc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/eth= ernet/freescale/enetc/enetc.c index 9e1b2536e9a9..7231f8ea1ba4 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1790,7 +1790,7 @@ static int enetc_alloc_tx_resource(struct enetc_bdr_r= esource *res, res->bd_count =3D bd_count; res->bd_size =3D sizeof(union enetc_tx_bd); =20 - res->tx_swbd =3D vzalloc(bd_count * sizeof(*res->tx_swbd)); + res->tx_swbd =3D vzalloc(array_size(bd_count, sizeof(*res->tx_swbd))); if (!res->tx_swbd) return -ENOMEM; =20 @@ -1878,7 +1878,7 @@ static int enetc_alloc_rx_resource(struct enetc_bdr_r= esource *res, if (extended) res->bd_size *=3D 2; =20 - res->rx_swbd =3D vzalloc(bd_count * sizeof(struct enetc_rx_swbd)); + res->rx_swbd =3D vzalloc(array_size(bd_count, sizeof(struct enetc_rx_swbd= ))); if (!res->rx_swbd) return -ENOMEM; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4021BEB64DD for ; Fri, 23 Jun 2023 21:16:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232920AbjFWVQU (ORCPT ); Fri, 23 Jun 2023 17:16:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232866AbjFWVPd (ORCPT ); Fri, 23 Jun 2023 17:15:33 -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 A1F8626BD; Fri, 23 Jun 2023 14:15:21 -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=8RgN37sI7dQZ+yBNJgvV+FVERbz2KA6A4JGbVoPo1D8=; b=ZLSOgmbfYoFK1LfswZnkAko5w1qaeuRTBPVtfsuJhYufYAShfc08lrY5 GfmwSRRDmk+b4IYZGmpWxgs4LgkYSVKQuaZq7LE+mHoJVN5ZQicrxpb1d qwR/n8FqYT1ATKyZe3Ay1Bz27c81Fou59W2Zj2TESMWOmR77CEA5urk0P s=; 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="59686177" 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:13 +0200 From: Julia Lawall To: Selvin Xavier Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/26] RDMA/bnxt_re: use array_size Date: Fri, 23 Jun 2023 23:14:50 +0200 Message-Id: <20230623211457.102544-20-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/infiniband/hw/bnxt_re/qplib_res.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.c b/drivers/infiniband= /hw/bnxt_re/qplib_res.c index 81b0c5e879f9..f049b627e734 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_res.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c @@ -118,11 +118,11 @@ static int __alloc_pbl(struct bnxt_qplib_res *res, else pages =3D sginfo->npages; /* page ptr arrays */ - pbl->pg_arr =3D vmalloc(pages * sizeof(void *)); + pbl->pg_arr =3D vmalloc(array_size(pages, sizeof(void *))); if (!pbl->pg_arr) return -ENOMEM; =20 - pbl->pg_map_arr =3D vmalloc(pages * sizeof(dma_addr_t)); + pbl->pg_map_arr =3D vmalloc(array_size(pages, sizeof(dma_addr_t))); if (!pbl->pg_map_arr) { vfree(pbl->pg_arr); pbl->pg_arr =3D NULL; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE1E9EB64D7 for ; Fri, 23 Jun 2023 21:16:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231675AbjFWVQZ (ORCPT ); Fri, 23 Jun 2023 17:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232870AbjFWVPd (ORCPT ); Fri, 23 Jun 2023 17:15:33 -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 379B2270A; Fri, 23 Jun 2023 14:15:22 -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=jammjAxbCgbnRHLqhi6UIftAryvqKnOHjwdJrbKzjag=; b=Z47OQtnPiaEB5oaBB+oz82Qsg6BtHw8YihUVIhQDCMR+I0tQpbbrpJXq nj5C0YQSxjWsFlY9SUmJShUU8xGXEqdHAlNbU+0vzr8txprHO2a1l78O0 vJXXUrP7E3H3oTBJf1CDCM1QC0nZjMpj3m7aYP6mcSPVWR15IxWF2hFkG o=; 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="59686178" 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:13 +0200 From: Julia Lawall To: Zack Rusin Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, VMware Graphics Reviewers , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 20/26] drm/vmwgfx: use array_size Date: Fri, 23 Jun 2023 23:14:51 +0200 Message-Id: <20230623211457.102544-21-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) // Signed-off-by: Julia Lawall --- drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c b/drivers/gpu/drm/vmwg= fx/vmwgfx_devcaps.c index 829df395c2ed..c72fc8111a11 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_devcaps.c @@ -88,7 +88,7 @@ int vmw_devcaps_create(struct vmw_private *vmw) uint32_t i; =20 if (gb_objects) { - vmw->devcaps =3D vzalloc(sizeof(uint32_t) * SVGA3D_DEVCAP_MAX); + vmw->devcaps =3D vzalloc(array_size(SVGA3D_DEVCAP_MAX, sizeof(uint32_t))= ); if (!vmw->devcaps) return -ENOMEM; for (i =3D 0; i < SVGA3D_DEVCAP_MAX; ++i) { From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03ABDC001B0 for ; Fri, 23 Jun 2023 21:16:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232466AbjFWVQ1 (ORCPT ); Fri, 23 Jun 2023 17:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232775AbjFWVPo (ORCPT ); Fri, 23 Jun 2023 17:15:44 -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 34EAD2728; Fri, 23 Jun 2023 14:15:23 -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=qV5G73GxtezcE7jW6SYetBuixStXGKiX50k7hlLQiPI=; b=D51bNxx3+NCOjAzU8GhU1cIyLUhkDHrYSC94pyiQyblzcGfm6MHi5CUK TvZc5kxyOIspVbl2ClJqlsUb8ZKRt14bc0NfiU4O9w/U7pvI5eLxNyOWn 22WDtlFdhPqTCvxDq0AwaJhrNmHKRupFifZlpHJ6E4mIZJz7yDpQt9k6Z 8=; 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="59686179" 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:14 +0200 From: Julia Lawall To: Jarkko Sakkinen Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/26] x86/sgx: use array_size Date: Fri, 23 Jun 2023 23:14:52 +0200 Message-Id: <20230623211457.102544-22-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Jarkko Sakkinen --- arch/x86/kernel/cpu/sgx/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c index 166692f2d501..3a234942c586 100644 --- a/arch/x86/kernel/cpu/sgx/main.c +++ b/arch/x86/kernel/cpu/sgx/main.c @@ -628,7 +628,8 @@ static bool __init sgx_setup_epc_section(u64 phys_addr,= u64 size, if (!section->virt_addr) return false; =20 - section->pages =3D vmalloc(nr_pages * sizeof(struct sgx_epc_page)); + section->pages =3D vmalloc(array_size(nr_pages, + sizeof(struct sgx_epc_page))); if (!section->pages) { memunmap(section->virt_addr); return false; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E03DAEB64D7 for ; Fri, 23 Jun 2023 21:16:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232947AbjFWVQb (ORCPT ); Fri, 23 Jun 2023 17:16:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232884AbjFWVP5 (ORCPT ); Fri, 23 Jun 2023 17:15:57 -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 3D93C2944; Fri, 23 Jun 2023 14:15:25 -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=6pln8KBe2ITtf0Rjafl/GtS76k6Cn8LbOnTYdoKfe3I=; b=pKNmqBiygwlNLCzGuSQt/yjs2FsRFeqJtZEf1QiTQmJSp4Fke68U0eM6 MjqGe7c1XWHvQYZR8PMOxPokjRn3KFG8EMkHO6Z9TDu+gTL1yvuoFUJVx XTtGe+P9TO7DPba/l6tlQHgJsnQdFj/RZ2EOMJ4okLFBWw40Mu0eNC8LI 8=; 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="59686180" 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:14 +0200 From: Julia Lawall To: "K. Y. Srinivasan" Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Haiyang Zhang , Wei Liu , Dexuan Cui , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 22/26] net: mana: use array_size Date: Fri, 23 Jun 2023 23:14:53 +0200 Message-Id: <20230623211457.102544-23-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Simon Horman --- drivers/net/ethernet/microsoft/mana/hw_channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net= /ethernet/microsoft/mana/hw_channel.c index 9d1507eba5b9..e82c513760f9 100644 --- a/drivers/net/ethernet/microsoft/mana/hw_channel.c +++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c @@ -627,7 +627,7 @@ static int mana_hwc_establish_channel(struct gdma_conte= xt *gc, u16 *q_depth, if (WARN_ON(cq->id >=3D gc->max_num_cqs)) return -EPROTO; =20 - gc->cq_table =3D vzalloc(gc->max_num_cqs * sizeof(struct gdma_queue *)); + gc->cq_table =3D vzalloc(array_size(gc->max_num_cqs, sizeof(struct gdma_q= ueue *))); if (!gc->cq_table) return -ENOMEM; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D9A7C001B1 for ; Fri, 23 Jun 2023 21:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232904AbjFWVQm (ORCPT ); Fri, 23 Jun 2023 17:16:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232895AbjFWVQA (ORCPT ); Fri, 23 Jun 2023 17:16:00 -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 ED00B295E; Fri, 23 Jun 2023 14:15:28 -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=W1WB9Wb0BvRRcBkbSVITYF4i4Xscr+EN0kvgwOJ6wOs=; b=WmG/JpBrM0La8Q7SPsscDO+9vwp6o00kURhYuE4MeUme0ls/EvAKTJhY mp+BcN1WhFW8+h7eRAujDv59DBrIbAx6oxgu581730TSsqjI0R/hG8vwc R2wBhiJozXLBTfyUjGNSc07qmFKw/jr6X7BSNFOgHP2+n6nDAix+z1p0U Q=; 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="59686181" 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:14 +0200 From: Julia Lawall To: Sakari Ailus Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Bingbu Cao , Tianshu Qiu , Mauro Carvalho Chehab , Greg Kroah-Hartman , linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 23/26] media: staging: imgu: use array_size Date: Fri, 23 Jun 2023 23:14:54 +0200 Message-Id: <20230623211457.102544-24-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Bingbu Cao --- drivers/staging/media/ipu3/ipu3-mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/ipu3/ipu3-mmu.c b/drivers/staging/media/= ipu3/ipu3-mmu.c index cb9bf5fb29a5..9c4adb815c94 100644 --- a/drivers/staging/media/ipu3/ipu3-mmu.c +++ b/drivers/staging/media/ipu3/ipu3-mmu.c @@ -464,7 +464,7 @@ struct imgu_mmu_info *imgu_mmu_init(struct device *pare= nt, void __iomem *base) * Allocate the array of L2PT CPU pointers, initialized to zero, * which means the dummy L2PT allocated above. */ - mmu->l2pts =3D vzalloc(IPU3_PT_PTES * sizeof(*mmu->l2pts)); + mmu->l2pts =3D vzalloc(array_size(IPU3_PT_PTES, sizeof(*mmu->l2pts))); if (!mmu->l2pts) goto fail_l2pt; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01FFFEB64D7 for ; Fri, 23 Jun 2023 21:16:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232544AbjFWVQq (ORCPT ); Fri, 23 Jun 2023 17:16:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232865AbjFWVQC (ORCPT ); Fri, 23 Jun 2023 17:16:02 -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 4BAD82964; Fri, 23 Jun 2023 14:15:29 -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=CxJuiiXcSlU+s+aK2RdCGaJm2rWe7fLo/P4JyxZmwgU=; b=Y+TGJl9kktgLU2LOFT6pAr8H9vMhgFCXSpYoMx6YRcy0WlnrnJFEBdQe GjewKrO0T9ledIQTGIKjVzV4zVvZ85studPlRFdE6P9wCS23upj1v7+Ez 6dB3jhHWtVRstUrvr+YIJkmjkuomBWQXMGTWDsJr1kV7DBR7dSXEYFL31 Y=; 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="59686185" 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:14 +0200 From: Julia Lawall To: Nilesh Javali Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 24/26] scsi: qla2xxx: use array_size Date: Fri, 23 Jun 2023 23:14:55 +0200 Message-Id: <20230623211457.102544-25-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/scsi/qla2xxx/qla_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_ini= t.c index 1a955c3ff3d6..72569ed6c825 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -8219,7 +8219,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_= t *srisc_addr, ql_dbg(ql_dbg_init, vha, 0x0163, "-> fwdt%u template allocate template %#x words...\n", j, risc_size); - fwdt->template =3D vmalloc(risc_size * sizeof(*dcode)); + fwdt->template =3D vmalloc(array_size(risc_size, sizeof(*dcode))); if (!fwdt->template) { ql_log(ql_log_warn, vha, 0x0164, "-> fwdt%u failed allocate template.\n", j); @@ -8474,7 +8474,7 @@ qla24xx_load_risc_blob(scsi_qla_host_t *vha, uint32_t= *srisc_addr) ql_dbg(ql_dbg_init, vha, 0x0173, "-> fwdt%u template allocate template %#x words...\n", j, risc_size); - fwdt->template =3D vmalloc(risc_size * sizeof(*dcode)); + fwdt->template =3D vmalloc(array_size(risc_size, sizeof(*dcode))); if (!fwdt->template) { ql_log(ql_log_warn, vha, 0x0174, "-> fwdt%u failed allocate template.\n", j); From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 738C4C001B0 for ; Fri, 23 Jun 2023 21:16:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232918AbjFWVQt (ORCPT ); Fri, 23 Jun 2023 17:16:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232906AbjFWVQD (ORCPT ); Fri, 23 Jun 2023 17:16:03 -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 1FA682D5E; Fri, 23 Jun 2023 14:15:30 -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=QVL85YxfC9lZXDIeZBFhc354vgfWwHTzh6yW0KOYvK4=; b=obHoEbEAs4Vxarjwie+EudxVXCEWB7n46ogAeNxZlsEWVoPQcxhx87vy b7lBQ22cD+VaMR23Nr7nQhnTC89WV184JirgVc3PcqN9bz2XA4WUXm5aW WjUCZtT+syctXB+oE0Kfp1AGf0HqfpKHdjFpSt0B28IJckRav0i1qufKi 8=; 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="59686189" 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:15 +0200 From: Julia Lawall To: "Michael S. Tsirkin" Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Jason Wang , Xuan Zhuo , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 25/26] vduse: use array_size Date: Fri, 23 Jun 2023 23:14:56 +0200 Message-Id: <20230623211457.102544-26-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc}; @@ =20 ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/vdpa/vdpa_user/iova_domain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/vdpa/vdpa_user/iova_domain.c b/drivers/vdpa/vdpa_user/= iova_domain.c index 5e4a77b9bae6..ee395e013086 100644 --- a/drivers/vdpa/vdpa_user/iova_domain.c +++ b/drivers/vdpa/vdpa_user/iova_domain.c @@ -571,8 +571,9 @@ vduse_domain_create(unsigned long iova_limit, size_t bo= unce_size) =20 domain->iova_limit =3D iova_limit; domain->bounce_size =3D PAGE_ALIGN(bounce_size); - domain->bounce_maps =3D vzalloc(bounce_pfns * - sizeof(struct vduse_bounce_map)); + domain->bounce_maps =3D + vzalloc(array_size(bounce_pfns, + sizeof(struct vduse_bounce_map))); if (!domain->bounce_maps) goto err_map; From nobody Mon Feb 9 03:31:02 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5BEFC001B0 for ; Fri, 23 Jun 2023 21:17:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232868AbjFWVRE (ORCPT ); Fri, 23 Jun 2023 17:17:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232885AbjFWVQk (ORCPT ); Fri, 23 Jun 2023 17:16:40 -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 3D0FB30DE; Fri, 23 Jun 2023 14:15:37 -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=zjTOkHzHNJN2JwbbSn0B3jYr0f7hFN0oZZoh6lbquOQ=; b=FPVhggARCWGLgx/uc1XplQBbZp4QfJ3ScSLfue5dgqmPlrnQ4BiqzZpN IQ21XgRjNNOHEfdPKTVuJdURuqERB5NCaGfeDpyZ+YpyMYSfpq+KUPiuU +vQ3rGawBQbmwNRu052NXLgEaJzd/RusbfLOqx+1C3Tv2tUHQBsR4S4Tk g=; 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="59686190" 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:15 +0200 From: Julia Lawall To: Ian Abbott Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, H Hartley Sweeten , linux-kernel@vger.kernel.org Subject: [PATCH 26/26] comedi: use array_size Date: Fri, 23 Jun 2023 23:14:57 +0200 Message-Id: <20230623211457.102544-27-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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) // Signed-off-by: Julia Lawall --- drivers/comedi/comedi_buf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/comedi/comedi_buf.c b/drivers/comedi/comedi_buf.c index 393966c09740..32ad3e6e1ce8 100644 --- a/drivers/comedi/comedi_buf.c +++ b/drivers/comedi/comedi_buf.c @@ -89,7 +89,7 @@ comedi_buf_map_alloc(struct comedi_device *dev, enum dma_= data_direction dma_dir, bm->dma_hw_dev =3D get_device(dev->hw_dev); } =20 - bm->page_list =3D vzalloc(sizeof(*buf) * n_pages); + bm->page_list =3D vzalloc(array_size(n_pages, sizeof(*buf))); if (!bm->page_list) goto err; =20 @@ -169,7 +169,7 @@ static void __comedi_buf_alloc(struct comedi_device *de= v, buf =3D &bm->page_list[0]; async->prealloc_buf =3D buf->virt_addr; } else { - pages =3D vmalloc(sizeof(struct page *) * n_pages); + pages =3D vmalloc(array_size(n_pages, sizeof(struct page *))); if (!pages) return;