]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring/unix: drop usage of io_uring socket
authorJens Axboe <axboe@kernel.dk>
Tue, 19 Dec 2023 19:30:43 +0000 (12:30 -0700)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:19:09 +0000 (18:19 -0400)
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>
include/linux/io_uring.h
io_uring/io_uring.c
io_uring/io_uring.h
net/core/scm.c
net/unix/scm.c

index 106cdc55ff3bd6f5f199d1af30eb6322a872d504..f99ff6de926cbffbf3042c82857b7921e9cadc21 100644 (file)
@@ -46,7 +46,6 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
                              struct iov_iter *iter, void *ioucmd);
 void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t res2,
                        unsigned issue_flags);
-struct sock *io_uring_get_socket(struct file *file);
 void __io_uring_cancel(bool cancel_all);
 void __io_uring_free(struct task_struct *tsk);
 void io_uring_unreg_ringfd(void);
@@ -82,6 +81,7 @@ static inline void io_uring_free(struct task_struct *tsk)
                __io_uring_free(tsk);
 }
 int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags);
+bool io_is_uring_fops(struct file *file);
 #else
 static inline int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw,
                              struct iov_iter *iter, void *ioucmd)
@@ -100,10 +100,6 @@ static inline void io_uring_cmd_do_in_task_lazy(struct io_uring_cmd *ioucmd,
                        void (*task_work_cb)(struct io_uring_cmd *, unsigned))
 {
 }
-static inline struct sock *io_uring_get_socket(struct file *file)
-{
-       return NULL;
-}
 static inline void io_uring_task_cancel(void)
 {
 }
@@ -122,6 +118,10 @@ static inline int io_uring_cmd_sock(struct io_uring_cmd *cmd,
 {
        return -EOPNOTSUPP;
 }
+static inline bool io_is_uring_fops(struct file *file)
+{
+       return false;
+}
 #endif
 
 #endif
index ea772a02c14055f038339dab58118e6cc59a08b3..747d2a6ecab89b46e1047360734c753909cb2af8 100644 (file)
@@ -175,19 +175,6 @@ static struct ctl_table kernel_io_uring_disabled_table[] = {
 };
 #endif
 
-struct sock *io_uring_get_socket(struct file *file)
-{
-#if defined(CONFIG_UNIX)
-       if (io_is_uring_fops(file)) {
-               struct io_ring_ctx *ctx = file->private_data;
-
-               return ctx->ring_sock->sk;
-       }
-#endif
-       return NULL;
-}
-EXPORT_SYMBOL(io_uring_get_socket);
-
 static inline void io_submit_flush_completions(struct io_ring_ctx *ctx)
 {
        if (!wq_list_empty(&ctx->submit_state.compl_reqs) ||
index c8cba78310831def86ff32e9281b1c276a60e72f..411c883b37a95743b0814e8a9e2c8d89cbb3debf 100644 (file)
@@ -61,7 +61,6 @@ struct file *io_file_get_fixed(struct io_kiocb *req, int fd,
                               unsigned issue_flags);
 
 void __io_req_task_work_add(struct io_kiocb *req, unsigned flags);
-bool io_is_uring_fops(struct file *file);
 bool io_alloc_async_data(struct io_kiocb *req);
 void io_req_task_queue(struct io_kiocb *req);
 void io_queue_iowq(struct io_kiocb *req, struct io_tw_state *ts_dont_use);
index 7dc47c17d8638a79960cee0a4cc8fd3fedd624fe..737917c7ac62762e3bd7122c47877104afc20596 100644 (file)
@@ -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;
                }
index 6ff628f2349f571fa8f1e86454a0339a78f7b0f0..822ce0d0d79158692c12c20eae8e1c354e1960f3 100644 (file)
@@ -35,10 +35,8 @@ struct sock *unix_get_socket(struct file *filp)
                /* PF_UNIX ? */
                if (s && ops && 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);