io_uring/net: fix cleanup after recycle
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 19 Dec 2022 15:11:40 +0000 (15:11 +0000)
committerJens Axboe <axboe@kernel.dk>
Mon, 19 Dec 2022 15:28:28 +0000 (08:28 -0700)
Don't access io_async_msghdr io_netmsg_recycle(), it may be reallocated.

Cc: stable@vger.kernel.org
Fixes: 9bb66906f23e5 ("io_uring: support multishot in recvmsg")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/9e326f4ad4046ddadf15bf34bf3fa58c6372f6b5.1671461985.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/net.c

index f76b688..fbc34a7 100644 (file)
@@ -820,10 +820,10 @@ retry_multishot:
                goto retry_multishot;
 
        if (mshot_finished) {
-               io_netmsg_recycle(req, issue_flags);
                /* fast path, check for non-NULL to avoid function call */
                if (kmsg->free_iov)
                        kfree(kmsg->free_iov);
+               io_netmsg_recycle(req, issue_flags);
                req->flags &= ~REQ_F_NEED_CLEANUP;
        }