From: Pavel Begunkov <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>, io-uring <io-uring@vger.kernel.org>
Subject: Re: [PATCH] io_uring/net: fix a multishot termination case for recv
Date: Sun, 29 Sep 2024 20:25:40 +0100 [thread overview]
Message-ID: <0542e045-e5ee-41d3-b44f-5b6f9657f90a@gmail.com> (raw)
In-Reply-To: <2ddaef0b-0def-4886-ade6-8fedd7a0965f@kernel.dk>
On 9/28/24 13:40, Jens Axboe wrote:
> On 9/28/24 6:18 AM, Jens Axboe wrote:
>> diff --git a/io_uring/net.c b/io_uring/net.c
>> index f10f5a22d66a..18507658a921 100644
>> --- a/io_uring/net.c
>> +++ b/io_uring/net.c
>> @@ -1133,6 +1133,7 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
>> int ret, min_ret = 0;
>> bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
>> size_t len = sr->len;
>> + bool mshot_finished;
>>
>> if (!(req->flags & REQ_F_POLLED) &&
>> (sr->flags & IORING_RECVSEND_POLL_FIRST))
>> @@ -1187,6 +1188,7 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
>> req_set_fail(req);
>> }
>>
>> + mshot_finished = ret <= 0;
>> if (ret > 0)
>> ret += sr->done_io;
>> else if (sr->done_io)
>> @@ -1194,7 +1196,7 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
>> else
>> io_kbuf_recycle(req, issue_flags);
>>
>> - if (!io_recv_finish(req, &ret, kmsg, ret <= 0, issue_flags))
>> + if (!io_recv_finish(req, &ret, kmsg, mshot_finished, issue_flags))
>> goto retry_multishot;
>>
>> return ret;
>
> On second thought, I don't think we can get into this situation -
> sr->done_io is only ever used for recv if we had to retry after getting
> some data. And that only happens if MSG_WAITALL is set, which is not
> legal for multishot and will result in -EINVAL. So don't quite see how
> we can run into this issue. But I could be missing something...
>
> Comments?
I noticed the chunk months ago, it's definitely a sloppy one, but I
deemed it not to be an actual problem after trying to exploit it at
the moment.
--
Pavel Begunkov
next prev parent reply other threads:[~2024-09-29 19:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-28 12:18 [PATCH] io_uring/net: fix a multishot termination case for recv Jens Axboe
2024-09-28 12:40 ` Jens Axboe
2024-09-29 19:25 ` Pavel Begunkov [this message]
2024-09-30 1:58 ` 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=0542e045-e5ee-41d3-b44f-5b6f9657f90a@gmail.com \
--to=asml.silence@gmail.com \
--cc=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.