diff options
author | Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> | 2007-07-14 23:45:41 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-07-14 23:45:41 -0400 |
commit | 130e7a83d7ec8c5c673225e0fa8ea37b1ed507a5 (patch) | |
tree | 35b4d5f60070309cb592b156590c1fb431e37ef6 /net/ipv4 | |
parent | e2a3123fbe58da9fd3f35cd242087896ace6049f (diff) |
[NETFILTER]: nf_conntrack: Don't track locally generated special ICMP error
The conntrack assigned to locally generated ICMP error is usually the one
assigned to the original packet which has caused the error. But if
the original packet is handled as invalid by nf_conntrack, no conntrack
is assigned to the original packet. Then nf_ct_attach() cannot assign
any conntrack to the ICMP error packet. In that case the current
nf_conntrack_icmp assigns appropriate conntrack to it. But the current
code mistakes the direction of the packet. As a result, NAT code mistakes
the address to be mangled.
To fix the bug, this changes nf_conntrack_icmp not to assign conntrack
to such ICMP error. Actually no address is necessary to be mangled
in this case.
Spotted by Jordan Russell.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c index b8b79992797e..f96573304f5b 100644 --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c | |||
@@ -165,25 +165,13 @@ icmp_error_message(struct sk_buff *skb, | |||
165 | 165 | ||
166 | h = nf_conntrack_find_get(&innertuple); | 166 | h = nf_conntrack_find_get(&innertuple); |
167 | if (!h) { | 167 | if (!h) { |
168 | /* Locally generated ICMPs will match inverted if they | 168 | pr_debug("icmp_error_message: no match\n"); |
169 | haven't been SNAT'ed yet */ | 169 | return -NF_ACCEPT; |
170 | /* FIXME: NAT code has to handle half-done double NAT --RR */ | ||
171 | if (hooknum == NF_IP_LOCAL_OUT) | ||
172 | h = nf_conntrack_find_get(&origtuple); | ||
173 | |||
174 | if (!h) { | ||
175 | pr_debug("icmp_error_message: no match\n"); | ||
176 | return -NF_ACCEPT; | ||
177 | } | ||
178 | |||
179 | /* Reverse direction from that found */ | ||
180 | if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY) | ||
181 | *ctinfo += IP_CT_IS_REPLY; | ||
182 | } else { | ||
183 | if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY) | ||
184 | *ctinfo += IP_CT_IS_REPLY; | ||
185 | } | 170 | } |
186 | 171 | ||
172 | if (NF_CT_DIRECTION(h) == IP_CT_DIR_REPLY) | ||
173 | *ctinfo += IP_CT_IS_REPLY; | ||
174 | |||
187 | /* Update skb to refer to this connection */ | 175 | /* Update skb to refer to this connection */ |
188 | skb->nfct = &nf_ct_tuplehash_to_ctrack(h)->ct_general; | 176 | skb->nfct = &nf_ct_tuplehash_to_ctrack(h)->ct_general; |
189 | skb->nfctinfo = *ctinfo; | 177 | skb->nfctinfo = *ctinfo; |