]> git.baikalelectronics.ru Git - kernel.git/commitdiff
io_uring/uring_cmd: ensure that device supports IOPOLL
authorJens Axboe <axboe@kernel.dk>
Wed, 8 Mar 2023 16:26:13 +0000 (09:26 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2023 07:50:14 +0000 (08:50 +0100)
commit 68147a076f02bbd61bad50e90e2a9a1edd9ca628 upstream.

It's possible for a file type to support uring commands, but not
pollable ones. Hence before issuing one of those, we should check
that it is supported and error out upfront if it isn't.

Cc: stable@vger.kernel.org
Fixes: 081b9010e6ee ("io_uring: add iopoll infrastructure for io_uring_cmd")
Link: https://github.com/axboe/liburing/issues/816
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
io_uring/uring_cmd.c

index e50de0b6b9f843f094a3e54923c953d85ee24fc7..18dfc5f6a8b72e2f2444796005512fd682ec1fe4 100644 (file)
@@ -108,7 +108,7 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
        struct file *file = req->file;
        int ret;
 
-       if (!req->file->f_op->uring_cmd)
+       if (!file->f_op->uring_cmd)
                return -EOPNOTSUPP;
 
        ret = security_uring_cmd(ioucmd);
@@ -120,6 +120,8 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags)
        if (ctx->flags & IORING_SETUP_CQE32)
                issue_flags |= IO_URING_F_CQE32;
        if (ctx->flags & IORING_SETUP_IOPOLL) {
+               if (!file->f_op->uring_cmd_iopoll)
+                       return -EOPNOTSUPP;
                issue_flags |= IO_URING_F_IOPOLL;
                req->iopoll_completed = 0;
                WRITE_ONCE(ioucmd->cookie, NULL);