--- x/net/unix/garbage.c +++ y/net/unix/garbage.c @@ -119,6 +119,7 @@ void unix_inflight(struct user_struct *u if (!u->inflight) { WARN_ON_ONCE(!list_empty(&u->link)); list_add_tail(&u->link, &gc_inflight_list); + sock_hold(&u->sk); } else { WARN_ON_ONCE(list_empty(&u->link)); } @@ -350,6 +351,11 @@ static void __unix_gc(struct work_struct } #endif + list_for_each_entry_safe(u, next, &gc_candidates, link) { + list_del(&u->link); + sock_put(&u->sk); + } + spin_lock(&unix_gc_lock); /* All candidates should have been detached by now. */