netfilter: nf_conntrack: per netns nf_conntrack_cachep
authorEric Dumazet <eric.dumazet@gmail.com>
Mon, 8 Feb 2010 19:16:56 +0000 (11:16 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 23 Feb 2010 15:37:53 +0000 (07:37 -0800)
commit747edef00c9b2147ca0b3d5bc33e9291a9a6d86e
treee1034913d5d90398ef9e297bc7646808c3b0cb22
parentde2545859df3c04462ef39bf8056e587a1d2fa17
netfilter: nf_conntrack: per netns nf_conntrack_cachep

commit 5b3501faa8741d50617ce4191c20061c6ef36cb3 upstream.

nf_conntrack_cachep is currently shared by all netns instances, but
because of SLAB_DESTROY_BY_RCU special semantics, this is wrong.

If we use a shared slab cache, one object can instantly flight between
one hash table (netns ONE) to another one (netns TWO), and concurrent
reader (doing a lookup in netns ONE, 'finding' an object of netns TWO)
can be fooled without notice, because no RCU grace period has to be
observed between object freeing and its reuse.

We dont have this problem with UDP/TCP slab caches because TCP/UDP
hashtables are global to the machine (and each object has a pointer to
its netns).

If we use per netns conntrack hash tables, we also *must* use per netns
conntrack slab caches, to guarantee an object can not escape from one
namespace to another one.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
[Patrick: added unique slab name allocation]
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
include/net/netns/conntrack.h
net/netfilter/nf_conntrack_core.c