Skip to content

Commit

Permalink
io_uring: defer msg-ring file validity check until command issue
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jens Axboe committed Mar 29, 2022
1 parent 9666d42 commit 3f1d52a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -4473,9 +4473,6 @@ static int io_msg_ring_prep(struct io_kiocb *req,
sqe->splice_fd_in || sqe->buf_index || sqe->personality))
return -EINVAL;

if (req->file->f_op != &io_uring_fops)
return -EBADFD;

req->msg.user_data = READ_ONCE(sqe->off);
req->msg.len = READ_ONCE(sqe->len);
return 0;
Expand All @@ -4485,9 +4482,14 @@ static int io_msg_ring(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_ring_ctx *target_ctx;
struct io_msg *msg = &req->msg;
int ret = -EOVERFLOW;
bool filled;
int ret;

ret = -EBADFD;
if (req->file->f_op != &io_uring_fops)
goto done;

ret = -EOVERFLOW;
target_ctx = req->file->private_data;

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

done:
if (ret < 0)
req_set_fail(req);
__io_req_complete(req, issue_flags, ret, 0);
Expand Down

0 comments on commit 3f1d52a

Please sign in to comment.