From: Rusty Russell <rusty@rustcorp.com.au>
To: lkml - Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@osdl.org>,
Netfilter development mailing list
<netfilter-devel@lists.netfilter.org>
Subject: [PATCH] Remove netfilter warnings on copy_to_user
Date: Wed, 01 Dec 2004 16:25:16 +1100 [thread overview]
Message-ID: <1101878716.11835.20.camel@localhost.localdomain> (raw)
Name: Remove copy_to_user Warnings in Netfilter
Status: Trivial
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
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.
Index: linux-2.6.10-rc2-bk13-Netfilter/net/ipv4/netfilter/ip_tables.c
===================================================================
--- linux-2.6.10-rc2-bk13-Netfilter.orig/net/ipv4/netfilter/ip_tables.c 2004-11-30 12:45:23.000000000 +1100
+++ linux-2.6.10-rc2-bk13-Netfilter/net/ipv4/netfilter/ip_tables.c 2004-12-01 15:49:35.000000000 +1100
@@ -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);
Index: linux-2.6.10-rc2-bk13-Netfilter/net/ipv6/netfilter/ip6_tables.c
===================================================================
--- linux-2.6.10-rc2-bk13-Netfilter.orig/net/ipv6/netfilter/ip6_tables.c 2004-11-16 15:30:12.000000000 +1100
+++ linux-2.6.10-rc2-bk13-Netfilter/net/ipv6/netfilter/ip6_tables.c 2004-12-01 15:50:28.000000000 +1100
@@ -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);
Index: linux-2.6.10-rc2-bk13-Netfilter/net/ipv4/netfilter/arp_tables.c
===================================================================
--- linux-2.6.10-rc2-bk13-Netfilter.orig/net/ipv4/netfilter/arp_tables.c 2004-11-16 15:30:12.000000000 +1100
+++ linux-2.6.10-rc2-bk13-Netfilter/net/ipv4/netfilter/arp_tables.c 2004-12-01 15:49:54.000000000 +1100
@@ -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);
--
A bad analogy is like a leaky screwdriver -- Richard Braakman
reply other threads:[~2004-12-01 5:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1101878716.11835.20.camel@localhost.localdomain \
--to=rusty@rustcorp.com.au \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netfilter-devel@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®