hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/net/unix/garbage.c
....@@ -1,9 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * NET3: Garbage Collector For AF_UNIX sockets
34 *
45 * Garbage Collector:
56 * Copyright (C) Barak A. Pearlmutter.
6
- * Released under the GPL version 2 or later.
77 *
88 * Chopped about by Alan Cox 22/3/96 to make it fit the AF_UNIX socket problem.
99 * If it doesn't work blame me, it worked when Barak sent it.
....@@ -23,11 +23,6 @@
2323 * Future optimizations:
2424 *
2525 * - don't just push entire root set; process in place
26
- *
27
- * This program is free software; you can redistribute it and/or
28
- * modify it under the terms of the GNU General Public License
29
- * as published by the Free Software Foundation; either version
30
- * 2 of the License, or (at your option) any later version.
3126 *
3227 * Fixes:
3328 * Alan Cox 07 Sept 1997 Vmalloc internal stack as needed.
....@@ -209,6 +204,7 @@
209204 /* The external entry point: unix_gc() */
210205 void unix_gc(void)
211206 {
207
+ struct sk_buff *next_skb, *skb;
212208 struct unix_sock *u;
213209 struct unix_sock *next;
214210 struct sk_buff_head hitlist;
....@@ -302,11 +298,30 @@
302298
303299 spin_unlock(&unix_gc_lock);
304300
301
+ /* We need io_uring to clean its registered files, ignore all io_uring
302
+ * originated skbs. It's fine as io_uring doesn't keep references to
303
+ * other io_uring instances and so killing all other files in the cycle
304
+ * will put all io_uring references forcing it to go through normal
305
+ * release.path eventually putting registered files.
306
+ */
307
+ skb_queue_walk_safe(&hitlist, skb, next_skb) {
308
+ if (skb->scm_io_uring) {
309
+ __skb_unlink(skb, &hitlist);
310
+ skb_queue_tail(&skb->sk->sk_receive_queue, skb);
311
+ }
312
+ }
313
+
305314 /* Here we are. Hitlist is filled. Die. */
306315 __skb_queue_purge(&hitlist);
307316
308317 spin_lock(&unix_gc_lock);
309318
319
+ /* There could be io_uring registered files, just push them back to
320
+ * the inflight list
321
+ */
322
+ list_for_each_entry_safe(u, next, &gc_candidates, link)
323
+ list_move_tail(&u->link, &gc_inflight_list);
324
+
310325 /* All candidates should have been detached by now. */
311326 BUG_ON(!list_empty(&gc_candidates));
312327