From patchwork Wed Aug 28 07:10:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13780780 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0198B14F9D5; Wed, 28 Aug 2024 07:02:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724828537; cv=none; b=Z1sEe8wvpj/HykJuDALF3752bAZXbgp8g1fRb0sUxmYCwgDPJ94CCwttho6VWEJ4fcSofbZyX/G3CycChm5QeyKe5Y8njXw4EgGy8zkY7E4RXQEGcpCInfQRMIwOJljuE/neqSjf7cUfWc7XAMi/RXbOitR22MEe6mik3neU0Go= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724828537; c=relaxed/simple; bh=ia+QMXx6wK488wPA1+TuPYkqM0Y+z8p8bHzHWG6wQX0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LSC167M+zwUYDfgDhxnBxCOB96bAfAXRb7zxJmbJtI5gbQsl/SwwndglT2ujX+nr0Yu9YBnY5j8iWDKFx36cAtgM1IyV7N71/2myasx4paPpAe0lBoqS3LLLJpZhM6zKALS825RBvcB8AiwQTl74KUA25zaDQY/QroehCvzfIDk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4WtwKB2tl1z1xwRP; Wed, 28 Aug 2024 15:00:14 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id F0D771A016C; Wed, 28 Aug 2024 15:02:11 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 28 Aug 2024 15:02:11 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , CC: Subject: [PATCH -next 1/5] nfc: core: Use kmemdup_array() instead of kmemdup() for multiple allocation Date: Wed, 28 Aug 2024 15:10:00 +0800 Message-ID: <20240828071004.1245213-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828071004.1245213-1-ruanjinjie@huawei.com> References: <20240828071004.1245213-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh500013.china.huawei.com (7.202.181.146) X-Patchwork-Delegate: kuba@kernel.org Let the kmemdup_array() take care about multiplication and possible overflows. Signed-off-by: Jinjie Ruan --- net/nfc/core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/nfc/core.c b/net/nfc/core.c index e58dc6405054..cbc2f718aece 100644 --- a/net/nfc/core.c +++ b/net/nfc/core.c @@ -790,9 +790,8 @@ int nfc_targets_found(struct nfc_dev *dev, dev->targets = NULL; if (targets) { - dev->targets = kmemdup(targets, - n_targets * sizeof(struct nfc_target), - GFP_ATOMIC); + dev->targets = kmemdup_array(targets, n_targets, + sizeof(struct nfc_target), GFP_ATOMIC); if (!dev->targets) { dev->n_targets = 0; From patchwork Wed Aug 28 07:10:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13780781 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9FBC15B554; Wed, 28 Aug 2024 07:02:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724828542; cv=none; b=f5VFRGd2YFzqY+gmdtBJDuzqtOTxWa0RGH/o6/3zQ8s+bKcYGvkqok3i5FJnZE+I4s191AkZLvSBTJuQcuaRN+oEMhRSEH6IR11xkHIERLuE+V28q21/kOPNJbHdfnmNmaZNT5Y+8uSHqe2AXXvpostMWhOFmNxLdI5Mde/FqNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724828542; c=relaxed/simple; bh=cJa1hnS9lYVnIF4B8El0la0j95Um5vUaS2HneJF+CSU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Epam6rDE8dkNlUIETJPTgfCggLKJue0QdOEHsUinf65LPGScSLYw88pUwgsMYLNOINaCJwKEIywJtKVCJMaxpyXrZC4OTNc0klCSwLzxkzUqcvAC79AZicqM5vhx3uZfDEnKF+G83Sv3vuKsx6rGMbmMMnEDBsn7E/s+a2xXVns= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4WtwLX4RDMz13S81; Wed, 28 Aug 2024 15:01:24 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 8FB44180AE6; Wed, 28 Aug 2024 15:02:12 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 28 Aug 2024 15:02:11 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , CC: Subject: [PATCH -next 2/5] netfilter: Use kmemdup_array() instead of kmemdup() for multiple allocation Date: Wed, 28 Aug 2024 15:10:01 +0800 Message-ID: <20240828071004.1245213-3-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828071004.1245213-1-ruanjinjie@huawei.com> References: <20240828071004.1245213-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh500013.china.huawei.com (7.202.181.146) X-Patchwork-Delegate: kuba@kernel.org Let the kmemdup_array() take care about multiplication and possible overflows. Signed-off-by: Jinjie Ruan --- net/bridge/netfilter/ebtables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index cbd0e3586c3f..3e67d4aff419 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -1256,7 +1256,7 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table, goto free_unlock; } - ops = kmemdup(template_ops, sizeof(*ops) * num_ops, GFP_KERNEL); + ops = kmemdup_array(template_ops, num_ops, sizeof(*ops), GFP_KERNEL); if (!ops) { ret = -ENOMEM; if (newinfo->nentries) From patchwork Wed Aug 28 07:10:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13780777 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E327156861; Wed, 28 Aug 2024 07:02:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724828537; cv=none; b=J1OvGlzZLBk02nliKBX/4rFPz87R0CX99HHtH6blH9BqiYHc1MUJN/Yyed46F9UNViUuCv3OWO+6QNGvSrI5zKrx6QhUFCkbtRQGkj81bdzEG1temXrJu722m1jncW434TfQLbF7g0q9t2gJ9nWuid+aKsLd14ROYH/5JH4Ecpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724828537; c=relaxed/simple; bh=rYQw2GvYk4flPgoa97He4EIDk++8BnrTx7hCVEVW6bM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HnBWvrhmqU8kFMopI+LFdk7bTtZOkG5beHjGuRYK6kz2/emRrAIPqrasKGdaGNyRGr0AXC2GzqDs9Nx7T6M4sGwJ+hTS5BPOpGHqqttYGQ4ymYpmOtuoDxsfIQ+yEjdF3njwDzApnQAiCbanKQ1p9noF+owTYvFPnU7OSmzwvOo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WtwKW3C99zpTvt; Wed, 28 Aug 2024 15:00:31 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 37DDD180AE6; Wed, 28 Aug 2024 15:02:13 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 28 Aug 2024 15:02:12 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , CC: Subject: [PATCH -next 3/5] netfilter: arptables: Use kmemdup_array() instead of kmemdup() for multiple allocation Date: Wed, 28 Aug 2024 15:10:02 +0800 Message-ID: <20240828071004.1245213-4-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828071004.1245213-1-ruanjinjie@huawei.com> References: <20240828071004.1245213-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh500013.china.huawei.com (7.202.181.146) X-Patchwork-Delegate: kuba@kernel.org Let the kmemdup_array() take care about multiplication and possible overflows. Signed-off-by: Jinjie Ruan --- net/ipv4/netfilter/arp_tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index 14365b20f1c5..4493a785c1ea 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c @@ -1547,7 +1547,7 @@ int arpt_register_table(struct net *net, goto out_free; } - ops = kmemdup(template_ops, sizeof(*ops) * num_ops, GFP_KERNEL); + ops = kmemdup_array(template_ops, num_ops, sizeof(*ops), GFP_KERNEL); if (!ops) { ret = -ENOMEM; goto out_free; From patchwork Wed Aug 28 07:10:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13780782 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F46615B560; Wed, 28 Aug 2024 07:02:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724828544; cv=none; b=bns2v17Pz3W48SnFsp2VakvbCyRhWkNu4G1yDK8qtuSpC1462shHgFhhp7t+h7TFXnJ30qbxhiyA+Tuqrc2VpfmNyS4z8bg4MfCxAWhrRRp5gtKPhnN78CRCLHJQLxeSr6GmKf8TH/ZKqWL1pZLJ4CMUVfjSnG2/lRX9X/bd1ZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724828544; c=relaxed/simple; bh=KRea+Vl+gVbOaLY/HDCRVQFg8GITaziBqGbQ2FPwNY0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nxC4ZQJ/kOO4sQAQfZrNl15y9Fv9pog6l2VlgrFn6B002U12Bieb3q1E1bMNyKJEvEsa+ZuI1UlzXBB5CP3TND9T1X7PZJX2ZNipMM/Z/VGeEy1PRHmaQ05czZFhr7DBWwGlTQCFYdLpInCjFIbEn1y0cDwDFBY1zqNM47LiWBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WtwFw4Jhkz20n0H; Wed, 28 Aug 2024 14:57:24 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id C163A14013B; Wed, 28 Aug 2024 15:02:13 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 28 Aug 2024 15:02:13 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , CC: Subject: [PATCH -next 4/5] netfilter: iptables: Use kmemdup_array() instead of kmemdup() for multiple allocation Date: Wed, 28 Aug 2024 15:10:03 +0800 Message-ID: <20240828071004.1245213-5-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828071004.1245213-1-ruanjinjie@huawei.com> References: <20240828071004.1245213-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh500013.china.huawei.com (7.202.181.146) X-Patchwork-Delegate: kuba@kernel.org Let the kmemdup_array() take care about multiplication and possible overflows. Signed-off-by: Jinjie Ruan --- net/ipv4/netfilter/ip_tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index fe89a056eb06..096bfef472b1 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c @@ -1767,7 +1767,7 @@ int ipt_register_table(struct net *net, const struct xt_table *table, goto out_free; } - ops = kmemdup(template_ops, sizeof(*ops) * num_ops, GFP_KERNEL); + ops = kmemdup_array(template_ops, num_ops, sizeof(*ops), GFP_KERNEL); if (!ops) { ret = -ENOMEM; goto out_free; From patchwork Wed Aug 28 07:10:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13780779 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BF5F157469; Wed, 28 Aug 2024 07:02:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724828537; cv=none; b=OWvK9aqajlgumArSNiyO5XpR1ySJHhzkYr/e0NlJhjIKh125POaNnHWRKze4NGYLJ7flG4+CfzVOxxH5Iyu2f2rwBEG9b30d8tLHKSzpAWXwjx8zPnDx0tDMG3qLl6RLTQ/Q2GY0lFyWX2gRxp5aybtnxJvKAOuVasx3ZfLCYz4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724828537; c=relaxed/simple; bh=K6r6lzcghPAsZtTUPZXavYqG1W7fOtNQiqHEKMLSYgA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pavLn/3JNfiTIEjy4FqNQ3cyOOE5Z8JwoCDcNMEU2/X1upp4QBRb8UuHF8bm+yzwZQ5gKRt7GrCBE2fIwPjKt7X0e/+L1R0ibqU3+S5J0d7SXsmqh+n7THLQnfXiiZVpchqwlLb6x4ObPZRQD0Gef3xuDLO4N6UFP4QYSIfIz8E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.254]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WtwLw1m0KzyR4b; Wed, 28 Aug 2024 15:01:44 +0800 (CST) Received: from kwepemh500013.china.huawei.com (unknown [7.202.181.146]) by mail.maildlp.com (Postfix) with ESMTPS id 6459F180106; Wed, 28 Aug 2024 15:02:14 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemh500013.china.huawei.com (7.202.181.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 28 Aug 2024 15:02:13 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , CC: Subject: [PATCH -next 5/5] netfilter: nf_nat: Use kmemdup_array() instead of kmemdup() for multiple allocation Date: Wed, 28 Aug 2024 15:10:04 +0800 Message-ID: <20240828071004.1245213-6-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828071004.1245213-1-ruanjinjie@huawei.com> References: <20240828071004.1245213-1-ruanjinjie@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemh500013.china.huawei.com (7.202.181.146) X-Patchwork-Delegate: kuba@kernel.org Let the kmemdup_array() take care about multiplication and possible overflows. Signed-off-by: Jinjie Ruan --- net/netfilter/nf_nat_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c index 016c816d91cb..6d8da6dddf99 100644 --- a/net/netfilter/nf_nat_core.c +++ b/net/netfilter/nf_nat_core.c @@ -1104,7 +1104,7 @@ int nf_nat_register_fn(struct net *net, u8 pf, const struct nf_hook_ops *ops, if (!nat_proto_net->nat_hook_ops) { WARN_ON(nat_proto_net->users != 0); - nat_ops = kmemdup(orig_nat_ops, sizeof(*orig_nat_ops) * ops_count, GFP_KERNEL); + nat_ops = kmemdup_array(orig_nat_ops, ops_count, sizeof(*orig_nat_ops), GFP_KERNEL); if (!nat_ops) { mutex_unlock(&nf_nat_proto_mutex); return -ENOMEM;