Skip to content

vsock/virtio: fix msg_iter desync on transmission failure#958

Open
blktests-ci[bot] wants to merge 3 commits into
linus-master_basefrom
series/1110932=>linus-master
Open

vsock/virtio: fix msg_iter desync on transmission failure#958
blktests-ci[bot] wants to merge 3 commits into
linus-master_basefrom
series/1110932=>linus-master

Conversation

@blktests-ci

@blktests-ci blktests-ci Bot commented Jun 13, 2026

Copy link
Copy Markdown

Pull request for series with
subject: vsock/virtio: fix msg_iter desync on transmission failure
version: 2
url: https://patchwork.kernel.org/project/linux-block/list/?series=1110932

@blktests-ci

blktests-ci Bot commented Jun 13, 2026

Copy link
Copy Markdown
Author

Upstream branch: 2a2974b
series: https://patchwork.kernel.org/project/linux-block/list/?series=1110932
version: 2

@blktests-ci

blktests-ci Bot commented Jun 13, 2026

Copy link
Copy Markdown
Author

Upstream branch: 062871f
series: https://patchwork.kernel.org/project/linux-block/list/?series=1110932
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/1110932=>linus-master branch from 574b987 to 4add41c Compare June 13, 2026 01:31
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from e48f9db to 199644a Compare June 17, 2026 11:41
@blktests-ci

blktests-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown
Author

Upstream branch: 5b33fc6
series: https://patchwork.kernel.org/project/linux-block/list/?series=1110932
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/1110932=>linus-master branch from 4add41c to f5712cb Compare June 17, 2026 11:50
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 199644a to e6d9eb8 Compare June 17, 2026 12:02
@blktests-ci

blktests-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown
Author

Upstream branch: 66affa3
series: https://patchwork.kernel.org/project/linux-block/list/?series=1110932
version: 2

@blktests-ci blktests-ci Bot force-pushed the series/1110932=>linus-master branch from f5712cb to bffc3fd Compare June 17, 2026 12:14
@blktests-ci

blktests-ci Bot commented Jun 22, 2026

Copy link
Copy Markdown
Author

Upstream branch: 66affa3
series: https://patchwork.kernel.org/project/linux-block/list/?series=1114953
version: 3

@blktests-ci blktests-ci Bot added V3 and removed V2 labels Jun 22, 2026
@blktests-ci blktests-ci Bot force-pushed the series/1110932=>linus-master branch from bffc3fd to 376e05b Compare June 22, 2026 23:11
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from e6d9eb8 to 7d8604f Compare June 24, 2026 01:11
@blktests-ci

blktests-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown
Author

Upstream branch: bade58e
series: https://patchwork.kernel.org/project/linux-block/list/?series=1114953
version: 3

@blktests-ci blktests-ci Bot force-pushed the series/1110932=>linus-master branch from 376e05b to 0d3edcc Compare June 24, 2026 01:18
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 7d8604f to 4cc45a3 Compare June 26, 2026 08:14
@blktests-ci

blktests-ci Bot commented Jun 26, 2026

Copy link
Copy Markdown
Author

Upstream branch: 4edcdef
series: https://patchwork.kernel.org/project/linux-block/list/?series=1114953
version: 3

@blktests-ci blktests-ci Bot force-pushed the series/1110932=>linus-master branch from 0d3edcc to 22d5bb7 Compare June 26, 2026 08:30
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 4cc45a3 to 90ffd56 Compare June 29, 2026 17:14
@blktests-ci

blktests-ci Bot commented Jun 29, 2026

Copy link
Copy Markdown
Author

Upstream branch: dc59e4f
series: https://patchwork.kernel.org/project/linux-block/list/?series=1114953
version: 3

@blktests-ci blktests-ci Bot force-pushed the series/1110932=>linus-master branch from 22d5bb7 to b2153c1 Compare June 29, 2026 17:35
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from 90ffd56 to d52f35a Compare July 2, 2026 19:18
@blktests-ci

blktests-ci Bot commented Jul 2, 2026

Copy link
Copy Markdown
Author

Upstream branch: 87320be
series: https://patchwork.kernel.org/project/linux-block/list/?series=1114953
version: 3

@blktests-ci blktests-ci Bot force-pushed the series/1110932=>linus-master branch from b2153c1 to d69b4f2 Compare July 2, 2026 19:55
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from d52f35a to a644c13 Compare July 6, 2026 08:28
tavip added 2 commits July 6, 2026 09:33
Export iov_iter_restore so that it can be used by modules.

This is needed by the virtio vsock transport (which can be built as a
module) to restore the msg_iter state when transmission fails.

Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Octavian Purdila <tavip@google.com>
When transmission fails in virtio_transport_send_pkt_info, the msg_iter
might have been partially advanced. If we don't restore it, the next
attempt to send data will use an incorrect iterator state, leading to
desync and warnings like "send_pkt() returns 0, but X expected".

Specifically, this can happen in the following scenario, triggered by
the syzkaller repro:

1. A write-only VMA (PROT_WRITE only) is partially populated by a
   prior TUN write that failed with -EIO but still faulted in some
   pages).
2. A vsock sendmmsg call with MSG_ZEROCOPY requests transmission of a
   buffer from this VMA.
3. The first packet (64KB) is sent successfully because the pages are
   populated.
4. The second packet allocation fails because GUP fast pins the first page
   but GUP slow fails on the next unpopulated page due to PROT_WRITE-only
   permissions.
5. The iterator is advanced by the partially successful GUP (68KB total
   advanced: 64KB from first packet + 4KB from second), but the send loop
   breaks and only reports 64KB sent. This creates a 4KB desync.
6. The next retry starts with a non-zero iov_offset, disabling zerocopy
   and falling back to copy mode.
7. In copy mode, the transmission succeeds for the next packets but
   exhausts the iterator early because of the desync.
8. The final retry sees an empty iterator but zerocopy is re-enabled
   (offset resets). It attempts to send the remaining bytes with zerocopy
   but pins 0 pages, creating an empty packet.
9. The transport sends the empty packet, triggering the warning because
   the returned bytes (header only) do not match the expected payload size.
10. The loop continues to spin, allocating ubuf_info each time, eventually
    exhausting sysctl_optmem_max and returning -ENOMEM to userspace.

Restore msg_iter to its original state before the packet allocation
and transmission attempt if they fail.

Fixes: e0718bd ("vsock: enable setting SO_ZEROCOPY")
Reported-by: syzbot+28e5f3d207b14bae122a@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=28e5f3d207b14bae122a
Assisted-by: gemini:gemini-3.1-pro
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Octavian Purdila <tavip@google.com>
@blktests-ci

blktests-ci Bot commented Jul 6, 2026

Copy link
Copy Markdown
Author

Upstream branch: 8cdeaa5
series: https://patchwork.kernel.org/project/linux-block/list/?series=1114953
version: 3

@blktests-ci blktests-ci Bot force-pushed the series/1110932=>linus-master branch from d69b4f2 to debba61 Compare July 6, 2026 09:33
@blktests-ci blktests-ci Bot force-pushed the linus-master_base branch from a644c13 to a2204c3 Compare July 7, 2026 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant