Skip to contentSkip to conversation

Fix SNAT/DNAT target size checks

PATCH New Martin Josefsson 1 participant 1 message Jan 22, 2005

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

PATCH 1/2 Fix SNAT/DNAT target size checks

Hi Patrick

This patch fixes two size checks in the checkentry() for SNAT and DNAT targets.
The patch to remove support for multiple ranges forgot to use IPT_ALIGN()
This isn't a problem on x86 but other archs like parisc are affected and thus can't add any SNAT/DNAT rules.

Reported and tested by a user on irc.

Please submit this patch to davem for inclusion in 2.6.11 (-rc2 was just released)

net/ipv4/netfilter/ip_nat_rule.c +2 -2
diff -X /home/gandalf/dontdiff.ny -urNp linux-2.6.11-rc2/net/ipv4/netfilter/ip_nat_rule.c linux-2.6.11-rc2.align/net/ipv4/netfilter/ip_nat_rule.c
@@ -181,7 +181,7 @@ static int ipt_snat_checkentry(const cha
 		return 0;
 	}
 
-	if (targinfosize != sizeof(struct ip_nat_multi_range_compat)) {
+	if (targinfosize != IPT_ALIGN(sizeof(struct ip_nat_multi_range_compat))) {
 		DEBUGP("SNAT: Target size %u wrong for %u ranges\n",
 		       targinfosize, mr->rangesize);
 		return 0;
@@ -214,7 +214,7 @@ static int ipt_dnat_checkentry(const cha
 		return 0;
 	}
 
-	if (targinfosize != sizeof(struct ip_nat_multi_range_compat)) {
+	if (targinfosize != IPT_ALIGN(sizeof(struct ip_nat_multi_range_compat))) {
 		DEBUGP("DNAT: Target size %u wrong for %u ranges\n",
 		       targinfosize, mr->rangesize);
 		return 0;
Signature · 1 line
/Martin