Skip to content

Commit dca5161

Browse files
kelleymhPaolo Abeni
authored andcommitted
hv_netvsc: Check status in SEND_RNDIS_PKT completion message
Completion responses to SEND_RNDIS_PKT messages are currently processed regardless of the status in the response, so that resources associated with the request are freed. While this is appropriate, code bugs that cause sending a malformed message, or errors on the Hyper-V host, go undetected. Fix this by checking the status and outputting a rate-limited message if there is an error. Signed-off-by: Michael Kelley <mikelley@microsoft.com> Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com> Link: https://lore.kernel.org/r/1676264881-48928-1-git-send-email-mikelley@microsoft.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 991cbd4 commit dca5161

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/net/hyperv/netvsc.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ static void netvsc_send_completion(struct net_device *ndev,
851851
u32 msglen = hv_pkt_datalen(desc);
852852
struct nvsp_message *pkt_rqst;
853853
u64 cmd_rqst;
854+
u32 status;
854855

855856
/* First check if this is a VMBUS completion without data payload */
856857
if (!msglen) {
@@ -922,6 +923,23 @@ static void netvsc_send_completion(struct net_device *ndev,
922923
break;
923924

924925
case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE:
926+
if (msglen < sizeof(struct nvsp_message_header) +
927+
sizeof(struct nvsp_1_message_send_rndis_packet_complete)) {
928+
if (net_ratelimit())
929+
netdev_err(ndev, "nvsp_rndis_pkt_complete length too small: %u\n",
930+
msglen);
931+
return;
932+
}
933+
934+
/* If status indicates an error, output a message so we know
935+
* there's a problem. But process the completion anyway so the
936+
* resources are released.
937+
*/
938+
status = nvsp_packet->msg.v1_msg.send_rndis_pkt_complete.status;
939+
if (status != NVSP_STAT_SUCCESS && net_ratelimit())
940+
netdev_err(ndev, "nvsp_rndis_pkt_complete error status: %x\n",
941+
status);
942+
925943
netvsc_send_tx_complete(ndev, net_device, incoming_channel,
926944
desc, budget);
927945
break;

0 commit comments

Comments
 (0)