Skip to contentSkip to conversation

netfilter: Remove copy_to_user Warnings in Netfilter

PATCH New Rusty Russell 1 participant 1 message Dec 31, 2004

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

PATCH 8/8 netfilter: Remove copy_to_user Warnings in Netfilter

Name: Remove copy_to_user Warnings in Netfilter
Status: Trivial

After changing firewall rules, we try to return the counters to userspace. We didn't fail at that point if the copy failed, but it doesn't really matter. Someone added a warn_unused_result attribute to copy_to_user, so we get bogus warnings.

net/ipv4/netfilter/ip_tables.c +4 -4
Index: linux-2.6.10-rc3-bk6-Netfilter/net/ipv4/netfilter/ip_tables.c
===================================================================
@@ -1141,12 +1141,12 @@
 	/* Decrease module usage counts and free resource */
 	IPT_ENTRY_ITERATE(oldinfo->entries, oldinfo->size, cleanup_entry,NULL);
 	vfree(oldinfo);
-	/* Silent error: too late now. */
-	copy_to_user(tmp.counters, counters,
-		     sizeof(struct ipt_counters) * tmp.num_counters);
+	if (copy_to_user(tmp.counters, counters,
+			 sizeof(struct ipt_counters) * tmp.num_counters) != 0)
+		ret = -EFAULT;
 	vfree(counters);
 	up(&ipt_mutex);
-	return 0;
+	return ret;
 
  put_module:
 	module_put(t->me);
net/ipv6/netfilter/ip6_tables.c +4 -3
Index: linux-2.6.10-rc3-bk6-Netfilter/net/ipv6/netfilter/ip6_tables.c
===================================================================
@@ -1222,11 +1222,12 @@
 	IP6T_ENTRY_ITERATE(oldinfo->entries, oldinfo->size, cleanup_entry,NULL);
 	vfree(oldinfo);
 	/* Silent error: too late now. */
-	copy_to_user(tmp.counters, counters,
-		     sizeof(struct ip6t_counters) * tmp.num_counters);
+	if (copy_to_user(tmp.counters, counters,
+			 sizeof(struct ip6t_counters) * tmp.num_counters) != 0)
+		ret = -EFAULT;
 	vfree(counters);
 	up(&ip6t_mutex);
-	return 0;
+	return ret;
 
  put_module:
 	module_put(t->me);
net/ipv4/netfilter/arp_tables.c +4 -4
Index: linux-2.6.10-rc3-bk6-Netfilter/net/ipv4/netfilter/arp_tables.c
===================================================================
@@ -948,12 +948,12 @@
 	/* Decrease module usage counts and free resource */
 	ARPT_ENTRY_ITERATE(oldinfo->entries, oldinfo->size, cleanup_entry,NULL);
 	vfree(oldinfo);
-	/* Silent error: too late now. */
-	copy_to_user(tmp.counters, counters,
-		     sizeof(struct arpt_counters) * tmp.num_counters);
+	if (copy_to_user(tmp.counters, counters,
+			 sizeof(struct arpt_counters) * tmp.num_counters) != 0)
+		ret = -EFAULT;
 	vfree(counters);
 	up(&arpt_mutex);
-	return 0;
+	return ret;
 
  put_module:
 	module_put(t->me);
Signature · 1 line
A bad analogy is like a leaky screwdriver -- Richard Braakman