From: Jens Axboe <axboe@kernel.dk>
To: io-uring <io-uring@vger.kernel.org>
Subject: [PATCH v2] io_uring/net: ensure async prep handlers always initialize ->done_io
Date: Fri, 15 Mar 2024 16:48:39 -0600 [thread overview]
Message-ID: <472ec1d4-f928-4a52-8a93-7ccc1af4f362@kernel.dk> (raw)
If we get a request with IOSQE_ASYNC set, then we first run the prep
async handlers. But if we then fail setting it up and want to post
a CQE with -EINVAL, we use ->done_io. This was previously guarded with
REQ_F_PARTIAL_IO, and the normal setup handlers do set it up before any
potential errors, but we need to cover the async setup too.
Fixes: 9817ad85899f ("io_uring/net: remove dependency on REQ_F_PARTIAL_IO for sr->done_io")
Reported-by: syzbot+f8e9a371388aa62ecab4@syzkaller.appspotmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
V2: missed a refresh, and hence v1 had io_send_prep_async() overwriting
sr->done_io if we had already set it up.
diff --git a/io_uring/net.c b/io_uring/net.c
index 19451f0dbf81..1e7665ff6ef7 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -326,7 +326,10 @@ int io_send_prep_async(struct io_kiocb *req)
struct io_async_msghdr *io;
int ret;
- if (!zc->addr || req_has_async_data(req))
+ if (req_has_async_data(req))
+ return 0;
+ zc->done_io = 0;
+ if (!zc->addr)
return 0;
io = io_msg_alloc_async_prep(req);
if (!io)
@@ -353,8 +356,10 @@ static int io_setup_async_addr(struct io_kiocb *req,
int io_sendmsg_prep_async(struct io_kiocb *req)
{
+ struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
int ret;
+ sr->done_io = 0;
if (!io_msg_alloc_async_prep(req))
return -ENOMEM;
ret = io_sendmsg_copy_hdr(req, req->async_data);
@@ -608,9 +613,11 @@ static int io_recvmsg_copy_hdr(struct io_kiocb *req,
int io_recvmsg_prep_async(struct io_kiocb *req)
{
+ struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
struct io_async_msghdr *iomsg;
int ret;
+ sr->done_io = 0;
if (!io_msg_alloc_async_prep(req))
return -ENOMEM;
iomsg = req->async_data;
--
Jens Axboe
next reply other threads:[~2024-03-15 22:48 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-15 22:48 Jens Axboe [this message]
2024-03-15 23:09 ` [PATCH v2] io_uring/net: ensure async prep handlers always initialize ->done_io Pavel Begunkov
2024-03-15 23:13 ` Pavel Begunkov
2024-03-15 23:19 ` Pavel Begunkov
2024-03-15 23:25 ` Jens Axboe
2024-03-15 23:28 ` Pavel Begunkov
2024-03-15 23:53 ` Jens Axboe
2024-03-16 16:14 ` Jens Axboe
2024-03-16 16:28 ` Pavel Begunkov
2024-03-16 16:31 ` Jens Axboe
2024-03-16 16:32 ` Pavel Begunkov
2024-03-16 16:34 ` Pavel Begunkov
2024-03-16 16:36 ` Jens Axboe
2024-03-16 16:36 ` Pavel Begunkov
2024-03-16 16:40 ` Pavel Begunkov
2024-03-16 16:42 ` Jens Axboe
2024-03-16 16:46 ` Pavel Begunkov
2024-03-16 16:51 ` Jens Axboe
2024-03-16 16:57 ` Pavel Begunkov
2024-03-16 17:01 ` Jens Axboe
2024-03-16 17:42 ` Pavel Begunkov
2024-03-16 23:58 ` Jens Axboe
2024-03-17 20:45 ` Pavel Begunkov
2024-03-15 23:13 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=472ec1d4-f928-4a52-8a93-7ccc1af4f362@kernel.dk \
--to=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.