Skip to content

hv_sock: Report EOF instead of -EIO for FIN#124

Open
dcui wants to merge 2 commits intomicrosoft:product/hcl-main/6.18from
dcui:decui/product/hcl-main/6.18
Open

hv_sock: Report EOF instead of -EIO for FIN#124
dcui wants to merge 2 commits intomicrosoft:product/hcl-main/6.18from
dcui:decui/product/hcl-main/6.18

Conversation

@dcui
Copy link
Copy Markdown
Contributor

@dcui dcui commented Apr 20, 2026

Commit f0c5827 unluckily causes a regression for the FIN packet, and the final read syscall gets an error rather than 0.

Ideally, we would want to fix hvs_channel_readable_payload() so that it could return 0 in the FIN scenario, but it's not good for the hv_sock driver to use the VMBus ringbuffer's cached priv_read_index, which is internal data in the VMBus driver.

Fix the regression in hv_sock by returning 0 rather than -EIO.

Fixes: f0c5827 ("hv_sock: Return the readable bytes in hvs_stream_has_data()")
Cc: stable@vger.kernel.org
Reported-by: Ben Hillis Ben.Hillis@microsoft.com
Reported-by: Mitchell Levy levymitchell0@gmail.com
Signed-off-by: Dexuan Cui decui@microsoft.com

( As of 4/20/2026, the v2 patch is not in the mainline kernel yet:
https://lore.kernel.org/linux-hyperv/aeHor6IpXUDyMtnW@sgarzare-redhat/T/#t )

Copilot AI review requested due to automatic review settings April 20, 2026 19:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Hyper-V vsock regression where receiving a FIN could cause the final read() to return -EIO instead of EOF (0), by adjusting hvs_stream_has_data() FIN handling.

Changes:

  • Update hvs_stream_has_data() to return 0 (EOF) instead of -EIO when a FIN has been encountered and recv_desc is already set.
  • Remove the local need_refill flag and replace the prior error return with a FIN-specific early return.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread net/vmw_vsock/hyperv_transport.c
benhillis
benhillis previously approved these changes Apr 20, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread net/vmw_vsock/hyperv_transport.c Outdated
@dcui dcui force-pushed the decui/product/hcl-main/6.18 branch from e05e03e to e04639f Compare April 21, 2026 02:38
@dcui dcui requested a review from Copilot April 21, 2026 02:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dcui
Copy link
Copy Markdown
Contributor Author

dcui commented Apr 22, 2026

The first patch is in the upstream net.git tree:
hv_sock: Report EOF instead of -EIO for FIN:
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=f6315295899415f1ddcf39f7c9cb46d25e2c6c6a

A second patch is pending in review:
https://lwn.net/ml/linux-kernel/20260421174931.1152238-1-decui%40microsoft.com/

@dcui dcui requested a review from Copilot April 22, 2026 01:06
@dcui dcui force-pushed the decui/product/hcl-main/6.18 branch from c0b55c1 to 699e374 Compare April 22, 2026 01:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Commit f0c5827 unluckily causes a regression for the FIN packet,
and the final read syscall gets an error rather than 0.

Ideally, we would want to fix hvs_channel_readable_payload() so that it
could return 0 in the FIN scenario, but it's not good for the hv_sock
driver to use the VMBus ringbuffer's cached priv_read_index, which is
internal data in the VMBus driver.

Fix the regression in hv_sock by returning 0 rather than -EIO.

Fixes: f0c5827 ("hv_sock: Return the readable bytes in hvs_stream_has_data()")
Cc: stable@vger.kernel.org
Reported-by: Ben Hillis <Ben.Hillis@microsoft.com>
Reported-by: Mitchell Levy <levymitchell0@gmail.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20260416191433.840637-1-decui@microsoft.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

As of today (4/21/2026), the patch is in the upstream net.git tree:
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=f6315295899415f1ddcf39f7c9cb46d25e2c6c6a
@dcui dcui force-pushed the decui/product/hcl-main/6.18 branch from 699e374 to 6c811b3 Compare April 22, 2026 01:13
@dcui dcui requested a review from Copilot April 22, 2026 01:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Commit f63152958994 fixes a regression, however it fails to report an
error for malformed/short packets -- normally we should never see such
packets, but let's report an error for them just in case.

Fixes: f63152958994 ("hv_sock: Report EOF instead of -EIO for FIN")
Cc: stable@vger.kernel.org
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20260423064811.1371749-1-decui@microsoft.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

As of today (4/23/2026), the patch is in the upstream net.git tree:
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=3d1f20727a635811f6b77801a7b57b8995268abd
@dcui dcui force-pushed the decui/product/hcl-main/6.18 branch from 6c811b3 to a1deac5 Compare April 23, 2026 19:49
@dcui dcui requested a review from Copilot April 23, 2026 19:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants