hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/net/unix/scm.c
....@@ -8,6 +8,7 @@
88 #include <net/af_unix.h>
99 #include <net/scm.h>
1010 #include <linux/init.h>
11
+#include <linux/io_uring.h>
1112
1213 #include "scm.h"
1314
....@@ -33,6 +34,9 @@
3334 /* PF_UNIX ? */
3435 if (s && sock->ops && sock->ops->family == PF_UNIX)
3536 u_sock = s;
37
+ } else {
38
+ /* Could be an io_uring instance */
39
+ u_sock = io_uring_get_socket(filp);
3640 }
3741 return u_sock;
3842 }
....@@ -59,7 +63,7 @@
5963 /* Paired with READ_ONCE() in wait_for_unix_gc() */
6064 WRITE_ONCE(unix_tot_inflight, unix_tot_inflight + 1);
6165 }
62
- user->unix_inflight++;
66
+ WRITE_ONCE(user->unix_inflight, user->unix_inflight + 1);
6367 spin_unlock(&unix_gc_lock);
6468 }
6569
....@@ -80,7 +84,7 @@
8084 /* Paired with READ_ONCE() in wait_for_unix_gc() */
8185 WRITE_ONCE(unix_tot_inflight, unix_tot_inflight - 1);
8286 }
83
- user->unix_inflight--;
87
+ WRITE_ONCE(user->unix_inflight, user->unix_inflight - 1);
8488 spin_unlock(&unix_gc_lock);
8589 }
8690
....@@ -94,7 +98,7 @@
9498 {
9599 struct user_struct *user = current_user();
96100
97
- if (unlikely(user->unix_inflight > task_rlimit(p, RLIMIT_NOFILE)))
101
+ if (unlikely(READ_ONCE(user->unix_inflight) > task_rlimit(p, RLIMIT_NOFILE)))
98102 return !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN);
99103 return false;
100104 }