diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2022-06-25 11:53:01 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-07-24 18:39:16 -0600 |
commit | 3273c4407acd4348b1531e1f860fbf1da942893b (patch) | |
tree | 8ca772565e74ef05f30a849e5a697fbff50880a2 | |
parent | ad8b261d837400cb7ccc339e81d7c35ab018acd8 (diff) | |
download | linux-stable-3273c4407acd4348b1531e1f860fbf1da942893b.tar.gz linux-stable-3273c4407acd4348b1531e1f860fbf1da942893b.tar.bz2 linux-stable-3273c4407acd4348b1531e1f860fbf1da942893b.zip |
io_uring: don't check file ops of registered rings
Registered rings are per definitions io_uring files, so we don't need to
additionally verify them.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/425cd64fd885b8e329a46c205ee811987691baaf.1656153286.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | io_uring/io_uring.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index f40526426db8..e1e8dcd17df3 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3036,22 +3036,22 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit, if (flags & IORING_ENTER_REGISTERED_RING) { struct io_uring_task *tctx = current->io_uring; - if (!tctx || fd >= IO_RINGFD_REG_MAX) + if (unlikely(!tctx || fd >= IO_RINGFD_REG_MAX)) return -EINVAL; fd = array_index_nospec(fd, IO_RINGFD_REG_MAX); f.file = tctx->registered_rings[fd]; f.flags = 0; + if (unlikely(!f.file)) + return -EBADF; } else { f = fdget(fd); + if (unlikely(!f.file)) + return -EBADF; + ret = -EOPNOTSUPP; + if (unlikely(!io_is_uring_fops(f.file))) + goto out_fput; } - if (unlikely(!f.file)) - return -EBADF; - - ret = -EOPNOTSUPP; - if (unlikely(!io_is_uring_fops(f.file))) - goto out_fput; - ret = -ENXIO; ctx = f.file->private_data; if (unlikely(!percpu_ref_tryget(&ctx->refs))) |