]> git.itanic.dy.fi Git - linux-stable/commit
filter: fix sk_filter rcu handling
authorEric Dumazet <eric.dumazet@gmail.com>
Mon, 6 Dec 2010 17:29:43 +0000 (09:29 -0800)
committerPaul Gortmaker <paul.gortmaker@windriver.com>
Sun, 17 Apr 2011 20:16:04 +0000 (16:16 -0400)
commitd89f6fc68da8ca411226e24d762826f0fff99007
tree08c2f383a300e07fba6d134ca6a0491204b9c1f6
parenta17efe35c72c510d8acf4da81aa5e2233b860281
filter: fix sk_filter rcu handling

commit 46bcf14f44d8f31ecfdc8b6708ec15a3b33316d9 upstream

Pavel Emelyanov tried to fix a race between sk_filter_(de|at)tach and
sk_clone() in commit 47e958eac280c263397

Problem is we can have several clones sharing a common sk_filter, and
these clones might want to sk_filter_attach() their own filters at the
same time, and can overwrite old_filter->rcu, corrupting RCU queues.

We can not use filter->rcu without being sure no other thread could do
the same thing.

Switch code to a more conventional ref-counting technique : Do the
atomic decrement immediately and queue one rcu call back when last
reference is released.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
include/net/sock.h
net/core/filter.c