lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed,  7 Dec 2011 12:59:10 -0600
From:	Seth Jennings <sjenning@...ux.vnet.ibm.com>
To:	"David S . Miller" <davem@...emloft.net>
Cc:	Seth Jennings <sjenning@...ux.vnet.ibm.com>,
	linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org,
	netdev@...r.kernel.org, Eric Dumazet <eric.dumazet@...il.com>,
	Brian King <brking@...ux.vnet.ibm.com>,
	Robert Jennings <rcj@...ux.vnet.ibm.com>
Subject: [PATCH 3/3] xfrm: Modify xfrm_ipcomp code to use new per-cpu helpers

This patch exchanges the per-cpu transform allocation/free
code in xfrm_ipcomp for a call to the new helper in the
cryptographic API

Signed-off-by: Seth Jennings <sjenning@...ux.vnet.ibm.com>
---
 net/xfrm/xfrm_ipcomp.c |   34 ++++++++--------------------------
 1 files changed, 8 insertions(+), 26 deletions(-)

diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index e5246fb..d681fbd 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -245,7 +245,6 @@ static void * __percpu *ipcomp_alloc_scratches(void)
 static void ipcomp_free_tfms(struct crypto_comp * __percpu *tfms)
 {
 	struct ipcomp_tfms *pos;
-	int cpu;
 
 	list_for_each_entry(pos, &ipcomp_tfms_list, list) {
 		if (pos->tfms == tfms)
@@ -259,15 +258,7 @@ static void ipcomp_free_tfms(struct crypto_comp * __percpu *tfms)
 
 	list_del(&pos->list);
 	kfree(pos);
-
-	if (!tfms)
-		return;
-
-	for_each_possible_cpu(cpu) {
-		struct crypto_comp *tfm = *per_cpu_ptr(tfms, cpu);
-		crypto_free_comp(tfm);
-	}
-	free_percpu(tfms);
+	crypto_free_percpu_comp(tfms, cpu_possible_mask);
 }
 
 static struct crypto_comp * __percpu *ipcomp_alloc_tfms(const char *alg_name)
@@ -295,27 +286,18 @@ static struct crypto_comp * __percpu *ipcomp_alloc_tfms(const char *alg_name)
 	if (!pos)
 		return NULL;
 
+	tfms = crypto_alloc_percpu_comp(alg_name, 0, CRYPTO_ALG_ASYNC,
+					cpu_possible_mask);
+	if (IS_ERR_VALUE((unsigned long)tfms)) {
+		kfree(pos);
+		return NULL;
+	}
+
 	pos->users = 1;
 	INIT_LIST_HEAD(&pos->list);
 	list_add(&pos->list, &ipcomp_tfms_list);
 
-	pos->tfms = tfms = alloc_percpu(struct crypto_comp *);
-	if (!tfms)
-		goto error;
-
-	for_each_possible_cpu(cpu) {
-		struct crypto_comp *tfm = crypto_alloc_comp(alg_name, 0,
-							    CRYPTO_ALG_ASYNC);
-		if (IS_ERR(tfm))
-			goto error;
-		*per_cpu_ptr(tfms, cpu) = tfm;
-	}
-
 	return tfms;
-
-error:
-	ipcomp_free_tfms(tfms);
-	return NULL;
 }
 
 static void ipcomp_free_data(struct ipcomp_data *ipcd)
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ