io_uring: fix poll error reporting
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 18 Apr 2022 12:41:20 +0000 (06:41 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Apr 2022 07:36:28 +0000 (09:36 +0200)
commit 7179c3ce3dbff646c55f7cd664a895f462f049e5 upstream.

We should not return an error code in req->result in
io_poll_check_events(), because it may get mangled and returned as
success. Just return the error code directly, the callers will fail the
request or proceed accordingly.

Fixes: 6bf9c47a3989 ("io_uring: defer file assignment")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/5f03514ee33324dc811fb93df84aee0f695fb044.1649862516.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/io_uring.c

index 6ddafa3af17010801559d5395edb940cb970d4a1..619c67fd456dd6992dbf857c7e9c1cfa10cec785 100644 (file)
@@ -5513,9 +5513,8 @@ static int io_poll_check_events(struct io_kiocb *req, bool locked)
                        unsigned flags = locked ? 0 : IO_URING_F_UNLOCKED;
 
                        if (unlikely(!io_assign_file(req, flags)))
-                               req->result = -EBADF;
-                       else
-                               req->result = vfs_poll(req->file, &pt) & poll->events;
+                               return -EBADF;
+                       req->result = vfs_poll(req->file, &pt) & poll->events;
                }
 
                /* multishot, just fill an CQE and proceed */