Revert "io_uring/unix: drop usage of io_uring socket"

This reverts commit 6cf9b744bf.
This commit is contained in:
Ksawlii 2024-11-19 09:11:51 +01:00
parent 28bfb5a650
commit 809ca90c02
4 changed files with 22 additions and 12 deletions

View file

@ -68,9 +68,9 @@ struct io_uring_task {
#if defined(CONFIG_IO_URING)
struct sock *io_uring_get_socket(struct file *file);
void __io_uring_cancel(bool cancel_all);
void __io_uring_free(struct task_struct *tsk);
bool io_is_uring_fops(struct file *file);
static inline void io_uring_files_cancel(void)
{
@ -88,6 +88,10 @@ static inline void io_uring_free(struct task_struct *tsk)
__io_uring_free(tsk);
}
#else
static inline struct sock *io_uring_get_socket(struct file *file)
{
return NULL;
}
static inline void io_uring_task_cancel(void)
{
}
@ -97,10 +101,6 @@ static inline void io_uring_files_cancel(void)
static inline void io_uring_free(struct task_struct *tsk)
{
}
static inline bool io_is_uring_fops(struct file *file)
{
return false;
}
#endif
#endif

View file

@ -1119,6 +1119,19 @@ 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 inline void io_tw_lock(struct io_ring_ctx *ctx, bool *locked)
{
if (!*locked) {
@ -10086,11 +10099,6 @@ static const struct file_operations io_uring_fops = {
#endif
};
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)
{

View 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_is_uring_fops(file)) {
if (io_uring_get_socket(file)) {
fput(file);
return -EINVAL;
}

View file

@ -34,8 +34,10 @@ 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);