]> git.baikalelectronics.ru Git - kernel.git/commit
[NETFILTER]: ip_conntrack_expect_related must not free expectation
authorRusty Russell <rusty@rustcorp.com.au>
Thu, 21 Jul 2005 20:14:46 +0000 (13:14 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 21 Jul 2005 20:14:46 +0000 (13:14 -0700)
commit1e8a1b34d39be8b7ac91e219cc23e2e6e4461aa3
tree77629aef70bd92983518b6f5dd13c70a222c4cbb
parente78848d20b5e243db6c43d861fd8f9abf223bc77
[NETFILTER]: ip_conntrack_expect_related must not free expectation

If a connection tracking helper tells us to expect a connection, and
we're already expecting that connection, we simply free the one they
gave us and return success.

The problem is that NAT helpers (eg. FTP) have to allocate the
expectation first (to see what port is available) then rewrite the
packet.  If that rewrite fails, they try to remove the expectation,
but it was freed in ip_conntrack_expect_related.

This is one example of a larger problem: having registered the
expectation, the pointer is no longer ours to use.  Reference counting
is needed for ctnetlink anyway, so introduce it now.

To have a single "put" path, we need to grab the reference to the
connection on creation, rather than open-coding it in the caller.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
12 files changed:
include/linux/netfilter_ipv4/ip_conntrack.h
include/linux/netfilter_ipv4/ip_conntrack_helper.h
net/ipv4/netfilter/ip_conntrack_amanda.c
net/ipv4/netfilter/ip_conntrack_core.c
net/ipv4/netfilter/ip_conntrack_ftp.c
net/ipv4/netfilter/ip_conntrack_irc.c
net/ipv4/netfilter/ip_conntrack_standalone.c
net/ipv4/netfilter/ip_conntrack_tftp.c
net/ipv4/netfilter/ip_nat_amanda.c
net/ipv4/netfilter/ip_nat_ftp.c
net/ipv4/netfilter/ip_nat_irc.c
net/ipv4/netfilter/ip_nat_tftp.c