* [PATCH v2] io_uring/net: disable partial retries for recvmsg with cmsg
@ 2023-06-20 13:19 Jens Axboe
2023-06-21 11:34 ` Stefan Metzmacher
0 siblings, 1 reply; 2+ messages in thread
From: Jens Axboe @ 2023-06-20 13:19 UTC (permalink / raw)
To: io-uring; +Cc: Stefan Metzmacher
We cannot sanely handle partial retries for recvmsg if we have cmsg
attached. If we don't, then we'd just be overwriting the initial cmsg
header on retries. Alternatively we could increment and handle this
appropriately, but it doesn't seem worth the complication.
Move the MSG_WAITALL check into the non-multishot case while at it,
since MSG_WAITALL is explicitly disabled for multishot anyway.
Link: https://lore.kernel.org/io-uring/[email protected]/
Cc: [email protected] # 5.10+
Reported-by: Stefan Metzmacher <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
---
v2: correct msg_controllen check and move into non-mshot branch
io_uring/net.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/io_uring/net.c b/io_uring/net.c
index c0924ab1ea11..2bc2cb2f4d6c 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -789,16 +789,19 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
flags = sr->msg_flags;
if (force_nonblock)
flags |= MSG_DONTWAIT;
- if (flags & MSG_WAITALL)
- min_ret = iov_iter_count(&kmsg->msg.msg_iter);
kmsg->msg.msg_get_inq = 1;
- if (req->flags & REQ_F_APOLL_MULTISHOT)
+ if (req->flags & REQ_F_APOLL_MULTISHOT) {
ret = io_recvmsg_multishot(sock, sr, kmsg, flags,
&mshot_finished);
- else
+ } else {
+ /* disable partial retry for recvmsg with cmsg attached */
+ if (flags & MSG_WAITALL && !kmsg->msg.msg_controllen)
+ min_ret = iov_iter_count(&kmsg->msg.msg_iter);
+
ret = __sys_recvmsg_sock(sock, &kmsg->msg, sr->umsg,
kmsg->uaddr, flags);
+ }
if (ret < min_ret) {
if (ret == -EAGAIN && force_nonblock) {
--
2.39.2
--
Jens Axboe
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] io_uring/net: disable partial retries for recvmsg with cmsg
2023-06-20 13:19 [PATCH v2] io_uring/net: disable partial retries for recvmsg with cmsg Jens Axboe
@ 2023-06-21 11:34 ` Stefan Metzmacher
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Metzmacher @ 2023-06-21 11:34 UTC (permalink / raw)
To: Jens Axboe, io-uring
Am 20.06.23 um 15:19 schrieb Jens Axboe:
> We cannot sanely handle partial retries for recvmsg if we have cmsg
> attached. If we don't, then we'd just be overwriting the initial cmsg
> header on retries. Alternatively we could increment and handle this
> appropriately, but it doesn't seem worth the complication.
>
> Move the MSG_WAITALL check into the non-multishot case while at it,
> since MSG_WAITALL is explicitly disabled for multishot anyway.
>
> Link: https://lore.kernel.org/io-uring/[email protected]/
> Cc: [email protected] # 5.10+
> Reported-by: Stefan Metzmacher <[email protected]>
> Signed-off-by: Jens Axboe <[email protected]>
Also Reviewed-by: Stefan Metzmacher <[email protected]>
> ---
>
> v2: correct msg_controllen check and move into non-mshot branch
>
> io_uring/net.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/io_uring/net.c b/io_uring/net.c
> index c0924ab1ea11..2bc2cb2f4d6c 100644
> --- a/io_uring/net.c
> +++ b/io_uring/net.c
> @@ -789,16 +789,19 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
> flags = sr->msg_flags;
> if (force_nonblock)
> flags |= MSG_DONTWAIT;
> - if (flags & MSG_WAITALL)
> - min_ret = iov_iter_count(&kmsg->msg.msg_iter);
>
> kmsg->msg.msg_get_inq = 1;
> - if (req->flags & REQ_F_APOLL_MULTISHOT)
> + if (req->flags & REQ_F_APOLL_MULTISHOT) {
> ret = io_recvmsg_multishot(sock, sr, kmsg, flags,
> &mshot_finished);
> - else
> + } else {
> + /* disable partial retry for recvmsg with cmsg attached */
> + if (flags & MSG_WAITALL && !kmsg->msg.msg_controllen)
> + min_ret = iov_iter_count(&kmsg->msg.msg_iter);
> +
> ret = __sys_recvmsg_sock(sock, &kmsg->msg, sr->umsg,
> kmsg->uaddr, flags);
> + }
>
> if (ret < min_ret) {
> if (ret == -EAGAIN && force_nonblock) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-06-21 11:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20 13:19 [PATCH v2] io_uring/net: disable partial retries for recvmsg with cmsg Jens Axboe
2023-06-21 11:34 ` Stefan Metzmacher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox