From dd070de91b2af237603c8b4fcd2869f8307b7dc1 Mon Sep 17 00:00:00 2001 From: Patrick Jacques Date: Fri, 26 Nov 2010 15:32:55 -0700 Subject: [PATCH] net: unix: force garbage collection if too many inflight sockets Patch vulnerability discussed on lkml: http://lkml.org/lkml/2010/11/25/8 Patch author: Eric Dumazet (cherry picked from commit 0e876bd3ad5b259988a12785db5bbe3962f256d0) Signed-off-by: nobodyAtall Signed-off-by: garwedgess --- net/unix/garbage.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/net/unix/garbage.c b/net/unix/garbage.c index 19c17e4a..736e6f94 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c @@ -269,9 +269,16 @@ static void inc_inflight_move_tail(struct unix_sock *u) } static bool gc_in_progress = false; +#define UNIX_INFLIGHT_TRIGGER_GC 16000 void wait_for_unix_gc(void) { + /* + * If number of inflight sockets is insane, + * force a garbage collect right now. + */ + if (unix_tot_inflight > UNIX_INFLIGHT_TRIGGER_GC && !gc_in_progress) + unix_gc(); wait_event(unix_gc_wait, gc_in_progress == false); }