Skip to content

Commit 78d0d20

Browse files
committed
io_uring/net: disable partial retries for recvmsg with cmsg
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]> Reviewed-by: Stefan Metzmacher <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent b1dc492 commit 78d0d20

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

io_uring/net.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -789,16 +789,19 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
789789
flags = sr->msg_flags;
790790
if (force_nonblock)
791791
flags |= MSG_DONTWAIT;
792-
if (flags & MSG_WAITALL)
793-
min_ret = iov_iter_count(&kmsg->msg.msg_iter);
794792

795793
kmsg->msg.msg_get_inq = 1;
796-
if (req->flags & REQ_F_APOLL_MULTISHOT)
794+
if (req->flags & REQ_F_APOLL_MULTISHOT) {
797795
ret = io_recvmsg_multishot(sock, sr, kmsg, flags,
798796
&mshot_finished);
799-
else
797+
} else {
798+
/* disable partial retry for recvmsg with cmsg attached */
799+
if (flags & MSG_WAITALL && !kmsg->msg.msg_controllen)
800+
min_ret = iov_iter_count(&kmsg->msg.msg_iter);
801+
800802
ret = __sys_recvmsg_sock(sock, &kmsg->msg, sr->umsg,
801803
kmsg->uaddr, flags);
804+
}
802805

803806
if (ret < min_ret) {
804807
if (ret == -EAGAIN && force_nonblock) {

0 commit comments

Comments
 (0)