--- /dev/null
+From c47862c12b906a64a9a1bf74f49682206952e013 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 13 Mar 2024 18:36:18 -0600
+Subject: io_uring: drop any code related to SCM_RIGHTS
+
+From: Jens Axboe <axboe@kernel.dk>
+
+Commit 6e5e6d274956305f1fc0340522b38f5f5be74bdb upstream.
+
+This is dead code after we dropped support for passing io_uring fds
+over SCM_RIGHTS, get rid of it.
+
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/io_uring.c | 47 +++--------------------------------------------
+ 1 file changed, 3 insertions(+), 44 deletions(-)
+
+diff --git a/fs/io_uring.c b/fs/io_uring.c
+index cd1858cc63206..2c793e4ccf096 100644
+--- a/fs/io_uring.c
++++ b/fs/io_uring.c
+@@ -63,7 +63,6 @@
+ #include <linux/net.h>
+ #include <net/sock.h>
+ #include <net/af_unix.h>
+-#include <net/scm.h>
+ #include <linux/anon_inodes.h>
+ #include <linux/sched/mm.h>
+ #include <linux/uaccess.h>
+@@ -264,10 +263,6 @@ struct io_ring_ctx {
+
+ struct async_list pending_async[2];
+
+-#if defined(CONFIG_UNIX)
+- struct socket *ring_sock;
+-#endif
+-
+ struct list_head task_list;
+ spinlock_t task_lock;
+ };
+@@ -3067,20 +3062,10 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events,
+
+ static void __io_sqe_files_unregister(struct io_ring_ctx *ctx)
+ {
+-#if defined(CONFIG_UNIX)
+- if (ctx->ring_sock) {
+- struct sock *sock = ctx->ring_sock->sk;
+- struct sk_buff *skb;
+-
+- while ((skb = skb_dequeue(&sock->sk_receive_queue)) != NULL)
+- kfree_skb(skb);
+- }
+-#else
+ int i;
+
+ for (i = 0; i < ctx->nr_user_files; i++)
+ fput(ctx->user_files[i]);
+-#endif
+ }
+
+ static int io_sqe_files_unregister(struct io_ring_ctx *ctx)
+@@ -3575,13 +3560,6 @@ static void io_ring_ctx_free(struct io_ring_ctx *ctx)
+ io_sqe_files_unregister(ctx);
+ io_eventfd_unregister(ctx);
+
+-#if defined(CONFIG_UNIX)
+- if (ctx->ring_sock) {
+- ctx->ring_sock->file = NULL; /* so that iput() is called */
+- sock_release(ctx->ring_sock);
+- }
+-#endif
+-
+ io_mem_free(ctx->rings);
+ io_mem_free(ctx->sq_sqes);
+
+@@ -3833,45 +3811,26 @@ static int io_allocate_scq_urings(struct io_ring_ctx *ctx,
+ /*
+ * Allocate an anonymous fd, this is what constitutes the application
+ * visible backing of an io_uring instance. The application mmaps this
+- * fd to gain access to the SQ/CQ ring details. If UNIX sockets are enabled,
+- * we have to tie this fd to a socket for file garbage collection purposes.
++ * fd to gain access to the SQ/CQ ring details.
+ */
+ static int io_uring_get_fd(struct io_ring_ctx *ctx)
+ {
+ struct file *file;
+ int ret;
+
+-#if defined(CONFIG_UNIX)
+- ret = sock_create_kern(&init_net, PF_UNIX, SOCK_RAW, IPPROTO_IP,
+- &ctx->ring_sock);
+- if (ret)
+- return ret;
+-#endif
+-
+ ret = get_unused_fd_flags(O_RDWR | O_CLOEXEC);
+ if (ret < 0)
+- goto err;
++ return ret;
+
+ file = anon_inode_getfile("[io_uring]", &io_uring_fops, ctx,
+ O_RDWR | O_CLOEXEC);
+ if (IS_ERR(file)) {
+ put_unused_fd(ret);
+- ret = PTR_ERR(file);
+- goto err;
++ return PTR_ERR(file);
+ }
+
+-#if defined(CONFIG_UNIX)
+- ctx->ring_sock->file = file;
+- ctx->ring_sock->sk->sk_user_data = ctx;
+-#endif
+ fd_install(ret, file);
+ return ret;
+-err:
+-#if defined(CONFIG_UNIX)
+- sock_release(ctx->ring_sock);
+- ctx->ring_sock = NULL;
+-#endif
+- return ret;
+ }
+
+ static int io_uring_create(unsigned entries, struct io_uring_params *p)
+--
+2.43.0
+
--- /dev/null
+From 0e5ff5687c220803dab485b3f83c78564665f2f2 Mon Sep 17 00:00:00 2001
+From: Sasha Levin <sashal@kernel.org>
+Date: Wed, 13 Mar 2024 18:33:48 -0600
+Subject: io_uring/unix: drop usage of io_uring socket
+
+From: Jens Axboe <axboe@kernel.dk>
+
+Commit a4104821ad651d8a0b374f0b2474c345bbb42f82 upstream.
+
+Since we no longer allow sending io_uring fds over SCM_RIGHTS, move to
+using io_is_uring_fops() to detect whether this is a io_uring fd or not.
+With that done, kill off io_uring_get_socket() as nobody calls it
+anymore.
+
+This is in preparation to yanking out the rest of the core related to
+unix gc with io_uring.
+
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+---
+ fs/io_uring.c | 18 +++++-------------
+ include/linux/fs.h | 6 +++---
+ net/core/scm.c | 2 +-
+ net/unix/scm.c | 4 +---
+ 4 files changed, 10 insertions(+), 20 deletions(-)
+
+diff --git a/fs/io_uring.c b/fs/io_uring.c
+index 9de8961763b06..cd1858cc63206 100644
+--- a/fs/io_uring.c
++++ b/fs/io_uring.c
+@@ -381,19 +381,6 @@ static struct kmem_cache *req_cachep;
+
+ static const struct file_operations io_uring_fops;
+
+-struct sock *io_uring_get_socket(struct file *file)
+-{
+-#if defined(CONFIG_UNIX)
+- if (file->f_op == &io_uring_fops) {
+- struct io_ring_ctx *ctx = file->private_data;
+-
+- return ctx->ring_sock->sk;
+- }
+-#endif
+- return NULL;
+-}
+-EXPORT_SYMBOL(io_uring_get_socket);
+-
+ static void io_ring_ctx_ref_free(struct percpu_ref *ref)
+ {
+ struct io_ring_ctx *ctx = container_of(ref, struct io_ring_ctx, refs);
+@@ -3794,6 +3781,11 @@ static const struct file_operations io_uring_fops = {
+ .fasync = io_uring_fasync,
+ };
+
++bool io_is_uring_fops(struct file *file)
++{
++ return file->f_op == &io_uring_fops;
++}
++
+ static int io_allocate_scq_urings(struct io_ring_ctx *ctx,
+ struct io_uring_params *p)
+ {
+diff --git a/include/linux/fs.h b/include/linux/fs.h
+index e009b52ab6b0d..272f261894b17 100644
+--- a/include/linux/fs.h
++++ b/include/linux/fs.h
+@@ -3614,11 +3614,11 @@ extern int generic_fadvise(struct file *file, loff_t offset, loff_t len,
+ int advice);
+
+ #if defined(CONFIG_IO_URING)
+-extern struct sock *io_uring_get_socket(struct file *file);
++bool io_is_uring_fops(struct file *file);
+ #else
+-static inline struct sock *io_uring_get_socket(struct file *file)
++static inline bool io_is_uring_fops(struct file *file)
+ {
+- return NULL;
++ return false;
+ }
+ #endif
+
+diff --git a/net/core/scm.c b/net/core/scm.c
+index 5525c14f33f1e..a442bf63cd480 100644
+--- a/net/core/scm.c
++++ b/net/core/scm.c
+@@ -105,7 +105,7 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
+ if (fd < 0 || !(file = fget_raw(fd)))
+ return -EBADF;
+ /* don't allow io_uring files */
+- if (io_uring_get_socket(file)) {
++ if (io_is_uring_fops(file)) {
+ fput(file);
+ return -EINVAL;
+ }
+diff --git a/net/unix/scm.c b/net/unix/scm.c
+index e881a6e78af53..51b623de3be5f 100644
+--- a/net/unix/scm.c
++++ b/net/unix/scm.c
+@@ -33,10 +33,8 @@ struct sock *unix_get_socket(struct file *filp)
+ /* PF_UNIX ? */
+ if (s && sock->ops && sock->ops->family == PF_UNIX)
+ u_sock = s;
+- } else {
+- /* Could be an io_uring instance */
+- u_sock = io_uring_get_socket(filp);
+ }
++
+ return u_sock;
+ }
+ EXPORT_SYMBOL(unix_get_socket);
+--
+2.43.0
+
--- /dev/null
+io_uring-unix-drop-usage-of-io_uring-socket.patch
+io_uring-drop-any-code-related-to-scm_rights.patch