Skip to contentSkip to conversation

: Clear NAT status bits on module unload

PATCH Applied Patrick McHardy 2 participants 2 messages Feb 5, 2005 – Feb 7, 2005 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Clear NAT status bits on module unload

Hi Dave,

another patch which I think should go in 2.6.11, it fixes a crash when unloading, then reloading iptable_nat.

Regards
Patrick

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2005/02/05 03:49:38+01:00 [email protected]
# [NETFILTER]: Clear NAT status bits on module unload
#

#   ip_nat_core doesn't clear the status bits in struct ip_conntrack on
#   module unload, but zeroes out the nat area. When the module is loaded
#   again and a connection times out ip_nat_cleanup_conntrack tries to
#   list_del the zeroed list-head and crashes. There are probably more
#   conditions under which it can crash or cause other misbehaviour.
#   
#   Signed-off-by: Patrick McHardy <[email protected]>
# 
# net/ipv4/netfilter/ip_nat_core.c
#   2005/02/05 03:49:28+01:00 [email protected] +1 -0
#   [NETFILTER]: Clear NAT status bits on module unload
#   
#   ip_nat_core doesn't clear the status bits in struct ip_conntrack on
#   module unload, but zeroes out the nat area. When the module is loaded
#   again and a connection times out ip_nat_cleanup_conntrack tries to
#   list_del the zeroed list-head and crashes. There are probably more
#   conditions under which it can crash or cause other misbehaviour.
#   
#   Signed-off-by: Patrick McHardy <[email protected]>
# 
diff -Nru a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c
--- a/net/ipv4/netfilter/ip_nat_core.c	2005-02-05 03:50:14 +01:00
+++ b/net/ipv4/netfilter/ip_nat_core.c	2005-02-05 03:50:14 +01:00
@@ -543,6 +543,7 @@
 static int clean_nat(struct ip_conntrack *i, void *data)
 {
 	memset(&i->nat, 0, sizeof(i->nat));
+	i->status &= ~(IPS_NAT_MASK | IPS_NAT_DONE_MASK | IPS_SEQ_ADJUST);
 	return 0;
 }
#1 lore raw
Quoted 2 lines · On Sat, 05 Feb 2005 03:53:16 +0100 Patrick McHardy <[email protected]> wrote:

another patch which I think should go in 2.6.11, it fixes a crash when unloading, then reloading iptable_nat.

Applied, thanks Patrick.