hv_sock: Return -EIO for malformed/short packets
Subsystems (7)
Dexuan Cui
maintainerPATCH v2 1/1 hv_sock: Return -EIO for malformed/short packets
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.
---
Commit f63152958994 is currently only in net.git's master branch.
Changes since v1:
Integrated comments from Stefano Garzarella:
1) access 'vsk' directly:
s/hvs->vsk->peer_shutdown/vsk->peer_shutdown/
2) test the error condition first and return -EIO for that.
NO other changes.
net/vmw_vsock/hyperv_transport.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
net/vmw_vsock/hyperv_transport.c +18 -9
@@ -704,17 +704,26 @@ static s64 hvs_stream_has_data(struct vsock_sock *vsk)if (hvs->recv_desc) {/* Here hvs->recv_data_len is 0, so hvs->recv_desc must * be NULL unless it points to the 0-byte-payload FIN -* packet: see hvs_update_recv_data(). +* packet or a malformed/short packet: see +* hvs_update_recv_data(). * -* Here all the payload has been dequeued, but -* hvs_channel_readable_payload() still returns 1, -* because the VMBus ringbuffer's read_index is not -* updated for the FIN packet: hvs_stream_dequeue() -> -* hv_pkt_iter_next() updates the cached priv_read_index -* but has no opportunity to update the read_index in -* hv_pkt_iter_close() as hvs_stream_has_data() returns -* 0 for the FIN packet, so it won't get dequeued. +* If hvs->recv_desc points to the FIN packet, here all +* the payload has been dequeued and the peer_shutdown +* flag is set, but hvs_channel_readable_payload() still +* returns 1, because the VMBus ringbuffer's read_index +* is not updated for the FIN packet: +* hvs_stream_dequeue() -> hv_pkt_iter_next() updates +* the cached priv_read_index but has no opportunity to +* update the read_index in hv_pkt_iter_close() as +* hvs_stream_has_data() returns 0 for the FIN packet, +* so it won't get dequeued. +* +* In case hvs->recv_desc points to a malformed/short +* packet, return -EIO. */ +if (!(vsk->peer_shutdown &SEND_SHUTDOWN )) +return -EIO ; +return 0 ; }
Signature · 1 line
2.49.0
Quoted 14 lines · Dexuan Cui
Commit
f63152958994fixes 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")Signed-off-by Dexuan Cui <[email protected]>---
Commit
f63152958994is currently only in net.git's master branch.Changes since v1:
Integrated comments from Stefano Garzarella:
Quoted 6 lines
1) access 'vsk' directly:
s/hvs->vsk->peer_shutdown/vsk->peer_shutdown/2) test the error condition first and return
-EIOfor that.NO other changes.
Thanks, LGTM!
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Wed, 22 Apr 2026 23:48:11 -0700 you wrote:
Commit
f63152958994fixes 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")Signed-off-by Dexuan Cui <[email protected]>[...]
Here is the summary with links:
- [net,v2] hv_sock: Return -EIO for malformed/short packets
https://git.kernel.org/netdev/net/c/3d1f20727a63
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html