Skip to contentSkip to conversation

allow ip_tables.h to be used from userspace

PATCH In review Stephen Hemminger 2 participants 4 messages Dec 5, 2006

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

PATCH 1/1 allow ip_tables.h to be used from userspace

The xtables version of ip_tables.h was no longer usable (in sanitized form) by iproute2 and other applications because sparse annotations had crept in.

---
 include/linux/netfilter_ipv4/ip_tables.h |    4 ++--
 net/ipv4/netfilter/ip_tables.c           |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/netfilter_ipv4/ip_tables.h +2 -2
index 4f06dad..0640c6c 100644
@@ -21,8 +21,8 @@ #include <linux/types.h>
 #include <linux/in.h>
 #include <linux/ip.h>
 #include <linux/skbuff.h>
-#endif
 #include <linux/compiler.h>
+#endif
 #include <linux/netfilter_ipv4.h>
 
 #include <linux/netfilter/x_tables.h>
@@ -194,7 +194,7 @@ struct ipt_replace
 	/* Number of counters (must be equal to current number of entries). */
 	unsigned int num_counters;
 	/* The old entries' counters. */
-	struct xt_counters __user *counters;
+	struct xt_counters *counters;
 
 	/* The entries (hang off end: not really an array). */
 	struct ipt_entry entries[0];
net/ipv4/netfilter/ip_tables.c +2 -2
index 8a45543..e75d467 100644
@@ -1238,8 +1238,8 @@ do_replace(void __user *user, unsigned i
 	duprintf("ip_tables: Translated table\n");
 
 	ret = __do_replace(tmp.name, tmp.valid_hooks,
-			      newinfo, tmp.num_counters,
-			      tmp.counters);
+			   newinfo, tmp.num_counters,
+			   (void __user *) tmp.counters);
 	if (ret)
 		goto free_newinfo_untrans;
 	return 0;
Signature · 1 line
1.4.1
#1 lore raw

include/linux/netfilter_ipv4/ip_tables.h struct ipt_replace · line 197

Quoted 10 lines · Stephen Hemminger

The xtables version of ip_tables.h was no longer usable (in sanitized form) by iproute2 and other applications because sparse annotations had crept in.

include/linux/netfilter_ipv4/ip_tables.h +1 -1
@@ -194,7 +194,7 @@ struct ipt_replace
 	/* Number of counters (must be equal to current number of entries). */
 	unsigned int num_counters;
 	/* The old entries' counters. */
-	struct xt_counters __user *counters;
+	struct xt_counters *counters;

# Eliminate the contents of (and inclusions of) compiler.h

HDRSED  := sed  -e "s/ inline / __inline__ /g" \
                -e "s/[[:space:]]__user[[:space:]]\+/ /g" \
                -e "s/(__user[[:space:]]\+/ (/g" \

I think this regex should be fixed instead to get rid of it while sanitizing (Makefile.headersinst).

#2 lore raw
Quoted 15 lines · On Tue, 05 Dec 2006 19:38:21 +0100 Patrick McHardy <[email protected]> wrote:

include/linux/netfilter_ipv4/ip_tables.h struct ipt_replace · line 197

Quoted 10 lines · Stephen Hemminger

The xtables version of ip_tables.h was no longer usable (in sanitized form) by iproute2 and other applications because sparse annotations had crept in.

include/linux/netfilter_ipv4/ip_tables.h +1 -1
@@ -194,7 +194,7 @@ struct ipt_replace
 	/* Number of counters (must be equal to current number of entries). */
 	unsigned int num_counters;
 	/* The old entries' counters. */
-	struct xt_counters __user *counters;
+	struct xt_counters *counters;

# Eliminate the contents of (and inclusions of) compiler.h

Quoted 7 lines
HDRSED  := sed  -e "s/ inline / __inline__ /g" \
                -e "s/[[:space:]]__user[[:space:]]\+/ /g" \
                -e "s/(__user[[:space:]]\+/ (/g" \

I think this regex should be fixed instead to get rid of it while sanitizing (Makefile.headersinst).

But ip_tables.h should still put include of compiler.h inside #ifdef __KERNEL__

Signature · 1 line
Stephen Hemminger <[email protected]>
#3 lore raw
Quoted 9 lines · Stephen Hemminger
Quoted 2 lines · On Tue, 05 Dec 2006 19:38:21 +0100 Patrick McHardy <[email protected]> wrote:

I think this regex should be fixed instead to get rid of it while sanitizing (Makefile.headersinst).

But ip_tables.h should still put include of compiler.h inside #ifdef __KERNEL__

Actually that should also get stripped away by the regex.