aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2008-11-09 09:23:57 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-11-09 14:17:33 -0500
commit6209344f5a3795d34b7f2c0061f49802283b6bdd (patch)
tree5c037ddbb8caac17b0c6101c9ab86387df106d41 /include
parent058e3739f6b0753696db1952378de9e8d2a11735 (diff)
net: unix: fix inflight counting bug in garbage collector
Previously I assumed that the receive queues of candidates don't change during the GC. This is only half true, nothing can be received from the queues (see comment in unix_gc()), but buffers could be added through the other half of the socket pair, which may still have file descriptors referring to it. This can result in inc_inflight_move_tail() erronously increasing the "inflight" counter for a unix socket for which dec_inflight() wasn't previously called. This in turn can trigger the "BUG_ON(total_refs < inflight_refs)" in a later garbage collection run. Fix this by only manipulating the "inflight" counter for sockets which are candidates themselves. Duplicating the file references in unix_attach_fds() is also needed to prevent a socket becoming a candidate for GC while the skb that contains it is not yet queued. Reported-by: Andrea Bittau <a.bittau@cs.ucl.ac.uk> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> CC: stable@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/net/af_unix.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 7dd29b7e461d..c29ff1da8a18 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -54,6 +54,7 @@ struct unix_sock {
54 atomic_long_t inflight; 54 atomic_long_t inflight;
55 spinlock_t lock; 55 spinlock_t lock;
56 unsigned int gc_candidate : 1; 56 unsigned int gc_candidate : 1;
57 unsigned int gc_maybe_cycle : 1;
57 wait_queue_head_t peer_wait; 58 wait_queue_head_t peer_wait;
58}; 59};
59#define unix_sk(__sk) ((struct unix_sock *)__sk) 60#define unix_sk(__sk) ((struct unix_sock *)__sk)