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-next>] [day] [month] [year] [list]
Date:	Thu, 22 May 2008 21:47:34 +0300 (EEST)
From:	Pekka J Enberg <penberg@...helsinki.fi>
To:	kaber@...sh.net
cc:	netfilter-devel@...r.kernel.org, netdev@...r.kernel.org,
	linux-kernel@...r.kernel.org, mpm@...enic.com, clameter@....com
Subject: [PATCH] netfilter: use krealloc() in nf_conntrack_extend.c

From: Pekka Enberg <penberg@...helsinki.fi>

The ksize() API is going away because it is being abused and it doesn't even
work consistenly across different allocators. Therefore, convert the use 
of ksize() in net/netfilter/nf_conntrack_extend.c to krealloc() that is 
open-coded there.

Cc: Matt Mackall <mpm@...enic.com>
Cc: Christoph Lameter <clameter@....com>
Signed-off-by: Pekka Enberg <penberg@...helsinki.fi>
---
 net/netfilter/nf_conntrack_extend.c |   31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

Index: slab-2.6/net/netfilter/nf_conntrack_extend.c
===================================================================
--- slab-2.6.orig/net/netfilter/nf_conntrack_extend.c	2008-05-22 21:38:14.000000000 +0300
+++ slab-2.6/net/netfilter/nf_conntrack_extend.c	2008-05-22 21:38:21.000000000 +0300
@@ -88,27 +88,22 @@
 	newlen = newoff + t->len;
 	rcu_read_unlock();
 
-	if (newlen >= ksize(ct->ext)) {
-		new = kmalloc(newlen, gfp);
-		if (!new)
-			return NULL;
+	new = krealloc(ct->ext, newlen, gfp);
+	if (!new)
+		return NULL;
 
-		memcpy(new, ct->ext, ct->ext->len);
-
-		for (i = 0; i < NF_CT_EXT_NUM; i++) {
-			if (!nf_ct_ext_exist(ct, i))
-				continue;
+	for (i = 0; i < NF_CT_EXT_NUM; i++) {
+		if (!nf_ct_ext_exist(ct, i))
+			continue;
 
-			rcu_read_lock();
-			t = rcu_dereference(nf_ct_ext_types[i]);
-			if (t && t->move)
-				t->move((void *)new + new->offset[i],
-					(void *)ct->ext + ct->ext->offset[i]);
-			rcu_read_unlock();
-		}
-		kfree(ct->ext);
-		ct->ext = new;
+		rcu_read_lock();
+		t = rcu_dereference(nf_ct_ext_types[i]);
+		if (t && t->move)
+			t->move((void *)new + new->offset[i],
+				(void *)ct->ext + ct->ext->offset[i]);
+		rcu_read_unlock();
 	}
+	ct->ext = new;
 
 	ct->ext->offset[id] = newoff;
 	ct->ext->len = newlen;
--
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