Skip to content

Commit 3f1d52a

Browse files
committed
io_uring: defer msg-ring file validity check until command issue
In preparation for not using the file at prep time, defer checking if this file refers to a valid io_uring instance until issue time. Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9666d42 commit 3f1d52a

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

fs/io_uring.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4473,9 +4473,6 @@ static int io_msg_ring_prep(struct io_kiocb *req,
44734473
sqe->splice_fd_in || sqe->buf_index || sqe->personality))
44744474
return -EINVAL;
44754475

4476-
if (req->file->f_op != &io_uring_fops)
4477-
return -EBADFD;
4478-
44794476
req->msg.user_data = READ_ONCE(sqe->off);
44804477
req->msg.len = READ_ONCE(sqe->len);
44814478
return 0;
@@ -4485,9 +4482,14 @@ static int io_msg_ring(struct io_kiocb *req, unsigned int issue_flags)
44854482
{
44864483
struct io_ring_ctx *target_ctx;
44874484
struct io_msg *msg = &req->msg;
4488-
int ret = -EOVERFLOW;
44894485
bool filled;
4486+
int ret;
44904487

4488+
ret = -EBADFD;
4489+
if (req->file->f_op != &io_uring_fops)
4490+
goto done;
4491+
4492+
ret = -EOVERFLOW;
44914493
target_ctx = req->file->private_data;
44924494

44934495
spin_lock(&target_ctx->completion_lock);
@@ -4500,6 +4502,7 @@ static int io_msg_ring(struct io_kiocb *req, unsigned int issue_flags)
45004502
ret = 0;
45014503
}
45024504

4505+
done:
45034506
if (ret < 0)
45044507
req_set_fail(req);
45054508
__io_req_complete(req, issue_flags, ret, 0);

0 commit comments

Comments
 (0)