Skip to contentSkip to conversation

2.6.16.19 Fix the bug of "return 0 instead of the error code in ipt_register_table"

PATCH In review lepton 2 participants 2 messages Jun 1, 2006

Subsystems (2)
lore
Share & tools
lore

lepton

author
#0 lore raw

PATCH 1/1 2.6.16.19 Fix the bug of "return 0 instead of the error code in ipt_register_table"

Hi,

There is a bug in ipt_register_table() in
net/ipv4/netfilter/ip_tables.c:

ipt_register_table() will return 0 instead of
the error code when xt_register_table() fails

net/ipv4/netfilter/ip_tables.c +2 -1
diff -prU 10 linux-2.6.16.19.oirg/net/ipv4/netfilter/ip_tables.c linux-2.6.16.19/net/ipv4/netfilter/ip_tables.c
@@ -1235,21 +1235,22 @@ int ipt_register_table(struct xt_table *
 	ret = translate_table(table->name, table->valid_hooks,
 			      newinfo, loc_cpu_entry, repl->size,
 			      repl->num_entries,
 			      repl->hook_entry,
 			      repl->underflow);
 	if (ret != 0) {
 		xt_free_table_info(newinfo);
 		return ret;
 	}
 
-	if (xt_register_table(table, &bootstrap, newinfo) != 0) {
+	ret = xt_register_table(table, &bootstrap, newinfo);
+	if (ret) {
 		xt_free_table_info(newinfo);
 		return ret;
 	}
 
 	return 0;
 }
 
 void ipt_unregister_table(struct ipt_table *table)
 {
 	struct xt_table_info *private;
#1 lore raw

net/ipv4/netfilter/ip_tables.c

Quoted 13 lines · lepton

Hi,

There is a bug in ipt_register_table() in
net/ipv4/netfilter/ip_tables.c:

ipt_register_table() will return 0 instead of
the error code when xt_register_table() fails

diff -prU 10 linux-2.6.16.19.oirg/net/ipv4/netfilter/ip_tables.c linux-2.6.16.19/net/ipv4/netfilter/ip_tables.c

net/ipv4/netfilter/ip_tables.c +0 -0

Thanks. As usual this bug has been happily copy and pasted around, so I've added this patch instead.

[NETFILTER]: x_tables: fix xt_register_table error propagation

When xt_register_table fails the error is not properly propagated back. Based on patch by Lepton Wu <[email protected]>.

---
commit b010cc3184ce7cb65a9865ae52ec2ce6f3fe4c9d
tree 9744395bcd9c7d976048ebd8afbabfc0a9b542a4
parent 10263005af5814396b8263c1c2a4367d49548e13
author Patrick McHardy <[email protected]> Thu, 01 Jun 2006 16:59:12 +0200 committer Patrick McHardy <[email protected]> Thu, 01 Jun 2006 16:59:12 +0200

 net/ipv4/netfilter/arp_tables.c |    3 ++-
 net/ipv4/netfilter/ip_tables.c  |    3 ++-
 net/ipv6/netfilter/ip6_tables.c |    3 ++-
 3 files changed, 6 insertions(+), 3 deletions(-)
net/ipv4/netfilter/arp_tables.c +2 -1
index d0d1919..ad39bf6 100644
@@ -1120,7 +1120,8 @@ int arpt_register_table(struct arpt_tabl
 		return ret;
 	}
 
-	if (xt_register_table(table, &bootstrap, newinfo) != 0) {
+	ret = xt_register_table(table, &bootstrap, newinfo);
+	if (ret != 0) {
 		xt_free_table_info(newinfo);
 		return ret;
 	}
net/ipv4/netfilter/ip_tables.c +2 -1
index cee3397..101ad98 100644
@@ -2113,7 +2113,8 @@ int ipt_register_table(struct xt_table *
 		return ret;
 	}
 
-	if (xt_register_table(table, &bootstrap, newinfo) != 0) {
+	ret = xt_register_table(table, &bootstrap, newinfo);
+	if (ret != 0) {
 		xt_free_table_info(newinfo);
 		return ret;
 	}
net/ipv6/netfilter/ip6_tables.c +2 -1
index 2e72f89..0b5bd55 100644
@@ -1281,7 +1281,8 @@ int ip6t_register_table(struct xt_table 
 		return ret;
 	}
 
-	if (xt_register_table(table, &bootstrap, newinfo) != 0) {
+	ret = xt_register_table(table, &bootstrap, newinfo);
+	if (ret != 0) {
 		xt_free_table_info(newinfo);
 		return ret;
 	}