Eric Dumazet 686a7e32ca inetpeer: fix race in unused_list manipulations
Several crashes in cleanup_once() were reported in recent kernels.

Commit d6cc1d642de9 (inetpeer: various changes) added a race in
unlink_from_unused().

One way to avoid taking unused_peers.lock before doing the list_empty()
test is to catch 0->1 refcnt transitions, using full barrier atomic
operations variants (atomic_cmpxchg() and atomic_inc_return()) instead
of previous atomic_inc() and atomic_add_unless() variants.

We then call unlink_from_unused() only for the owner of the 0->1
transition.

Add a new atomic_add_unless_return() static helper

With help from Arun Sharma.

Refs: https://bugzilla.kernel.org/show_bug.cgi?id=32772

Reported-by: Arun Sharma <asharma@fb.com>
Reported-by: Maximilian Engelhardt <maxi@daemonizer.de>
Reported-by: Yann Dupont <Yann.Dupont@univ-nantes.fr>
Reported-by: Denys Fedoryshchenko <denys@visp.net.lb>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-05-27 13:39:11 -04:00
..
2011-04-22 11:04:14 -07:00
2011-05-10 15:03:01 -07:00
2011-04-22 11:04:14 -07:00
2011-03-12 15:08:49 -08:00
2010-10-25 13:09:45 -07:00
2011-05-12 23:03:46 -04:00
2011-05-19 17:13:04 -04:00
2011-02-01 15:35:25 -08:00
2011-05-23 16:29:24 -04:00
2011-05-24 01:13:12 -04:00
2011-05-22 21:01:20 -04:00
2011-05-17 14:16:58 -04:00
2011-05-24 01:13:12 -04:00
2011-03-31 11:26:23 -03:00
2011-03-31 11:26:23 -03:00
2010-10-27 11:37:32 -07:00
2011-05-24 01:13:12 -04:00
2010-07-12 12:57:54 -07:00