Skip to contentSkip to conversation

use vzalloc() instead of vmalloc() for counterstmp

PATCH In review Loganaden Velvindron 1 participant 2 messages Oct 30, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 use vzalloc() instead of vmalloc() for counterstmp

counterstmp is not cleared before it is used in get_counters(). it might be leaked partially when it is sent to userland later on.

---
 net/bridge/netfilter/ebtables.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/bridge/netfilter/ebtables.c +2 -2
index f46ca41..26922e9 100644
@@ -989,7 +989,7 @@ static int do_replace_finish(struct net *net, struct ebt_replace *repl,
 	   the check on the size is done later, when we have the lock */
 	if (repl->num_counters) {
 		unsigned long size = repl->num_counters * sizeof(*counterstmp);
-		counterstmp = vmalloc(size);
+		counterstmp = vzalloc(size);
 		if (!counterstmp)
 			return -ENOMEM;
 	}
@@ -1410,7 +1410,7 @@ static int copy_counters_to_user(struct ebt_table *t,
 		return -EINVAL;
 	}
 
-	counterstmp = vmalloc(nentries * sizeof(*counterstmp));
+	counterstmp = vzalloc(nentries * sizeof(*counterstmp));
 	if (!counterstmp)
 		return -ENOMEM;
 
Signature · 1 line
2.6.1