From patchwork Fri Jun 23 21:14:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112317 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6048661vqr; Fri, 23 Jun 2023 14:24:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4B7VnMs51OzG3w0YHHbaH/cHuG702Ve4F5IEM5v5y9OxPAZLP3fAa43xF01KcjzxqlkzQJ X-Received: by 2002:a05:6359:6398:b0:132:7a28:e13a with SMTP id sg24-20020a056359639800b001327a28e13amr7067849rwb.17.1687555480846; Fri, 23 Jun 2023 14:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555480; cv=none; d=google.com; s=arc-20160816; b=V5utMzZqgHbBYhxjxtxE4hYPemWWxZQ2XC5j3BM5rPyWqeVN4sPcqjQNIhfaMrvWBx WLqsJ4eYkBVdYIFCWcK6yPZq+09DM7Cp+OIXzpGay/woyXLIK8P6XRQBscmp+hPvV86e S7TDRtsdkI0tH0OFBLKGc44jR9+RUp6QLs/7ZqYG+RzKvExn7AW+RCgl+JWt49ko54pH TcmBiBxbfONeYz+A9+ikMvQjO7Bx6XP0CQKNevPTJtxBrIJKN4UL/OcvqR1iL/yNiBvO T0Uj6QvBKx8EEiQqRegCvLS1Hlz0TSnnvhGTNzHki6rEygSNdFQtH9hFPCSNLaAhy/eD Xn6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jd3h5W+nQqo5i0Obf5JwrqgVHs0D/GmiD6Eb1h7EYkk=; fh=hEHkW6PU5jJ8R0snCKvrzcRObo/hxfkg/Lt0qbve9mY=; b=hEPG1S2LxII/K5HysA2+BcxRHrfldieT8wnEikqCfPOC8ZI9MR5yq6Y0BTvLOKvuew 4YIW1F/4IoAKzxhFClpcCOgjDHWQd7NALt4xgMMoh1h2ukPXlA2NLL3b4/Fzaf6V/Ax1 SeC7rExhzS1JZpwY3+h7qwmwqjNixdD2Ovpy1gA2SPo2hxE3robkC7aOGUiESCpv2ZVe DE5Mtn+/cgfqsCBAep2ZkHtQ1B/QfikBvuKvVZvXscF2QbaUaoAcF/IWGGlPXXgefZBY ymDDNQRod6OBYMaTpIWxt0WZnzo/UuWt29N0asVXXS0IZxnBeZHvXkyZudCXYwXLttIj EtRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=o2bPTbjy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k26-20020a635a5a000000b005534371608dsi212225pgm.849.2023.06.23.14.24.26; Fri, 23 Jun 2023 14:24:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=o2bPTbjy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231843AbjFWVPP (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:15 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530175715665884?= X-GMAIL-MSGID: =?utf-8?q?1769530175715665884?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ size_t e1,e2; expression COUNT; identifier alloc = {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- 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) for (i = 0; i < test_loop_count; i++) { n = get_random_u32_inclusive(1, 100); - p = vmalloc(n * PAGE_SIZE); + p = vmalloc(array_size(n, PAGE_SIZE)); if (!p) return -1; @@ -175,7 +175,7 @@ static int long_busy_list_alloc_test(void) int rv = -1; int i; - ptr = vmalloc(sizeof(void *) * 15000); + ptr = vmalloc(array_size(15000, sizeof(void *))); if (!ptr) return rv; @@ -221,11 +221,11 @@ static int full_fit_alloc_test(void) junk_length = fls(num_online_cpus()); junk_length *= (32 * 1024 * 1024 / PAGE_SIZE); - ptr = vmalloc(sizeof(void *) * junk_length); + ptr = vmalloc(array_size(junk_length, sizeof(void *))); if (!ptr) return rv; - junk_ptr = vmalloc(sizeof(void *) * junk_length); + junk_ptr = 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 = vmalloc_huge((nr_pages > 0 ? nr_pages:1) * PAGE_SIZE, GFP_KERNEL); else - ptr = vmalloc((nr_pages > 0 ? nr_pages:1) * PAGE_SIZE); + ptr = vmalloc(array_size(nr_pages > 0 ? nr_pages : 1, PAGE_SIZE)); if (!ptr) return -1; @@ -293,7 +293,7 @@ pcpu_alloc_test(void) size_t size, align; int i; - pcpu = vmalloc(sizeof(void __percpu *) * 35000); + pcpu = vmalloc(array_size(35000, sizeof(void __percpu *))); if (!pcpu) return -1; From patchwork Fri Jun 23 21:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112314 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6048654vqr; Fri, 23 Jun 2023 14:24:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5CFeQaTXK6S+h8MQDY0twwPdAgUaGovdMeZWVx400zXZdTZc1YaZyB1zLjxsdRXEnzbi3a X-Received: by 2002:a05:6a00:21c2:b0:65a:710a:7855 with SMTP id t2-20020a056a0021c200b0065a710a7855mr17143129pfj.26.1687555479819; Fri, 23 Jun 2023 14:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555479; cv=none; d=google.com; s=arc-20160816; b=itZyw6ACQ4Sj1ZdQ2EQlxvsgx4dxmJdIWcvGWiLrKAS8xBZlbyL7gVnR4REKxeCIl6 tCef1Is6WPwFgP0tozPMgnXj7XKUAS1W9wdKHzwo8h3QIsi2sOIq21PKAnNcMgOk3xil TL6jOPBh/412882D/iW9elAguiJDWmsCRRe+DZE18Wf98Ehyod0nBkf9xluUdFzVVFPO o8/5bbx+aeDIK4oUtGpfDAmjbRtOncTIT0eIxnihsqFhhRCNwUCKztOatneVfgk1dohZ Uw333JTkDKxO0rlk0igx4LA8Ug1kGpNPU+4YVlPZ5c3uw+6Bh8zw9AJvDPT7B5oglMaJ 4iwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6uQt9cKBk2Sag9c2YWWjAaGPZs3k3Hvob+itlodbJvE=; fh=Cqc/z/U6Zn38c+j1JjCoDjkQ1/zqQ8NO+by02VHnZBE=; b=GmwLqfNg0DqOPEJS2vek92zjbu5LrmYp3LK7d2LV9z0y87xVaLW0/7cTz6A5inVMKv 2GR+EqsGvu+cRVO1cxlADFXG52PzeMDb/1ptGGnrsoFMhcG1rQT2tH68XkvwCE+cSxzQ r1zlliecun27hoq0y0N2q/dfQDb7Pbpto+Ahx1cdYwG0tnWmDkbd2lPFV4BA71x+1u9r 0m3ZvVe0yIKjMPaUlMMxTO4mvBy/3dGrd6Njxp18xEHCWsGoivKuxXl3ibTEGItMSxfH PbYsltteXmmINb0aWGxB/zshTocaLgoSObP5etBc0j+nu5ydqmJzORFOGnlIIYRwpI94 DOQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=uUeK7v84; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020a6567c2000000b0054402b987ecsi244296pgs.803.2023.06.23.14.24.25; Fri, 23 Jun 2023 14:24:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=uUeK7v84; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231702AbjFWVTA (ORCPT + 99 others); Fri, 23 Jun 2023 17:19:00 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530174806075844?= X-GMAIL-MSGID: =?utf-8?q?1769530174806075844?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall 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/net/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; } - oq->buff_info = vzalloc(oq->max_count * OCTEP_OQ_RECVBUF_SIZE); + oq->buff_info = 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 patchwork Fri Jun 23 21:14:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6055487vqr; Fri, 23 Jun 2023 14:42:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TTfreQ1mfVwRJy4wkopVUQJcZmfx21YbgtCImkfi/cfnfD4wBEPKjGJydJhPYpxxXblzZ X-Received: by 2002:a17:902:9f8f:b0:1b5:4bdd:6428 with SMTP id g15-20020a1709029f8f00b001b54bdd6428mr218479plq.67.1687556551636; Fri, 23 Jun 2023 14:42:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556551; cv=none; d=google.com; s=arc-20160816; b=n7nE7JMzYwOHmCrE0Qx0oLWKzOm+5DVV90LeRaCS7V5W3dvMNTO6wWGbMz974zmfS4 rGHxXGowWB28iU33JgT9pJ5lKZUps3miDRzMa/8/vXSjN/ljZslNnGniC4n/3PBhtO08 /GMDDUgwswFtJtVcsBIAh1ainYuQxrOmDfs9Dl9r+7vAqvHLx0CCBBkMSPLUeTUQLGU9 w1fzObn5zxLHRvESQdLvnKaMhjcs6jxaOSzrMNGDy5eAll0TShSi/0szv39n5CCzvfkd ae7l8siM1saqZLI2lNUfYtImzKf/xL4pVO/umLu+fwqy4nr+hI2ynOw79PudjgIh72VG nI1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P1v6BJpujkRR/XkZZ2TcSC10Ee0xBDh3V/U/H44vDYA=; fh=wiRZAUBhqKiWWd/HTa1epr+0ZBHJz5POkOeTBY45oXQ=; b=ENI5KmR7JdEjYKgjfLx1A7DjPBz8vnJleWQP5s7rdbgW9uimXZKznbL2CYNMUaWJFu 5Vv199Tr4IX3e/O0Qo3Se5+kHIQ8IwLB4lRE2wPD5Y0J21Qi3XpsZdgJ7IAZUE4v1aC7 mGAX/poWfaIA7Oh/NkZ97ia/P9d33Xziy0/Z4nLOqKC/TuZKnPae83K/V3kPoz05pOJ6 c2GIbYtQPbPWpCclevsdG9QldPzhsb2YnJ0ryRSt2GAvMZSaNncmfZBBIPmrSI0itMa2 9fakPv4BaCznKkAY8ckVtoQMQqWlOB8aCuQ3OAqWbOJXvAJVJYTyuZjvJFfy7+ZER0DP sp+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=bZVjS8wA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020a170902b71300b001b66f00d40csi61416pls.351.2023.06.23.14.42.17; Fri, 23 Jun 2023 14:42:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=bZVjS8wA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232076AbjFWVPS (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:18 -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_Tr=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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769531298359588976?= X-GMAIL-MSGID: =?utf-8?q?1769531298359588976?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/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); if (!gdrm->shadow_buf) { - gdrm->shadow_buf = vzalloc(fb->pitches[0] * fb->height); + gdrm->shadow_buf = vzalloc(array_size(fb->pitches[0], fb->height)); if (!gdrm->shadow_buf) { mutex_unlock(&gdrm->damage_lock); return -ENOMEM; From patchwork Fri Jun 23 21:14:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6055725vqr; Fri, 23 Jun 2023 14:43:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Sm6Cn+tgJRxnjnNVYSowUxzCJRhqYVL54r9ZbqqJPOj99RiFrzkJzl6knDZqFshYceED+ X-Received: by 2002:a17:902:868f:b0:1b3:ec08:f8e2 with SMTP id g15-20020a170902868f00b001b3ec08f8e2mr234953plo.49.1687556590330; Fri, 23 Jun 2023 14:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556590; cv=none; d=google.com; s=arc-20160816; b=zqs1xZzgFCSe926JcD5LkvI3e5I78hssgb46zd4CnySCEcvfLjn08KUBRj9zhzBwwA YL+rGEnPJUryOoaXnimYPWRxEfysjZMku5p3cI3ABeWtjTsUtjXuKjS6jXmMnXXXTsYR D8cBIk4XNea6EJnVqcDXWQvTKgOeZkIoUhcmOMJgqVQ8zXX+Dpnjb1SqDu90XmI8qDJ1 iQN0B/bJWHHNq37g924J8cB3mqpQt88ipuPplqeh020IIGcv2Q/oCU9Idr134rzgqFf6 IyZ2hDfwG8PrrK4Ha/stqSNwuiRH3xadt7F+bxDrNY6Gi8P9cXE1WrgbkgWqeIc2tjrO q+zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q8fH1XyQxmARYocJhPPGMcs4NWJZYuZGeywIVulmPQY=; fh=hDtFpMQzPzneqOM4qBUUOVoMkJlN7PCDODc8ZRjU6qo=; b=Jou0n+dEbR+qzjQ88dQm9M0Pvt73TiyTqiLWbQzmNmAABJjZ1oX3ooQ3BCIpOrpszO 3UPzXuUL5SU3Z8KrbGbzhShXXx2UyTbGmTfy4tar1EZemLUS0TTmzzo3ESa9EEmaMoAG bTw+WJ039mUfpWT9lIPrQYDZF9gRyzFb+jb5x+gITLCB2hNxnyv8uan2q2Qa1ZsNzZz0 O+sXts7uipaOjv+RBDz+WkczDL9cwFNVQtxatdx5s7Gn1poXYNhcrNkIVRgt2X9tgM/c ugHB/huXaibphxMwiXnLKhfV1CP1LadxvYSdJTfhSAiKuoZ3w6GZlyXhmglAOwepTOhj MfSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b="XKE/KhM+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020a170902b71300b001b66f00d40csi61416pls.351.2023.06.23.14.42.58; Fri, 23 Jun 2023 14:43:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b="XKE/KhM+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232760AbjFWVPV (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231978AbjFWVPP (ORCPT ); Fri, 23 Jun 2023 17:15:15 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B46A0189; Fri, 23 Jun 2023 14:15:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=q8fH1XyQxmARYocJhPPGMcs4NWJZYuZGeywIVulmPQY=; b=XKE/KhM+KKZI5szWCteFS3slNnUiCyWgU1iD3fRNxS81/HolDJ7JHSnu ee7gU71NB+eagWOB21InP0QJvpVyyckPjHtFnS7moz3Ok8Ov4u84nz1ze VICUC1wGomN3ti0kodaswdijsh6e/o9njQ1p+PCQLi1gZTrhcknLfNiPT k=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.01,153,1684792800"; d="scan'208";a="59686162" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2023 23:15:10 +0200 From: Julia Lawall To: Jeroen de Borst Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Praveen Kaligineedi , Shailend Chand , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/26] gve: use array_size Date: Fri, 23 Jun 2023 23:14:35 +0200 Message-Id: <20230623211457.102544-5-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230623211457.102544-1-Julia.Lawall@inria.fr> References: <20230623211457.102544-1-Julia.Lawall@inria.fr> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769531339108846068?= X-GMAIL-MSGID: =?utf-8?q?1769531339108846068?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ size_t e1,e2; expression COUNT; identifier alloc = {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Simon Horman --- drivers/net/ethernet/google/gve/gve_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/google/gve/gve_tx.c b/drivers/net/ethernet/google/gve/gve_tx.c index 813da572abca..d77ebbb24936 100644 --- a/drivers/net/ethernet/google/gve/gve_tx.c +++ b/drivers/net/ethernet/google/gve/gve_tx.c @@ -248,7 +248,7 @@ static int gve_tx_alloc_ring(struct gve_priv *priv, int idx) tx->mask = slots - 1; /* alloc metadata */ - tx->info = vzalloc(sizeof(*tx->info) * slots); + tx->info = vzalloc(array_size(slots, sizeof(*tx->info))); if (!tx->info) return -ENOMEM; From patchwork Fri Jun 23 21:14:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112320 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6049572vqr; Fri, 23 Jun 2023 14:26:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6wGhogcWSxO/Mwi0zR1ws+kzkV6930cm61IrcnChPVzzGlldIT/24U3rb0eA5r36sVlQUp X-Received: by 2002:aca:2109:0:b0:39c:9173:31f1 with SMTP id 9-20020aca2109000000b0039c917331f1mr23320768oiz.28.1687555606600; Fri, 23 Jun 2023 14:26:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555606; cv=none; d=google.com; s=arc-20160816; b=obrd70hYT6pprP2p8vAK/7GaEewTW/BSF8wvww5CQeJJOYL/qhLHR5y9KFmTdgVG9c WUyTp3aURzjwDW1X0xKNQSUdJvEcfBPqbOnMOHUW6O0yaeuNl1YRBRzr6lmgMtoGNBKF VVjZvYmjUumL+fw/4td1u+36ZIb2tzIG5MWVtCJpsU7jYgzj1/huMQ38HoJndEgiAmqF NXGMUMqKv30t3g/xGLn+W3cKALd/HR2iziD9Z/AJLTiocm//CSoQ4UhuoWKXu7Z0ibDD aRTCBc/3CspMQTrIbU9qNzPDpC1N7oYBvK05RV98QNkszpvHWoPmOzYs2EuALG8PsWZt 7z8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8o1B2LX7Hh8TNSfFwUWyg0VffJUQJIzGAe2D6u+TlYM=; fh=fPN19taMOkcn+N410fgaeLFenvdK4hsDVESvGetjJCg=; b=mNusw9BpH/4bEF67JuHbnJm3QVyoGvUR27MoT/OkZENSgHEbhi4m8NCxbRgok1ZoIT zbtY4JRVbaZw42D+Wm6KQQNm0iKJkC1bsMDRI4LIN12GOPiL0dbrr0kIsa6jTiRiEO9P uRfzKYHNNHMWfCNCI5naXC9HN75HT8g+KhRSrxl5gRj2IOAdB0fM+cYhCMe/1xa51rEd 9G+VLEP3NFhMr821iqSPbJaQRKDFuwRTVsyY+CRKyfeXIgYAK1XJzUYsx9BnlzjyCy2+ BPLADvut/+7LdgammIsF3HeWGUzN870t/2jUbUSbcaC9K7uQ4S3ofPILfhtAxaf/jfVO SM5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=W3acjQz8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a17090ad78900b00260fcf90085si325013pju.97.2023.06.23.14.26.19; Fri, 23 Jun 2023 14:26:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=W3acjQz8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232923AbjFWVUO (ORCPT + 99 others); Fri, 23 Jun 2023 17:20:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233011AbjFWVTv (ORCPT ); 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530307699653313?= X-GMAIL-MSGID: =?utf-8?q?1769530307699653313?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall 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 = dev->func_bar + ERDMA_BAR_RQDB_SPACE_OFFSET; - kqp->swr_tbl = vmalloc(qp->attrs.sq_size * sizeof(u64)); - kqp->rwr_tbl = vmalloc(qp->attrs.rq_size * sizeof(u64)); + kqp->swr_tbl = vmalloc(array_size(qp->attrs.sq_size, sizeof(u64))); + kqp->rwr_tbl = vmalloc(array_size(qp->attrs.rq_size, sizeof(u64))); if (!kqp->swr_tbl || !kqp->rwr_tbl) goto err_out; From patchwork Fri Jun 23 21:14:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112322 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6050304vqr; Fri, 23 Jun 2023 14:28:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5M/YRy3+dfcf1ztVAAGeBQzf/xtIzlSd7CsFZ9bXZB1U+9yXcVkAXREUkLX732JiaetS+N X-Received: by 2002:a05:6a00:1a87:b0:66a:386c:e6a6 with SMTP id e7-20020a056a001a8700b0066a386ce6a6mr12029243pfv.6.1687555723824; Fri, 23 Jun 2023 14:28:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555723; cv=none; d=google.com; s=arc-20160816; b=uyh2ifYNI0ivH1HAdp8BzHVivrMB9VUz0fd8BwT5gEKF2FvV9w6r2MHFZ3TiUeyusP Zj0xVLpMOxmg+yh3MQvCJJMchXwO930twdYZJZisK0g1ag9rwJEhvZ6zOVGbs8zDPr/j cmx0m0A0o7IUmErVXbNcTsZx0+7fjgHW1lRgEsVyetbZt9DbI/ZIxSxyvMmEl/RvyFri iUCvYceXNZgqrlGUT0WjAxrwM2I2p3LUW0J9cbpIKh8Z00KwklY4pOzNGsnqpKNPpgl6 AlocUjI7e3gXeJPsnCXrdpdqpXoz2mBsq6nEl/QrAZKCVvTkCWThbgRJmWD+gtNOGPeE Oc8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v1C6X9Yx4yVXOAdKb8gSIcJ1cJexwLFD0Mhp8hyTXpM=; fh=F5dRuVQGU4ee3jzykFtDTPC2cSFBiBkLO6/40suH+oo=; b=vkEjzHws5+wrn6QzWn5GPegXgpaxgt+CjwB1uVxwoJuJcetLkESGkHQURKTHH8QC77 +TDoDGWdjP5qlOabE4r556vddELTmr1UXn0rqXCI+tXp/8aZueFd+nKr6kczSfGTVjKg SOMyPrgfqpULOR7IWNVTSy1tzmCvIZvOeLgHhxebwCdYWOjaoEBz3I8e4CEbIbK0rU5J 1QlGlW7pj6qqMWVou/Up7e020bjCvRz0Lx4C1HAe0S6aVAEsXOKDwNFzG6kphJCaaeDT 7SGQH93KFrdguVXhSuXW9AQzOAy4BqRO5CnCZJBwaBcobCVIbU7w8vO+sAyK3XyMKcgY UuHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=ibGdS6fG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fi14-20020a056a00398e00b006688d6acadesi45239pfb.156.2023.06.23.14.28.31; Fri, 23 Jun 2023 14:28:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=ibGdS6fG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232442AbjFWVPZ (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:25 -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_K=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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530430841966736?= X-GMAIL-MSGID: =?utf-8?q?1769530430841966736?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ size_t e1,e2; expression COUNT; identifier alloc = {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) // Signed-off-by: Julia Lawall 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/system_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_buffer *buffer) { struct sg_table *table = &buffer->sg_table; int npages = PAGE_ALIGN(buffer->len) / PAGE_SIZE; - struct page **pages = vmalloc(sizeof(struct page *) * npages); + struct page **pages = vmalloc(array_size(npages, sizeof(struct page *))); struct page **tmp = pages; struct sg_page_iter piter; void *vaddr; From patchwork Fri Jun 23 21:14:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112331 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6054584vqr; Fri, 23 Jun 2023 14:40:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4oizOtYwBNeqKI0xpRJimI56srBaDUTL0THKmQjfs4WsjH98lM5Xa2jr7g3saAiT3kWnhY X-Received: by 2002:a17:90a:fe0d:b0:256:4217:b955 with SMTP id ck13-20020a17090afe0d00b002564217b955mr20082346pjb.35.1687556404281; Fri, 23 Jun 2023 14:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556404; cv=none; d=google.com; s=arc-20160816; b=YcczQr38hCEOXGKwlEBXGdPjMQROj0yGapKVCuRNb408NztZuP2Fiufzi2hqqW6YnQ AFCeCdvKA+/Nz1EUQtiEHuBX6dQcsxvXnmhfu6N2RvfIeKh0MoYVdD1/+fKLWZb68pY2 i5wT9mZdaQA2Hg8/JQkrqaUVIfeEZx1mkWEmQ1QDsqouTGXgoWHSItQMd3wJkFO3eAhK cG/KLLxmh++9z3C7B6xx5O3pw2GguGWxiQZhs0g++UC6fNmb9NeG4b52YM3dtmxxTNay lFV8VIckPjfYm4uZ6VIaidsOACTA+MswyS6UzXtOvdV1xBemH2dh3DA1m/Tb2qYMNDl5 251Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QJydWjDhcLcynf/rTVoWViPI3W7kgehSdj6sywGYPic=; fh=v748+a5v7zsNoeZ4C+RGwK7AELp2QIWr0P1GpREhaNM=; b=nC5k8dc8wpuOC1VD6RoWaCJtiXcHkOcHgSXZhrS+xmiXY4PeEHPcOVRPhKOvPBZO/K 8mztnvoQ7N5b5G3HBlsoAnhnbF2YPaeSJp43IAPlvEgmUs9jiIDwtbGmU8dZLc4/fTfK tMYKuOJdQ7EEo0xp5f32tsNtwJYZT7D2wY3eTAAdXGu9oylyb3IVSamZEAjxJFStEodG bo1AXa4dBUZ1YSJk3LJc79WH5ecAy6fNvEQRS4Mx+830mqRmP/dfv6kU/YwGxdlh3q2f VfcIEzC2q/7jFulqeM4AlCTpSpqoX5TfU7BiuJd+KQthtQnZPx/zgUrIfsC6h8sJJAXY OCPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=X2xeK3QM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v6-20020a17090ac90600b002536c5eb7cfsi2611108pjt.58.2023.06.23.14.39.51; Fri, 23 Jun 2023 14:40:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=X2xeK3QM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232833AbjFWVP3 (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:29 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769531144489634969?= X-GMAIL-MSGID: =?utf-8?q?1769531144489634969?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/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 = (trace_max_pages * PAGE_SIZE)/ FNIC_ENTRY_SIZE_BYTES; - fnic_trace_buf_p = (unsigned long)vzalloc(trace_max_pages * PAGE_SIZE); + fnic_trace_buf_p = (unsigned long)vzalloc(array_size(trace_max_pages, PAGE_SIZE)); if (!fnic_trace_buf_p) { printk(KERN_ERR PFX "Failed to allocate memory " "for fnic_trace_buf_p\n"); From patchwork Fri Jun 23 21:14:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112334 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6055342vqr; Fri, 23 Jun 2023 14:42:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6W8/WHnc0VK5ylSYkRV8rItHm9/g9TzPt7DPo6kPN/x7Xv3lsEwRpNhSv/LaEGh/gSh1pY X-Received: by 2002:a05:6a20:6a23:b0:117:1ffb:a14 with SMTP id p35-20020a056a206a2300b001171ffb0a14mr29387162pzk.13.1687556526418; Fri, 23 Jun 2023 14:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556526; cv=none; d=google.com; s=arc-20160816; b=hycQ0zHqY3eVRVDXQ1UOUU4O0FCFDUTe2pGtEmSfG3xFK/c7a6HYWWjezWje3tCneu JBaUM/whpcgDuoeJRvdqMmMz8zhqWEqJpmoRI+e5YZjX4G6XcuC34TTFC2PQ41AXTVu5 lekK9+cExYxOLmLTZAGYze80dvOgb7bVEyIEX2ci8MiNfVhx2A2ZaxL/3EbZyraNbHNz eRDjswcpV0SGV1l8pEm5kMurWxqDkGp+npteYnzCK0kfWgBBIW5zxb33Tw3aumWFaGfS O2uZtA4ptL3Ur1Nb9F61rMKCATE03L/rsybKG1/+C980Q6m4ZUeqUF8td0WtwckaN0+A vUjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8WWGDy69qrtzavSblwBRgHQbwXA80r1Q53C16BTDHPg=; fh=le6LjByZ/GLn71+30CM/IrfFLROZ2UJGH4hDLIguZ6U=; b=FV0ZCDl4ROAQSPHNHCUWfg5pbKntrdaJO0N75pqrvkcQT13o1FNk3TIN5Q+DAzfSbR H1EF26sFNAdjuMfzaTmEziL7V1BIaebfmPuFp0Vy8l21j+A77J/TtPOnSVfrOaP1lCeX 3eHyxE8uz2GqXyJuINQReAp/2XnDlaxEfRmdojo4uB4FRaXvZGrKPX1tCEzJIQy6XXVi ZPD3iyVnxOmlHQZTO5hZP/KrZ5Dz7n7NTvQ4btpcBUEAKdowMmfiZc3D9wHpPp5w2cCo YKOHkG9544l5Pb3YeU1tVNFjEfTAzuQmVl5ien/KYw1y2rQfUQ7uEouEUWjWzjHeY6rk 6dRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b="Nf2/PyVP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w136-20020a627b8e000000b006689f89b186si41985pfc.208.2023.06.23.14.41.53; Fri, 23 Jun 2023 14:42:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b="Nf2/PyVP"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231911AbjFWVPd (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:33 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769531272328061410?= X-GMAIL-MSGID: =?utf-8?q?1769531272328061410?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Xuan Zhuo Reviewed-by: David Hildenbrand Acked-by: Michael S. Tsirkin --- 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(struct virtio_mem *vm) if (vm->bbm.bb_states && old_pages == new_pages) return 0; - new_array = vzalloc(new_pages * PAGE_SIZE); + new_array = vzalloc(array_size(new_pages, PAGE_SIZE)); if (!new_array) return -ENOMEM; @@ -465,7 +465,7 @@ static int virtio_mem_sbm_mb_states_prepare_next_mb(struct virtio_mem *vm) if (vm->sbm.mb_states && old_pages == new_pages) return 0; - new_array = vzalloc(new_pages * PAGE_SIZE); + new_array = vzalloc(array_size(new_pages, PAGE_SIZE)); if (!new_array) return -ENOMEM; @@ -588,7 +588,7 @@ static int virtio_mem_sbm_sb_states_prepare_next_mb(struct virtio_mem *vm) if (vm->sbm.sb_states && old_pages == new_pages) return 0; - new_bitmap = vzalloc(new_pages * PAGE_SIZE); + new_bitmap = vzalloc(array_size(new_pages, PAGE_SIZE)); if (!new_bitmap) return -ENOMEM; From patchwork Fri Jun 23 21:14:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112321 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6049987vqr; Fri, 23 Jun 2023 14:27:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5TxSgohkweOn+1aiJX49ljcxiYbBhdtKiBcFdg/cb7IdABSnaVdTAlFNPZ1SRfDTflwqEL X-Received: by 2002:a05:6a20:9385:b0:10c:4ff5:38b7 with SMTP id x5-20020a056a20938500b0010c4ff538b7mr13742828pzh.6.1687555678599; Fri, 23 Jun 2023 14:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555678; cv=none; d=google.com; s=arc-20160816; b=Rv6Ru3AyQLJ5YTyUaqo+wO+cGYlG2iieqRUhc1fytUGBrj4/z5tNmkbnGDewtxBvZX 0c0frXelxNqBt2HSEiJubMNfrKjdcfuq5Ih1HvxkAZbolc16/13fnm9O/1bJZEe+jsOE Kpd0RiSYGBPsdmsyzZPn4i61o4IbxcH81eH3hIN6WoMIQ+w6mLmmDznNu5HGeuqta3it kwvoRczitH7XIjwULCdIgadLCGZEoYFqDhX0HpbXmKcSG4i0kfkD8L2jzHDbkI3yYJT6 Ceo2WzMWSHKM57euFUS9D1lSkIql1jv6xnA4GoO+ZfLQSbsrOOCSjkx3iPhRjMKNm2+5 L43w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GCWo4PVrP3ZeFd8PIff442f3VLqG/AMKNMFkIT9T6cA=; fh=kAwTNgFKZnElgUbacnbPeNcvgCOdjAyuqnkcwpNxIGk=; b=CCmIjglvNV9d6DyFDUXfpBy7ppb9GiFdbbZD6y9rB3wjyV7CttraXhQk2E4N9IM0li yaN2RxJL8Hrn6Xa4PLa5fGOC5i7pyggbkTLUhhrPxvaMoVvCJHp9Qr1G05ggf4mSMEm9 lijwZwzMVtyIBT8DvdRkNwwVAnwhSEZM/eWZNoiCfxAk+pGG7JnVrXREGXEHBha9YQdm yjkAfZAj/iLAO6HUrDETxZDfxuzproV2/YXz+ZzG+9RZRKd8YIe6zUAZ47kTWqC03B4n rkg6wp40qblaHci+SAt1M3b8l3LjUtyZ8rkogL9OTIxwhf0lPTozvyh4AiLMgQfykXcr G3gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=K02CyeC0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q20-20020a056a00151400b0065d3032fa22si15615pfu.289.2023.06.23.14.27.43; Fri, 23 Jun 2023 14:27:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=K02CyeC0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233006AbjFWVU6 (ORCPT + 99 others); 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530382920724963?= X-GMAIL-MSGID: =?utf-8?q?1769530382920724963?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Simon Horman Acked-by: Shannon Nelson --- 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/ethernet/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; - qcq->q.info = vzalloc(num_descs * sizeof(*qcq->q.info)); + qcq->q.info = vzalloc(array_size(num_descs, sizeof(*qcq->q.info))); if (!qcq->q.info) { err = -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; - qcq->cq.info = vzalloc(num_descs * sizeof(*qcq->cq.info)); + qcq->cq.info = vzalloc(array_size(num_descs, sizeof(*qcq->cq.info))); if (!qcq->cq.info) { err = -ENOMEM; goto err_out_free_irq; From patchwork Fri Jun 23 21:14:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112308 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6045677vqr; Fri, 23 Jun 2023 14:17:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Z0S5dv0AbUHUw0sDzETGB7OnGN2h7HJcNxd/RHDCHoUNvxI6f0HXFpw27swjKFUpLxqI2 X-Received: by 2002:a17:902:ec8c:b0:1b6:c552:f5d9 with SMTP id x12-20020a170902ec8c00b001b6c552f5d9mr388642plg.17.1687555056661; Fri, 23 Jun 2023 14:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555056; cv=none; d=google.com; s=arc-20160816; b=hOUXjZd6U+NrmfvgXRFy5kuX2za/1/jf1SSQ8a+1DTSSNiYwFqfETXl8p/uE2MNXMX YSuzM8KMpYBUkVLJNOsHN9PcnuAAV8UiixwqZ1LakXjZxU4Nd95SEEHTGOxjQlD7jde3 DwtD309/AAT56aPQupCFCyKPo0sEG0FgDua4PF4L9mzCEP+Uqfjznts3GzSkvYcoujBP ONt+9kwnFLliVjIDQWnAbF+lfgvvWhwDenCexT0wpfJZmgqjG5Xyp7b8pK3rjtWG9Jno gNf4ZM07N9/BwuchBh8fgBddurjOTBN4X5GVRtC6Tg2rBDzy1tHqgoBpg6eiQ4Fm8NsQ N+Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yyXUjWCAlWpegeeP3K+qGmg2LllPAIpv/xP8Xpl32WI=; fh=ZuSR092+YmLEKokmFv8CHmd1t45Me8cND1PPcjuZM2g=; b=zRWZA5Rj5BlTKMwPJ9X/vS4kOVgA77Sts87Wb2HKR9lyL+MBd0XHG2AkSPU9LcVgIl lLj2ZI3wn94iHNVFCslcJTvFT7LEFXx/L57lBNRB7oEGJe47gJS94VRd7NctZ3lQQ4hk KPWjc/hcdgeJoDVRFyonnPsXzCR8s6kGU0BOLGvBXiOuZfiejxU9i1TkRNLxam9MpT+Q T3iqs5fgtUP6nBMtenGn5Xpb3driaxYR7xcPXl+X9gYEjtkIcbvKF+PQ3GVN2+xmyCH+ 2reLPa7u9i+o7+gRsmuVBljxqTirdvcy1CUE/5747keExBhTkjkZ3BE/VzJS8zscXc+i aw9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=WNpEcGRn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id je20-20020a170903265400b001aafec82436si66879plb.204.2023.06.23.14.17.23; Fri, 23 Jun 2023 14:17:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=WNpEcGRn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232678AbjFWVPg (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:36 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769529731163207012?= X-GMAIL-MSGID: =?utf-8?q?1769529731163207012?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall 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_cntrl, * so to avoid any memory possible allocation failures, vzalloc is * used here */ - mhi_cntrl->mhi_chan = vzalloc(mhi_cntrl->max_chan * - sizeof(*mhi_cntrl->mhi_chan)); + mhi_cntrl->mhi_chan = vzalloc(array_size(mhi_cntrl->max_chan, + sizeof(*mhi_cntrl->mhi_chan))); if (!mhi_cntrl->mhi_chan) return -ENOMEM; From patchwork Fri Jun 23 21:14:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6045660vqr; Fri, 23 Jun 2023 14:17:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6qIbhESenfoh0Jzy7jMOS68ufHRK+kDIDQ+aqK+wxZ484O3YB+e/mz+lKAvSSqd9Md/XAC X-Received: by 2002:a05:6a00:2e10:b0:64f:35c8:8584 with SMTP id fc16-20020a056a002e1000b0064f35c88584mr31798054pfb.18.1687555054886; Fri, 23 Jun 2023 14:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555054; cv=none; d=google.com; s=arc-20160816; b=GbyEKvD4DUN94JOAe6RsqJN+JJnOAVHWz7K36GTsF9RL8E00jIzvSwiZ4Z2H90d3xn nyDtSFHgK1Nd0tRVBNRSdkwhES7rUWm7bUalKmVmaXYPGtr8e4o+CnJuWiSuLtgN8Xo8 eLaXlZ9eUdTFhhwsADEiXjWPc/dXj6+HpBpMGj9ASpp1RGcAW/VqjQyLL2fBcI1xUEWl AfSMzYRGSsFzn31C/VrsLPVT9zJgSV+tyZCmUmfkrmX2g3t3wZgtQ9+EykPRQKIT/66p myxDmThzck/J/DhGeXJeqk6bfzL6eatPGlPjHlzgs3r8HL9VJrP+J5bRvDyYASGRlWOV J2mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/TRxy0AuF5FOCiYvvmf3tnTeoM1gUmxAEjlXeC+Ek4Q=; fh=w9WUcIrhuVsmFPTfZTX+NmB1JSS7q4BCLa9Ptx6Anoo=; b=VC3OTt4WvOGFOlqJX6wsT/Vq6k2WclVBBFaSgE/qnUSUFuY0XYTWdx10sCPWtBgB68 3VtMv/MU4JCpvasGLQm1YcePnWWZrkpvuzqGoX5wiL9HAs5264/AF04W3khCh6W9ttW1 N6Y6BkE9FIvKvIlzHaxR97lKFQHjfGac1lDqlXqdZ08M5DXxUk5eOfXTebDLD1V4/TF9 CMe8SLdseKu+R4gQ1hFMh0cKgcwSKYORGxF0vvnMsIr7uR3gdo42alpg/39IvmqjlIut 8crVfHFMEDmJewr+qLYTHDUOhdfegZvsNoaRqGM6lu01CGoANkvkBei5Vg8467fVVbYr 3scQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=VcpH1Vz0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v9-20020a056a00148900b0066243798ac3si4417pfu.278.2023.06.23.14.17.22; Fri, 23 Jun 2023 14:17:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=VcpH1Vz0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232724AbjFWVPn (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:43 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769529729049890136?= X-GMAIL-MSGID: =?utf-8?q?1769529729049890136?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: Simon Horman Acked-by: Shannon Nelson --- 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, unsigned int type, new->q.dev = dev; new->flags = flags; - new->q.info = vzalloc(num_descs * sizeof(*new->q.info)); + new->q.info = vzalloc(array_size(num_descs, sizeof(*new->q.info))); if (!new->q.info) { netdev_err(lif->netdev, "Cannot allocate queue info\n"); err = -ENOMEM; @@ -581,7 +581,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, if (err) goto err_out; - new->cq.info = vzalloc(num_descs * sizeof(*new->cq.info)); + new->cq.info = vzalloc(array_size(num_descs, sizeof(*new->cq.info))); if (!new->cq.info) { netdev_err(lif->netdev, "Cannot allocate completion queue info\n"); err = -ENOMEM; From patchwork Fri Jun 23 21:14:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6045679vqr; Fri, 23 Jun 2023 14:17:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4wf8K4yH24gLJRpgr5TSMZpIXv17K1DhjDkIyIM800OGfO8iSKDQrf1YePKe1n43R6OqpV X-Received: by 2002:a17:90a:648a:b0:25e:8ff2:3cde with SMTP id h10-20020a17090a648a00b0025e8ff23cdemr21913142pjj.6.1687555056938; Fri, 23 Jun 2023 14:17:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555056; cv=none; d=google.com; s=arc-20160816; b=NxI17MtNU7yp7AO4yQUX+RYVcjYEaaLmOxKckPmmTZVAQ6GUUHNviHmwy6A7IYff+0 J+8xtHMfVHOJZ0Ghp1wQkIW1gSaXpiBKI8iyMSJPlt6om4hVciS6fLD/nFbBFG1ktue6 R3NdTECnP4di8Pc35npS3YSRXk4vHUvwWL5u9pVr6WPZD0BO8GrdX0ZdxhExwGzH1rhA QX86DZL1EPZ++WtPoGxHlos5l6C/rhK9zKf4WltWN47945p1NCAMcY+dsgb4s/rpgADF 4iNWH+GuH4btP+VmR4Zo5ArtFpMR3Ll38dugcxjLc0+FkPx97hK8EnN1phHXSztQ+BE0 KhLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=x3yaNVdlz5Bh0UGifQdHJbRNelT3AqwxtCVAxF/u48k=; fh=0D+SbFijWVFjdZJfrLsJG5Vji/MCOullDsmz1TAcCEI=; b=aCsRxfS3da/vWZuKxAuf62vM7nOd5yhc9LOUdlYV9I5Xke9CSsVvVlCxqE6WVfB5w5 8Fn8kW1G1JU9ur5M/8bUElZhcoU/XvgTdRhQBdRDTbXmLyz+17DYqoc+f15TR2LDg+u/ RbrD8uivFOfHV+Bqct66/iSuWbrg7Qrrj8/rbrq7CPHDLxfURVRv1FU+Ili2UPYK0fS2 UNN5bha/UBNzv+tRF8ST1WCEyeSPhwGUhXt9EOOhDTfi+phZrp4JZb70v1kAakwyDc8B OzgykyVBqrEUL1h4l80MWHKISjmOYeP/CpBwGfd3pu1VT/9//cGx283drOQ4/nxvJ2HO 67yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=sNuULnbO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k191-20020a6384c8000000b0055336060f9csi241075pgd.376.2023.06.23.14.17.24; Fri, 23 Jun 2023 14:17:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=sNuULnbO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232229AbjFWVPs (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:48 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769529731257639785?= X-GMAIL-MSGID: =?utf-8?q?1769529731257639785?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ size_t e1,e2; expression COUNT; identifier alloc = {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) // Signed-off-by: Julia Lawall Reviewed-by: 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 = vzalloc(sizeof(struct blk_zone) * - zone_info->nr_zones); + zone_info->zone_cache = + 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 patchwork Fri Jun 23 21:14:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112310 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6045698vqr; Fri, 23 Jun 2023 14:17:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6T/fgECGc7auYnJoOhbf6XF59zPl5GbeoDoR3wnT8XbY1beJkIn/AyJBjeqdNAqqj8puLm X-Received: by 2002:a05:6a00:2e9b:b0:64d:5b4b:8429 with SMTP id fd27-20020a056a002e9b00b0064d5b4b8429mr25692992pfb.18.1687555059440; Fri, 23 Jun 2023 14:17:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555059; cv=none; d=google.com; s=arc-20160816; b=CP4/FFRrJ74UH18WnOE9z+uuOJUIFuAdUjS/i2R3DSSgIfmkz7nihsEtq0KIY/zGzg ibUZYrVOk599hStesgOqHGyzhPweZs7tTpKTMJawSX4lkXSeJHFAdI8DsFR+EQ8pEh+t J8x227zq+kDL3+PBBMP/sfHTl0LSPDgiRTzJ9iJ2RxxDV2LfQmnzq9Wl4CfASX4x1gHy FG9MDQZFuo3MYVfCQGmaMjN2UxyWzKAeH1hJ9FzPea4rLOUfVZPABCp/XQ5AHt/AtTvN dGm1SCpcS7+571OZEk0xo5NR/7EFhhgfT07t6F3rGjW9KI4IroqWapxm+eJNs50wmxdg z6Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1HkDEW7AxSHLZvHADInYpWBN1+Bsf50V6Er9x8KFaJk=; fh=yHGuOWQHbttm9lF3oiSFhqz9m993m7B7c90zxZrRrzA=; b=MCt9/W2TVBdpChF/kmA+I1QeKuiCp7R7pJT14HGPCuQjyXkrhJkKT2PAioJNPB2Zeh nVNKWxUL/uOiSE/avacAdNLYcdRbLOmp4ns+ZeZxtR23qtNoLGbDiJ0Hz3WMOBDil3bo z3jCt5YBUF+oF708ebgJMrX7TxalsWfUU9LMwFF80ml8IKwDfJoEqOCPebADMwhP66Jw jxD97oilyq7TCAI8ia3A7am/mqYDH8SbwPTq0nPSzCg1R3q3fqhR/tzdq5w2nGmQbuhQ pMBhv9koONWQWahgHB0gZBlrxJWrr/ifsKunsQCGo/Y3rV5cqzDnL35KWEjMzrpdTq09 6IJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=BfrIEUyQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s17-20020a656911000000b0053fbacdaf5asi199979pgq.759.2023.06.23.14.17.27; Fri, 23 Jun 2023 14:17:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=BfrIEUyQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232629AbjFWVPv (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:51 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769529734241189638?= X-GMAIL-MSGID: =?utf-8?q?1769529734241189638?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/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; - gart->savedata = vmalloc(resource_size(res) / GART_PAGE_SIZE * - sizeof(u32)); + gart->savedata = vmalloc(array_size(resource_size(res) / GART_PAGE_SIZE, + sizeof(u32))); if (!gart->savedata) { err = -ENOMEM; goto unregister_iommu; From patchwork Fri Jun 23 21:14:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112319 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6048777vqr; Fri, 23 Jun 2023 14:24:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6aFOpGCJ/s0Q/T0yNcR3UC5nj/spCi6WoyUd/AYbE5Qaj6siUm6TKsH8wOXrSsoN/VKVe5 X-Received: by 2002:a05:6808:168e:b0:39e:d559:61fc with SMTP id bb14-20020a056808168e00b0039ed55961fcmr19351183oib.30.1687555497126; Fri, 23 Jun 2023 14:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555497; cv=none; d=google.com; s=arc-20160816; b=HXcDuX/hk+6cV8PwnOOUJTit5TQrj5ojPdJbELuW299mHiPto5vpXifU/vSKNjgBGT ZpKN4CYYk1S2ylVHY0G0PpaeYg45qAEY/79wvI0wzU6K0WQGY/Pmv+6wty5FeFgAQkTT 0uffopyHjMlFHxO7UlNf8MLoW87MeZQxdYc4Y+hwuRK60aeW7ubyat0fsfVtGs41dPon 9sSXSBRsak4L8vsZnVjm3XTJttF7smM4NR52u19gUz50W3UWI8tsq0z8GJqXAQlCHpj/ vc7GxrwQu1HDAFVaURsLT8YMFw+Pdm6tvzhPJNRbqaDQ0YWnaLxRp7qU/IVp7Sfgrd5i 8niA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BOvAIPV5b2s9XXgIiUCDYijQMWfGXsngYuXLkntqOho=; fh=itZnuXKIpYduKahZL+T1+9QCQh1QeawSdNcMWTvBmWo=; b=A2vlQmGZTHlZp8iUJSpM+dMWRy9OaB0qLP4AjADyi2+jMgGJc5dsL8KUuzOZ2Yk9PN EtwCBotfLNBKsc0BzKzRR+yRotaDgBX3T5mrXWenBls8EALzRcfrVC/RbxHXpSW2ThG4 /Wdt9roxCmiTEJCw9yAsn3IkujCa4kZvKy1/Jj+KBjaVR3M1zO0ZIqJQNz/6hR1DfDU7 ZZs+4OUZEDQ7qpEaIqCH7KdMaHZi9ZowOpc/FJTzGpmvVsS4HuZajWPMvKg/lggBOotP arMqb36mVCGUZNsR3dSTAiZwL3pPjkyB3njU7UqFZcnxg0/lZ0P+OD96nFlnKA5WymKc rCrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=oBORICMj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a17090a19c500b00250291be156si2659182pjj.148.2023.06.23.14.24.42; Fri, 23 Jun 2023 14:24:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=oBORICMj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232878AbjFWVPz (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:55 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530193107226509?= X-GMAIL-MSGID: =?utf-8?q?1769530193107226509?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall 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 = roundup_pow_of_two(irq_size); - qp->irq = vzalloc(irq_size * sizeof(struct siw_sqe)); + qp->irq = vzalloc(array_size(irq_size, sizeof(struct siw_sqe))); if (!qp->irq) { qp->attrs.irq_size = 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 = roundup_pow_of_two(orq_size); - qp->orq = vzalloc(orq_size * sizeof(struct siw_sqe)); + qp->orq = vzalloc(array_size(orq_size, sizeof(struct siw_sqe))); if (!qp->orq) { qp->attrs.orq_size = 0; qp->attrs.irq_size = 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 = vmalloc_user(num_sqe * sizeof(struct siw_sqe)); else - qp->sendq = vzalloc(num_sqe * sizeof(struct siw_sqe)); + qp->sendq = vzalloc(array_size(num_sqe, sizeof(struct siw_sqe))); if (qp->sendq == NULL) { rv = -ENOMEM; @@ -414,7 +414,7 @@ int siw_create_qp(struct ib_qp *ibqp, struct ib_qp_init_attr *attrs, qp->recvq = vmalloc_user(num_rqe * sizeof(struct siw_rqe)); else - qp->recvq = vzalloc(num_rqe * sizeof(struct siw_rqe)); + qp->recvq = vzalloc(array_size(num_rqe, sizeof(struct siw_rqe))); if (qp->recvq == NULL) { rv = -ENOMEM; @@ -1624,7 +1624,7 @@ int siw_create_srq(struct ib_srq *base_srq, srq->recvq = vmalloc_user(srq->num_rqe * sizeof(struct siw_rqe)); else - srq->recvq = vzalloc(srq->num_rqe * sizeof(struct siw_rqe)); + srq->recvq = vzalloc(array_size(srq->num_rqe, sizeof(struct siw_rqe))); if (srq->recvq == NULL) { rv = -ENOMEM; From patchwork Fri Jun 23 21:14:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112311 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6046295vqr; Fri, 23 Jun 2023 14:19:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6voCc7OCZ+FFfvEMb3ok8AQpRB9akOtZY00P6xz2fd2QYBwGqQ2Kgr1nMyw5G9hkODnEw9 X-Received: by 2002:a17:903:446:b0:1b1:86ad:3347 with SMTP id iw6-20020a170903044600b001b186ad3347mr299895plb.3.1687555147604; Fri, 23 Jun 2023 14:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555147; cv=none; d=google.com; s=arc-20160816; b=1FtuYgORTjBahVaf+j9SXri5tu5LMUR/yDgw6QKcj2gE0gAvgTe1OvQ0AMJdZ5mloF QeWNfytq4Dc1ZS2d5RiAN9BmyMV8wCpwJU/u9o1sKDmpvqQY9YPqI2sB64iYcC8VVQQk o7GmOP7AiPJAil8T150RkyifhxG9Mu1LU3TxiQf6lj4jBa+R9mg8MMRR8Lok2F7e9Pou R+EpsDuQwQdgIUR8ONGPKDPIWG9Q6tGbCL08WpmhGbtnL5xqkyqMOXzhLy6c3RNBoW7k SgbLDII99dmcImlHAncEcEXfEz4MAkSo4O4NbLVpxuAv2xMC2XGA/OIQlnG8qyA+ZpT1 S+mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=42OKv4WqZGQxlnFHmnIuYt+rtnNJuJHuQ6K07YbNUj8=; fh=SQjqolBeMpJhg+n3dLQTExtFoPdMXR2KVoU8KnYenBc=; b=RBxMXCkAijx0FJ8BmvJddXCU2gvzEhdAHxieX3cTanM4RlKseoubgeh6DqvwOIkQn7 CuHUXXWcMm+Ni9/weJ+UML9xbqbUiodX772XgXCF6mUcvemGaNbmcTat4N8lFBfDq+Ip sXvSGVVYz+iE/w3hpwO0xzyQa9gDyjCGmZNqicjAihTysnFjedz9uFUQef8PDoNyGMdK z5LzZ0vkJ/1TJZ9JrDvSU7Pen1xn2somQHARfSXvYbcgGH3hfj5T8L+PrYV5WpTjVQcB Hu5nfKoTwv4E03Ax5rTcoZErmCzgzFS30xWhc8qHJZeydBM9BZpJjNKO8nWY6WCstv4c TDWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=GXBNYgmL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf11-20020a170902b90b00b001a68f933777si50629plb.245.2023.06.23.14.18.55; Fri, 23 Jun 2023 14:19:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=GXBNYgmL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232888AbjFWVP6 (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:58 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769529826190922912?= X-GMAIL-MSGID: =?utf-8?q?1769529826190922912?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/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/habanalabs/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 = - 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 = 0; goto finish; diff --git a/drivers/accel/habanalabs/common/state_dump.c b/drivers/accel/habanalabs/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_device *hdev, u32 index) base_addr = sds->props[SP_SYNC_OBJ_BASE_ADDR] + sds->props[SP_NEXT_SYNC_OBJ_ADDR] * index; - sync_objects = vmalloc(sds->props[SP_SYNC_OBJ_AMOUNT] * sizeof(u32)); + sync_objects = vmalloc(array_size(sds->props[SP_SYNC_OBJ_AMOUNT], sizeof(u32))); if (!sync_objects) return NULL; @@ -453,8 +453,8 @@ hl_state_dump_alloc_read_sm_block_monitors(struct hl_device *hdev, u32 index) s64 base_addr; /* Base addr can be negative */ int i; - monitors = vmalloc(sds->props[SP_MONITORS_AMOUNT] * - sizeof(struct hl_mon_state_dump)); + monitors = vmalloc(array_size(sds->props[SP_MONITORS_AMOUNT], + sizeof(struct hl_mon_state_dump))); if (!monitors) return NULL; From patchwork Fri Jun 23 21:14:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112333 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6054761vqr; Fri, 23 Jun 2023 14:40:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6+IzX06fdncWxOsX35VflSjUUMzNz6FvI/i8aC5r5GhScl49VMmtEzTwlbdrKDHNi6X9Nl X-Received: by 2002:a17:90a:19ce:b0:25e:db77:1db7 with SMTP id 14-20020a17090a19ce00b0025edb771db7mr27174402pjj.9.1687556437461; Fri, 23 Jun 2023 14:40:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556437; cv=none; d=google.com; s=arc-20160816; b=QzK/6B+tBRF8baFXB2w4D4X/94OgpxlQmOoIgpB7yoMxfi8+qSmFyDFLPw/OOhaqKQ RiYxdWyp3wDzUYqSsm4DTDvLEWqx+h/cNSBjGxxfZ04MEZSDUH2GHnYT4XS21FfRKar9 ksDin3lHdrbclXiAG2vkveyKdg1OrkCsizSUc91RacDAjTlfuHWMTkRvbNTaHQUtWGdi co7+o4tgqrniRa/JicVg9a71dmncswXDk+USZ7YO6rUGWwO+WHgcoqj1rRJvwkZyffmg ayLfJUZfiwCKnrXD/1oTIOY0zvNPDYoVw5dthrDge3CL2L4kLA/M0oRPNLHeTIIgJhzd Uu1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NBw5vlMSYDphuKB5VO9qUzXDvK0V7Xr95Q+k+nN/f84=; fh=GCqGrws+MgIy7TDj0DbaHKdqX1BOXKj2FTlZm+3riyc=; b=mcRgoXz1rLKf64O6vxbaO9e0huLtc7IwHvx+wJFimhLI5BDv0jY36KoPDTF3cgHCxe GGC0pV4Cm7e2U+v8eB73w0fP12LZ0YmHBOQgODY1lYUUA6V0IHH0iowhZlBMxz0CIWJw t8BXoMDa7/mK02Yin8Drn/8U3xwLM0JR4EO+/N1yR/47CEglK9sOZx40Pfs0mBfiC/Px B69PuUnS201QBgI39Edqra+Kyp43R0+pi19eCPvVGde8uuQJzJkHboC1iAmzID9Phcyc QP56vdavhvKeWaQK7FrdkbqmyJOBnJZI2gjoDLDIlnpkqsubGhTYqTSrq0azvp8ggy27 Imbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=N3bMVT0Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a17090a1b0c00b00260a7aee610si2451628pjq.152.2023.06.23.14.40.24; Fri, 23 Jun 2023 14:40:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=N3bMVT0Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232867AbjFWVQD (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:03 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769531178505388038?= X-GMAIL-MSGID: =?utf-8?q?1769531178505388038?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/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); } - mm->ggtt_mm.host_ggtt_aperture = vzalloc((vgpu_aperture_sz(vgpu) >> PAGE_SHIFT) * sizeof(u64)); + mm->ggtt_mm.host_ggtt_aperture = + 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); } - mm->ggtt_mm.host_ggtt_hidden = vzalloc((vgpu_hidden_sz(vgpu) >> PAGE_SHIFT) * sizeof(u64)); + mm->ggtt_mm.host_ggtt_hidden = + 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 patchwork Fri Jun 23 21:14:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112326 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6053486vqr; Fri, 23 Jun 2023 14:37:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5rzKn9XG9jqofYMM0uff3XuZHGkkYgyRzCCAqIZH2RpJ6nI8SvgbOfmsJ6Kv4H5tQn0RD+ X-Received: by 2002:a05:6a20:442a:b0:110:6146:1056 with SMTP id ce42-20020a056a20442a00b0011061461056mr31872533pzb.2.1687556226660; Fri, 23 Jun 2023 14:37:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556226; cv=none; d=google.com; s=arc-20160816; b=mesHecsyfj9I/nM4MrmHrwPi02TFUuJn2sPTGo79cfvrQfpLBgTGewdkUMMiXaTiIO uUfA0Bw3SNvg35T/eBE7dVExQ7Yh78tOA+su7QalFc+ZZTJYplF9rZXllvEEUsThvzt7 un3Oj4UmIwS69kvfdOOTHc2yCYLWfiza2FDb8ggdoVXTfIby0D6tqro8H5Fr8kb/h/Qz 46nAdyQJJmnYWceVmQ7/r2YptdSNfeOD9/4a3LlQ6xZYBcZSBI8alknsSgfbLfEDjGcK MI/AeOaF+NIVYLy0Nj+G546pEV45QIjM3y8r9UtTKtgH6K/9sqWpKP3uhV5dIo3P2CYy OUzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wXbBUetUKejFi8ORS1ZEmLv+CVaFu9wgVarZrNCtRDg=; fh=OYPk5F6oFlY7JcywgF8It8VTSZdtQYKVtptLL44VnkY=; b=W6ssVV+xawPCcz6h8D2UbwKW2flQgHeRGKrreiLHnOqbvWhj9ibofYZiYVwpJTWq1/ S77tfS6qVezPmMrlPzLztfixY7D7+TAaLLewlc0Y6PSAckKa1JjP+5afxh7d0n1ENibt Bi/p0Byd3+O1hiPGTeXduMMUnFdPewBGZMoFmIvjX6Bpq+sZNBEugv9/6T9r81n1XEZR H1QfVdYznu06fWyoLelT3cCWBDfEGA9xO1PUQKCTl6d87OqwDQ7hEz34d0QYJbeI58t3 cc9JWyssC3o0cwJ8iW0YcrqjqeWosjJAlfxLDXptKvZIbWysr4ejYGbkSTkp8PA167co XA+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=A7nI+7mm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z30-20020a056a001d9e00b0063286f81d35si35655pfw.262.2023.06.23.14.36.54; Fri, 23 Jun 2023 14:37:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=A7nI+7mm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232831AbjFWVQG (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:06 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530958237602487?= X-GMAIL-MSGID: =?utf-8?q?1769530958237602487?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall 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 = vmalloc(size * sizeof(unsigned long)); + area = vmalloc(array_size(size, sizeof(unsigned long))); if (!area) { kcov_put(kcov); return; From patchwork Fri Jun 23 21:14:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112337 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6055566vqr; Fri, 23 Jun 2023 14:42:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4PPADxXgiDnITk4/aDeS78A5/S/v/+pv/c8in+ATkvblqDQf4PK1pN0HQfdde3fdKJ3hxi X-Received: by 2002:a05:6a20:7d9a:b0:118:95f1:5a78 with SMTP id v26-20020a056a207d9a00b0011895f15a78mr19303396pzj.31.1687556564145; Fri, 23 Jun 2023 14:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556564; cv=none; d=google.com; s=arc-20160816; b=KumV8gR2AS8TwW+2HXaSKr6yBrvO6+1Sil2L7BOnarHzgC8sOrKs7zIqN/aTGlge4j BcaNnvYYO5lgQTkpHn+z4dV0AxtxCM6EwqjRz4YHC1zXzi7CpAA1LFIM3w1X8dvYtEPn PMoAT4TTC2uRGSfdCxX/SqymxtGqf+0AMgS+cW2oGEVI8TwRUZsEEWXrGG/OwOgc1v7T qpewyqDmmvn/OCJK3I078RdxbDKEGoLhq/tscvQF9fuXvLVa9V/y/u21DYx2Pr+szdbY e2q39UNh1HpywEXLpOngxUyvo9NJDVJweeoLqv4la2yymJUhLc6KIjmiSiyNtoUDy0UN bYnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1b2qOiijM2SOFY49y/T4nNKOOzZTttGdtrLG5Lh64bI=; fh=0ygwvk59cds318uqho8S6soxx405nxeWPfQubYxJsD8=; b=avSC55nzzUBGnE3w1Z/FA8fYLUnuu/CsUxrHpoiCJbkUGVQ5hzevpGNWhBxoGbzmya Seh/3loL+KoimuyQ6TGPPbTT/0XOr767odiMm6kPjjR4XUkGPytSQzrPGogaLjDkfZmn xgLxR9SEWmSngcY2UaTnliowXPGnWcKCM0ciVK+PnMhs0F31okU4HD6nskAOrdYb/qVn Qbh49ACoL8XTiY/9kpEasVyA2eGb1sUl8jPMyu7AkvBeVmFQkg/7ccHnvmzWr8LiKlqX QvPQRuuC4jBuj9U6DlNQfF+jKvWCTkA3SzmuNdRc/vWoVKai3badjr/+QkcrNTTcE6k+ Jc5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=uyu8z8wz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w136-20020a627b8e000000b006689f89b186si41985pfc.208.2023.06.23.14.42.31; Fri, 23 Jun 2023 14:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=uyu8z8wz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230264AbjFWVQK (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:10 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769531311896078509?= X-GMAIL-MSGID: =?utf-8?q?1769531311896078509?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall 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/ethernet/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_resource *res, res->bd_count = bd_count; res->bd_size = sizeof(union enetc_tx_bd); - res->tx_swbd = vzalloc(bd_count * sizeof(*res->tx_swbd)); + res->tx_swbd = vzalloc(array_size(bd_count, sizeof(*res->tx_swbd))); if (!res->tx_swbd) return -ENOMEM; @@ -1878,7 +1878,7 @@ static int enetc_alloc_rx_resource(struct enetc_bdr_resource *res, if (extended) res->bd_size *= 2; - res->rx_swbd = vzalloc(bd_count * sizeof(struct enetc_rx_swbd)); + res->rx_swbd = vzalloc(array_size(bd_count, sizeof(struct enetc_rx_swbd))); if (!res->rx_swbd) return -ENOMEM; From patchwork Fri Jun 23 21:14:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112328 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6053730vqr; Fri, 23 Jun 2023 14:37:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ40eqCTzqIjx03IuANeFxce0tunJ81yk5ivTd2mgXlRWV/q8Xpv2wIkY/tdS/pDKkpZFH0G X-Received: by 2002:a05:6a00:99c:b0:668:6c2a:c4e3 with SMTP id u28-20020a056a00099c00b006686c2ac4e3mr16689476pfg.13.1687556269134; Fri, 23 Jun 2023 14:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556269; cv=none; d=google.com; s=arc-20160816; b=TXBABmY+SKURTJKtSIgnx41cxE9MjqMIKWC+UzfDIVlT6EPSKJN056PtABjmxvR7IL OZX24HCQI4xNogZ/4aK5DCUtlwHPY4tAsADI+nW6Adu6RPUhDCgHPTWa9nSOHycVLXE6 wJDIVyGNuuynus4Z91JplXOL0Rxo9BelA8KT4KZz/y5bcd03phPT/GKQ5ZII5GV0F/Fk iEaUy9PMKEs7ihhHxsbqcLzbwcr0GegN2lxGwwZsXqp/VvxQZ+ovrqdQ/xjKjvM+ALLN tsAg+1SCkKMHvBfKLXSJcQPlkl82rObitkugjcWJx6VcJf3WuZBiUiZ8bNC3ioFtgwXS 7nSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8RgN37sI7dQZ+yBNJgvV+FVERbz2KA6A4JGbVoPo1D8=; fh=4GhRN2p8jF6l7uhi+UJ/CswsbaxAF4Vi9m+VjlL/GZw=; b=kmjJBHmxDXF2E1+bZWPnG+ud2zvpF7FIoMwodztSfSp+qfo77QpQPnEbpttuwGWue4 i4+iTx4QclzziLkPlaxbCSLOTihk872APkKgPyUBfvYN3/WJkntzgNXLpyCUabfuvTXo ULVLNEHXY7QsPIdJh7cPlTReTVvIllV4wua4BpT4ACinDXYksi/lnzE8W1AyMD4+WaMz 55tOP2gAbtcJKRHdNiFv7zfSNjZPRxkyRcFU/tzIc/Dj2MkVuFYr2sMkYyRbRSDsVNz/ hpvOXnmOoLgvfIFOqeuC086nFKJK35wYvGDCnMtaLYTmU9FXJ2sZOwSkO9NtQvsyUHcT athQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=ZLSOgmbf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y31-20020a056a00181f00b0066885c2a4besi69691pfa.65.2023.06.23.14.37.35; Fri, 23 Jun 2023 14:37:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=ZLSOgmbf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231947AbjFWVQU (ORCPT + 99 others); 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769531002426541880?= X-GMAIL-MSGID: =?utf-8?q?1769531002426541880?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/infiniband/hw/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 = sginfo->npages; /* page ptr arrays */ - pbl->pg_arr = vmalloc(pages * sizeof(void *)); + pbl->pg_arr = vmalloc(array_size(pages, sizeof(void *))); if (!pbl->pg_arr) return -ENOMEM; - pbl->pg_map_arr = vmalloc(pages * sizeof(dma_addr_t)); + pbl->pg_map_arr = vmalloc(array_size(pages, sizeof(dma_addr_t))); if (!pbl->pg_map_arr) { vfree(pbl->pg_arr); pbl->pg_arr = NULL; From patchwork Fri Jun 23 21:14:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6053872vqr; Fri, 23 Jun 2023 14:38:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66QhsTLxvQgSe7eavDmwdT27nSlv0n05a7Y37FtmoRjpEtuPopJ0u6wcSDEKgk7gxWWqVR X-Received: by 2002:a05:6a21:788e:b0:125:b0ec:78be with SMTP id bf14-20020a056a21788e00b00125b0ec78bemr4360513pzc.10.1687556283535; Fri, 23 Jun 2023 14:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556283; cv=none; d=google.com; s=arc-20160816; b=PYjIZ1QwIpRG8EjVSWyt78slyrNqdLjidPPyGEGxJ3XK4PRQlCwiYPGxVRFdQcru5S 9EWVbU9SOkmDttWutc1IDIDviU7HDzWjDAb/WJyaaDrKsJqA/gng3CRBx2fU9OR32J1G Hovh92oPjclIF45/aoyQ68AsOW3nyMAM+virkbYe23O5CM+tRxyOzuXATSHls9KXeh6N n8owzC82zoA+Vy77Q5DMEwN+tuGQPZW0g5YeJClUxLvTa4bhSgR2PkB04hfRLDsLgxWx Kxxn9gQaPR/jpdzcT2TI1TPHbDyD2aQu+BYxhoWDI0uJ86yYjoObykhE0bXSxq5IQBq8 D3Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jammjAxbCgbnRHLqhi6UIftAryvqKnOHjwdJrbKzjag=; fh=DE1wrYw37yRMyqW9rtnAxlFdtA+6nyPKla9TFht66fc=; b=GikxxejsXS60wNmNpB10HhW8ofiKsHGzlGPKQ3re0b+cjq5nfL5vZgbgRElz0pprAz yjwsKiZb8cMW64nbAs9Vl/lnTbR3dTXQL+/g+2Kl1kILrKWQbmMdD8pimOmnxRAZfeJP YfPWq8dGid3U2FtvJTEfsmb9QELpLqcAxNE6KNJ+QzfRnvgrOl4fpiBGpLsL85ZMCUcp +C+WBElb+en6ttRVaiyGSoq7dChAh78qMxgqbEqaNC+TSOtMGP1nFrJkRfPH9tU72ki4 CRZm/uAqn74DwJ4h+Ottro7D8BuUlGVnQORTdvbPPzMrt6yOA7BKfqXsG1CZVIgrvkUX LTQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=Z47OQtnP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w136-20020a627b8e000000b006689f89b186si41985pfc.208.2023.06.23.14.37.51; Fri, 23 Jun 2023 14:38:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=Z47OQtnP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232924AbjFWVQW (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:22 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769531017477240211?= X-GMAIL-MSGID: =?utf-8?q?1769531017477240211?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ size_t e1,e2; expression COUNT; identifier alloc = {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) // Signed-off-by: Julia Lawall --- 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/vmwgfx/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; if (gb_objects) { - vmw->devcaps = vzalloc(sizeof(uint32_t) * SVGA3D_DEVCAP_MAX); + vmw->devcaps = vzalloc(array_size(SVGA3D_DEVCAP_MAX, sizeof(uint32_t))); if (!vmw->devcaps) return -ENOMEM; for (i = 0; i < SVGA3D_DEVCAP_MAX; ++i) { From patchwork Fri Jun 23 21:14:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112318 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6048690vqr; Fri, 23 Jun 2023 14:24:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5OKIXog5x8ObYCP1sCB8Omyseh6V9fHghQ0ZTEKQRzKJWVGVb2XB71OmyNggmh2y/Kas90 X-Received: by 2002:a05:6a20:1609:b0:105:2e9e:b13a with SMTP id l9-20020a056a20160900b001052e9eb13amr25299023pzj.8.1687555485169; Fri, 23 Jun 2023 14:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555485; cv=none; d=google.com; s=arc-20160816; b=QxlPjl2TZ6ThhDLC9vSqSSyGDxZIKSqmv20aAD4DySPF/StaWmVmFC9lUNOpmjBMWe EGKUUge7LrQTzPhXvcLrMxciTypbqvgHnlChb3Og0sOpj32UFxEL/xTfUAuXPLl7uIvH P5ATz8Kq+9BCPrjy3R7+DlMH8RCtGd9zmisFmx9hRIUKMaWtHGz2g6cvwC5lmeuEhuvo qVsj+ctqxAETx/vXOWiTD7Ds0PLxHZ39RLvQj3FOkbnufDsGwB4fpWLK/bfSqFyMTxqn S1rDHAUe3FeyGk4KhICwgT+qTty4dVtDyrtZaAK5RFYtIT3hnsIF5GRkKo2RjmLm4eMJ DgCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qV5G73GxtezcE7jW6SYetBuixStXGKiX50k7hlLQiPI=; fh=1WfTt7ZQ2PCyDexWEgjrvClpa/X0h2q3omZne/wztD4=; b=Y63OcYCRVy1zpAhhu/lv9IHrKLPTB3rXCYwXkQ3lEqf5upJQ+6H8CcfedhJ6WrI8GL Uhud/ruW8K7rauygmWqSd6UfOhuE7s8eTnDhPDsnlYoaR8I9Ig/OxeHDkB7ity3QPArb rqLWA6rPcdfp00CXyGKk7vNdaM3VaLgXRTGQa4Hr2JzZNvwN+kgCdRrp6hbAp440FxEe n+riz8QFRX+yFoecoiOSXQWFX8F/BIV7akWvURl9iJ0/6SQ6htgqHYwZc+eY/keRgll5 xeSez4cTE2OKhDCN7r/VNiNmTaCKntIskWrTh71D8HeOpiAjNVlsRqILcUyqmsFq1hPD /izg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=D51bNxx3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx15-20020a056a00428f00b0066a48cbde7asi28053pfb.190.2023.06.23.14.24.31; Fri, 23 Jun 2023 14:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=D51bNxx3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232938AbjFWVQ1 (ORCPT + 99 others); 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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530180284973927?= X-GMAIL-MSGID: =?utf-8?q?1769530180284973927?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall 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; - section->pages = vmalloc(nr_pages * sizeof(struct sgx_epc_page)); + section->pages = vmalloc(array_size(nr_pages, + sizeof(struct sgx_epc_page))); if (!section->pages) { memunmap(section->virt_addr); return false; From patchwork Fri Jun 23 21:14:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112312 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6046516vqr; Fri, 23 Jun 2023 14:19:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7BfsJh3sesVAgVMLFeWkU2BoOmP2gui05orKJH0fTEKppv+bloCKOZg88k1DRIyAfE6HBD X-Received: by 2002:a17:902:da84:b0:1b6:78a1:93c7 with SMTP id j4-20020a170902da8400b001b678a193c7mr286773plx.39.1687555180921; Fri, 23 Jun 2023 14:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555180; cv=none; d=google.com; s=arc-20160816; b=l+7/C+kRjWNik7rfqPktxPIEU2JtuTwz1FCOHzlOSU+9xo2M/2+k574DUVgld4EKME KM3/JP2wYdBkWPVBiv4p6NJ1iBgeaFV0dUCh/MzMDQP9QFeoziREWScGtlcgDAcgQLy9 l7zFSuksulcioiMsIVUwrAsmOo1OcWzUFdWTDmuXQ+UnwL8Lx6q270+A0c/TgtaqmDCA pl9yESi+tc//xWtVF0zDAtRFaCoYWvwZvJwkG9TH4CbhzGRf0QbTDJ4SsU8mGBhO2kZD 9OtMzan6PPBsyl6XxLNXlttqupvjVlvNsuPSqcKMP8Ya4xasd0yHJrmv0MTr8wzvepqL fRaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6pln8KBe2ITtf0Rjafl/GtS76k6Cn8LbOnTYdoKfe3I=; fh=m3wHYztPG1Z7IXi0XlhdTZNDnFaSzXWtQpM9ZHCRd/0=; b=S7SopIaSsKxBJSscm9Y7OWmP9i4ZdDAniqqyYfcTL6Jv+6i3fRF1ql/sb8AwM/XAwx PcziAeCAyFtEOcT54hAk9UXPC3fENFIg929z7x9pgGlDBi8OYHUhXmtocqC2HDLeWK4r RNC9HaHVvw4mfFznQBSS0GpkoHDlctB5UylujRdbgzKJIrf7ryBclos+b/FzPTcxL4vA kxAivNJo3pkTdv0Drf2X7OxM9yy9sN/fWYXNW0G8rYBtb1w67TN8GdtsFvT90kZHv/d+ 2sDmJnS5bn3tx7bnKxpQ3u9WDlw+lPm5ocmqXY06sqrInUArTJ1wUgZgCVaKoctqVRZ5 ZMaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=pKNmqBiy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf11-20020a170902b90b00b001a68f933777si50629plb.245.2023.06.23.14.19.28; Fri, 23 Jun 2023 14:19:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=pKNmqBiy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232944AbjFWVQa (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:30 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769529861444629323?= X-GMAIL-MSGID: =?utf-8?q?1769529861444629323?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall 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_context *gc, u16 *q_depth, if (WARN_ON(cq->id >= gc->max_num_cqs)) return -EPROTO; - gc->cq_table = vzalloc(gc->max_num_cqs * sizeof(struct gdma_queue *)); + gc->cq_table = vzalloc(array_size(gc->max_num_cqs, sizeof(struct gdma_queue *))); if (!gc->cq_table) return -ENOMEM; From patchwork Fri Jun 23 21:14:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112313 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6046702vqr; Fri, 23 Jun 2023 14:20:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6D9JD01Mvqw3ohr0ozb6l7xKgFHuE6suTrNDyHzXr49MM1XAd1tyWi6bbMaB+s3w/xhKTy X-Received: by 2002:a05:6a20:2588:b0:106:5dff:5db5 with SMTP id k8-20020a056a20258800b001065dff5db5mr38305082pzd.1.1687555207222; Fri, 23 Jun 2023 14:20:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555207; cv=none; d=google.com; s=arc-20160816; b=qgn/kpzEMcuhcX8ONebV6M6+Zr8T/7/TkpeTV84gbSu+L0KA+CsHBooQy0YWBqBy0Q P2pYnXnatghV6l6p/MD3dIkn69upXFhsDSXzbF30OvU1U0WBnJ9CvqksCMWrmIDC8Q3P AZpf1hGj2Y164yMRcUtooUPgeUSgQx7bMV84j46OOkupkglm7aW3ID0XCcC9B/ImRvFk Xx8FUoKflM6n1onhjzfrlNW1lPm05P+52zu8IF0nQZlYxqp7SDqpgKYs1pQhOxYXBxIX JSCgVLB16Fcy1imW0gUEthRrlBsxIJ2UHzjOw/kmhRzTaCh7tM+eGLzZz0a3hI6WtxR9 O+Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=W1WB9Wb0BvRRcBkbSVITYF4i4Xscr+EN0kvgwOJ6wOs=; fh=Rdk+OWmudmdPt+m21oN6e9kPfmvlv0u9RO9HC7/sCwc=; b=ssZvChMAHClyDoQ/bbl/8eRhUhGhE0kdQy2gV/pKq2ytimGjaANVfP9wb/o4k3UP4/ wOBKj2FOlkg3Nzo9V+iiSpu5g+73zmpzXzIgk4nwKcDsewoCwmpMfNcf1yMAKE3+ZcFm Q+eSHLXYbNEUg1hfYaH35dSQAGYu8A/qBledyVGiVysR3413lX2XWS+1HZSLkYkRm5XA x3ak28SXV7iLTrl7ac7vBZ0yAHM0HbNsm2/q3Gqbs6JfYPobHBq3EWD43vk50eLxVh3l dSz/GxXsc2g9C2KFUThau0Q9kIGMXyxJa4Xhis6K9bbEjOG0O5XL4Kv2UNhllNqyy0/w kF5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b="WmG/JpBr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q37-20020a631f65000000b0054f73ee92basi280155pgm.8.2023.06.23.14.19.54; Fri, 23 Jun 2023 14:20:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b="WmG/JpBr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232951AbjFWVQl (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:41 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769529889227792498?= X-GMAIL-MSGID: =?utf-8?q?1769529889227792498?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall 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 *parent, void __iomem *base) * Allocate the array of L2PT CPU pointers, initialized to zero, * which means the dummy L2PT allocated above. */ - mmu->l2pts = vzalloc(IPU3_PT_PTES * sizeof(*mmu->l2pts)); + mmu->l2pts = vzalloc(array_size(IPU3_PT_PTES, sizeof(*mmu->l2pts))); if (!mmu->l2pts) goto fail_l2pt; From patchwork Fri Jun 23 21:14:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112315 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6048652vqr; Fri, 23 Jun 2023 14:24:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6QzkzsqfnV70avrLBU2vfiBIxbK8Ep6+yItl7AX8KkPzp5UL1d3BfcgxDeJSh7/G7N42/1 X-Received: by 2002:a05:6a21:900c:b0:106:25b3:2f92 with SMTP id tq12-20020a056a21900c00b0010625b32f92mr14662360pzb.52.1687555479817; Fri, 23 Jun 2023 14:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555479; cv=none; d=google.com; s=arc-20160816; b=M0S5nPS8gm3MOI73qJq6X0ragOvbafuoZNZBOvowR0nPHMseJzI/Ur69uPA43n3GEI iNVcb4uzG11nkElHrPavX0cEgCZbAaQhwTlM91SYJ7ya7FPvEUydKzKVqOlLH/NbEDQO VAn4OfKKuS+qOAmDu8TKT9llid2K4CY4lM3fY3VyleZPk2ae8Tbkg1vXPBBkLEjm5rzB dHz0ET7pWgFMi9ALBmk64jQiVg7B6i3y0dY49gM+D+hs0t7cy9lk9ot+p0m9ei9yjoVb U3wuPLcJL+15ibvj/+CPtFOT/2i80cbRX1+Iwb0Bu23W/6J9ZlZEIVO+hQd3clPrxnyb kjew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CxJuiiXcSlU+s+aK2RdCGaJm2rWe7fLo/P4JyxZmwgU=; fh=OcI2ar8rmK11afESoLyKrSp1zPZ4RRBBhD+T3FlUyqQ=; b=yd8sGT4JjzAQMxFn5UioJ3TiNYaA34P7Ws/UBIzfiz72Nf9ywySFi3Wky8uZ6FPrJk 5yjzs/llX5UzWnoaWOWzg/WbsgH6vvsxNhzenWjwbB8UAaHyXdhmSe+LFzCaCaj2/o/u 2tvXixEYzE8+w1oq9ilFWzBKhtNUDglM2j0ds4Qn2Jlemqe/sxKE6XwSIBKekOaH7diW SvR7iVQR9V2LZhvnlQZrhufO1PunbvFIVhvGN+ZfOPrVXdI8drx7spTZM1G7pi4R8JH3 oFfrAsSvLfsz+MAHsAbzMiNSkURl2n5qvkSH7p+sQifBBoC5arqq2Uo5Nes/5fCaJho8 94UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=Y+TGJl9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k17-20020a056a00135100b00653c0edfd34si46346pfu.139.2023.06.23.14.24.25; Fri, 23 Jun 2023 14:24:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=Y+TGJl9k; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232521AbjFWVQp (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:45 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530174603900768?= X-GMAIL-MSGID: =?utf-8?q?1769530174603900768?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/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_init.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 = vmalloc(risc_size * sizeof(*dcode)); + fwdt->template = 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 = vmalloc(risc_size * sizeof(*dcode)); + fwdt->template = 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 patchwork Fri Jun 23 21:14:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112316 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6048658vqr; Fri, 23 Jun 2023 14:24:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5BX9w8aMrajbz68XuO9/KCVOsDcVkjNc+2d3J5CNX6IDYootWu9Kt3bjOjzESDfNDjOg5m X-Received: by 2002:a05:6808:1450:b0:3a0:34c2:646d with SMTP id x16-20020a056808145000b003a034c2646dmr16084102oiv.21.1687555480448; Fri, 23 Jun 2023 14:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555480; cv=none; d=google.com; s=arc-20160816; b=Ee4p2VRs7nmjA8a5/iIxVlxJFCY11LbhRNR8F8rb6G5vnGR/kWVqPwXX3TL7hSTCcA StGplH/UINzA4Vxo1EjLB94nEYXGDmtjBjxek11E2zelRnxdXjRUkEkLwoztWv37wrt7 UEkGGA/dYrKIemNBjpVXqhwnseM5OOzGFPQYHVx/giND1x8nS4Tc0Eo8L9aosquHTVLN Wx1PkDrI+LjwpUrhfp3dNwTszKFIFzGdCMXv+H5VL/ojoWkAcDReKj8icNiED3BqkDfp Jjg6NfodAx5eN2tO8M+C26/9AaFL9H1yUsneZXAS3VhgKDKvJB8xlUwL60TI9R3MaGb4 aYsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QVL85YxfC9lZXDIeZBFhc354vgfWwHTzh6yW0KOYvK4=; fh=/dLKWv2g+MHt+9pGlXbIrGjHgmTrgFG7i3FAhq3mKZ4=; b=eTOmQ64dFaLl6pJ/9ZormK5hJtP5IebahJ47tv7isYcGOLzxJG+s5c8RnYb5q9dzT5 JCBFigsnTTh8iLfJOLqDZ9yOua9VHoBYiSAadOo5CikT3ri0fgmEG5J83iaQt1ymBD4S Vx6oHdMvg8qRCHELVBE2/Kgddga8MRYS/A9jebce817Xn0KPTCQ9r5UoOqgUpjN58spE MoKsUd8ddg1HQifCXoAWepPuHgyQWbDMQ+aREnwXKNsi6WDFeTDogvjQiTvK3r/oCiME oQQOUVWrteAdbFAzcKaIMj5b7LdLzVsqIgOlGB4nvcsImo4YetdmXEL9XbGxrW8OsVhD JDzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=obHoEbEA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b10-20020a17090a8c8a00b0025337db9e19si314474pjo.156.2023.06.23.14.24.25; Fri, 23 Jun 2023 14:24:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=obHoEbEA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232866AbjFWVQs (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:48 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530175486048160?= X-GMAIL-MSGID: =?utf-8?q?1769530175486048160?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/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 bounce_size) domain->iova_limit = iova_limit; domain->bounce_size = PAGE_ALIGN(bounce_size); - domain->bounce_maps = vzalloc(bounce_pfns * - sizeof(struct vduse_bounce_map)); + domain->bounce_maps = + vzalloc(array_size(bounce_pfns, + sizeof(struct vduse_bounce_map))); if (!domain->bounce_maps) goto err_map; From patchwork Fri Jun 23 21:14:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112327 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6053587vqr; Fri, 23 Jun 2023 14:37:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ486uGVy66QSTKs94L7k3YSYuwrjblj2SfVla3KHF8DAVHWWi9wf7naXUGryx7JDLDdbj7v X-Received: by 2002:a17:902:d543:b0:1b0:7c3c:31f7 with SMTP id z3-20020a170902d54300b001b07c3c31f7mr302406plf.28.1687556246545; Fri, 23 Jun 2023 14:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556246; cv=none; d=google.com; s=arc-20160816; b=rYjTdV6DVuZ4jvl3ypU7hYdksLdF71gSJbFf75YUUTM7C6oZvRZxV7eBB8nWdw83eJ b5ISejDFek2KRkckYRVrznUfBHM1Cy0qJ6lPKya/3g8hVELbPVvegZgGfqpVp6YFIdl+ ixTvN2yMJInUPhHHJtpEmgLdBV5QxmCCIFYqCj2BR8mcntnpCNWoCicyDSQmWrHN6W21 Lqx11vcXc68XyTERIKFtc/pK/JCStE9pqiFGAV1Sehu+G9+GDNDJVCTwx9EYpS7y2BYc sBs5swODnpJ2BB6ojyqPtzN/qmV5Ld1JO7Cj2nZ/UPoAV5VP6lH2qmZpX++Ub3bmuO95 NoKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zjTOkHzHNJN2JwbbSn0B3jYr0f7hFN0oZZoh6lbquOQ=; fh=y0ETFeU6w6trYMg3qM1hoduOKRqZ5aMgSndi/hTfcWA=; b=RgHvQAmg/n9jdYEIxHfIHGFUI0P43D3zRlvygMcARg9KZQmX1phl9BeBRmD3I0mOg4 e94pwGZNQMh5uYBrO7DOqhopfldKMIvc8isgal2Ro16xuV1BYoxMcMaZBhdx3HJki8QI PBX7s7TvvDa5Vjv2w2YB8+jwX7F2GkJ39hPWPVn6QaQ2KETNrTRrtArPBoVLI3OcRq0d Dfv65RB4+A+OIRQnSP9mQMOiqBoszMAQptNpZiuxDjbp+h16fAQXFI0bxUvVhxfAmyoW vqtye7u8sRd+wYiSyMkjYzFAyKZAFzIZASRZ4gOZE5p27NxLDjtKwNwfv4OC47iQabtC /VOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=FPVhggAR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a170902bd8e00b001ab1279d418si54564pls.474.2023.06.23.14.37.13; Fri, 23 Jun 2023 14:37:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=FPVhggAR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232893AbjFWVRD (ORCPT + 99 others); Fri, 23 Jun 2023 17:17:03 -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 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530978477526817?= X-GMAIL-MSGID: =?utf-8?q?1769530978477526817?= Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ size_t e1,e2; expression COUNT; identifier alloc = {vmalloc,vzalloc,kvmalloc,kvzalloc}; @@ ( alloc( - (e1) * (e2) + array_size(e1, e2) ,...) | alloc( - (e1) * (COUNT) + array_size(COUNT, e1) ,...) ) // Signed-off-by: Julia Lawall --- 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 = get_device(dev->hw_dev); } - bm->page_list = vzalloc(sizeof(*buf) * n_pages); + bm->page_list = vzalloc(array_size(n_pages, sizeof(*buf))); if (!bm->page_list) goto err; @@ -169,7 +169,7 @@ static void __comedi_buf_alloc(struct comedi_device *dev, buf = &bm->page_list[0]; async->prealloc_buf = buf->virt_addr; } else { - pages = vmalloc(sizeof(struct page *) * n_pages); + pages = vmalloc(array_size(n_pages, sizeof(struct page *))); if (!pages) return;