Skip to content

Commit a410482

Browse files
committed
io_uring/unix: drop usage of io_uring socket
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 <[email protected]>
1 parent c432031 commit a410482

File tree

5 files changed

+7
-23
lines changed

5 files changed

+7
-23
lines changed

include/linux/io_uring.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
#include <uapi/linux/io_uring.h>
88

99
#if defined(CONFIG_IO_URING)
10-
struct sock *io_uring_get_socket(struct file *file);
1110
void __io_uring_cancel(bool cancel_all);
1211
void __io_uring_free(struct task_struct *tsk);
1312
void io_uring_unreg_ringfd(void);
1413
const char *io_uring_get_opcode(u8 opcode);
1514
int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags);
15+
bool io_is_uring_fops(struct file *file);
1616

1717
static inline void io_uring_files_cancel(void)
1818
{
@@ -32,10 +32,6 @@ static inline void io_uring_free(struct task_struct *tsk)
3232
__io_uring_free(tsk);
3333
}
3434
#else
35-
static inline struct sock *io_uring_get_socket(struct file *file)
36-
{
37-
return NULL;
38-
}
3935
static inline void io_uring_task_cancel(void)
4036
{
4137
}
@@ -54,6 +50,10 @@ static inline int io_uring_cmd_sock(struct io_uring_cmd *cmd,
5450
{
5551
return -EOPNOTSUPP;
5652
}
53+
static inline bool io_is_uring_fops(struct file *file)
54+
{
55+
return false;
56+
}
5757
#endif
5858

5959
#endif

io_uring/io_uring.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,6 @@ static struct ctl_table kernel_io_uring_disabled_table[] = {
171171
};
172172
#endif
173173

174-
struct sock *io_uring_get_socket(struct file *file)
175-
{
176-
#if defined(CONFIG_UNIX)
177-
if (io_is_uring_fops(file)) {
178-
struct io_ring_ctx *ctx = file->private_data;
179-
180-
return ctx->ring_sock->sk;
181-
}
182-
#endif
183-
return NULL;
184-
}
185-
EXPORT_SYMBOL(io_uring_get_socket);
186-
187174
static inline void io_submit_flush_completions(struct io_ring_ctx *ctx)
188175
{
189176
if (!wq_list_empty(&ctx->submit_state.compl_reqs) ||

io_uring/io_uring.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ struct file *io_file_get_fixed(struct io_kiocb *req, int fd,
4444
unsigned issue_flags);
4545

4646
void __io_req_task_work_add(struct io_kiocb *req, unsigned flags);
47-
bool io_is_uring_fops(struct file *file);
4847
bool io_alloc_async_data(struct io_kiocb *req);
4948
void io_req_task_queue(struct io_kiocb *req);
5049
void io_queue_iowq(struct io_kiocb *req, struct io_tw_state *ts_dont_use);

net/core/scm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
105105
if (fd < 0 || !(file = fget_raw(fd)))
106106
return -EBADF;
107107
/* don't allow io_uring files */
108-
if (io_uring_get_socket(file)) {
108+
if (io_is_uring_fops(file)) {
109109
fput(file);
110110
return -EINVAL;
111111
}

net/unix/scm.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ struct sock *unix_get_socket(struct file *filp)
3535
/* PF_UNIX ? */
3636
if (s && ops && ops->family == PF_UNIX)
3737
u_sock = s;
38-
} else {
39-
/* Could be an io_uring instance */
40-
u_sock = io_uring_get_socket(filp);
4138
}
39+
4240
return u_sock;
4341
}
4442
EXPORT_SYMBOL(unix_get_socket);

0 commit comments

Comments
 (0)