netfilter: fix race in conntrack between dump_table and destroy
authorStephen Hemminger <shemminger@vyatta.com>
Tue, 11 Jan 2011 22:54:42 +0000 (23:54 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 24 Feb 2011 22:54:36 +0000 (14:54 -0800)
commit5f72ca2a4c4b60e69b07e6ceecc505e47aba060a
treecfcad21ccb7867168ea512ffb8fd11fa698b2331
parent53b9575ce4ac028c83c4b3ed944e8941cf984257
netfilter: fix race in conntrack between dump_table and destroy

commit 13ee6ac579574a2a95e982b19920fd2495dce8cd upstream.

The netlink interface to dump the connection tracking table has a race
when entries are deleted at the same time. A customer reported a crash
and the backtrace showed thatctnetlink_dump_table was running while a
conntrack entry was being destroyed.
(see https://bugzilla.vyatta.com/show_bug.cgi?id=6402).

According to RCU documentation, when using hlist_nulls the reader
must handle the case of seeing a deleted entry and not proceed
further down the linked list.  The old code would continue
which caused the scan to walk into the free list.

This patch uses locking (rather than RCU) for this operation which
is guaranteed safe, and no longer requires getting reference while
doing dump operation.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/netfilter/nf_conntrack_netlink.c