]> git.itanic.dy.fi Git - linux-stable/commitdiff
io_uring/net: correctly handle multishot recvmsg retry setup
authorJens Axboe <axboe@kernel.dk>
Fri, 8 Mar 2024 00:48:03 +0000 (17:48 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2024 13:32:17 +0000 (15:32 +0200)
[ Upstream commit deaef31bc1ec7966698a427da8c161930830e1cf ]

If we loop for multishot receive on the initial attempt, and then abort
later on to wait for more, we miss a case where we should be copying the
io_async_msghdr from the stack to stable storage. This leads to the next
retry potentially failing, if the application had the msghdr on the
stack.

Cc: stable@vger.kernel.org
Fixes: 9bb66906f23e ("io_uring: support multishot in recvmsg")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
io_uring/net.c

index 4aaeada03f1e7da124c23a6c98a139ea193586f9..386a6745ae32f12359349a4c9db331b7439da130 100644 (file)
@@ -915,7 +915,8 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
                        kfree(kmsg->free_iov);
                io_netmsg_recycle(req, issue_flags);
                req->flags &= ~REQ_F_NEED_CLEANUP;
-       }
+       } else if (ret == -EAGAIN)
+               return io_setup_async_msg(req, kmsg, issue_flags);
 
        return ret;
 }