Skip to contentSkip to conversation

hv_netvsc: Reset the RSC count if NVSP_STAT_FAIL in netvsc_receive()

PATCH Applied Andrea Parri (Microsoft) 3 participants 3 messages Feb 3, 2021 – Feb 5, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hv_netvsc: Reset the RSC count if NVSP_STAT_FAIL in netvsc_receive()

Commit 44144185951a0f ("hv_netvsc: Add validation for untrusted Hyper-V values") added validation to rndis_filter_receive_data() (and rndis_filter_receive()) which introduced NVSP_STAT_FAIL-scenarios where the count is not updated/reset. Fix this omission, and prevent similar scenarios from occurring in the future.

Cc "David S. Miller" <[email protected]>
Cc Jakub Kicinski <[email protected]>
Fixes 44144185951a0f ("hv_netvsc: Add validation for untrusted Hyper-V values")
---
 drivers/net/hyperv/netvsc.c       | 5 ++++-
 drivers/net/hyperv/rndis_filter.c | 2 --
 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/net/hyperv/netvsc.c +4 -1
index 2350342b961ff..13bd48a75db76 100644
@@ -1262,8 +1262,11 @@ static int netvsc_receive(struct net_device *ndev,
 		ret = rndis_filter_receive(ndev, net_device,
 					   nvchan, data, buflen);
 
-		if (unlikely(ret != NVSP_STAT_SUCCESS))
+		if (unlikely(ret != NVSP_STAT_SUCCESS)) {
+			/* Drop incomplete packet */
+			nvchan->rsc.cnt = 0;
 			status = NVSP_STAT_FAIL;
+		}
 	}
 
 	enq_receive_complete(ndev, net_device, q_idx,
drivers/net/hyperv/rndis_filter.c +0 -2
index 598713c0d5a87..3aab2b867fc0d 100644
@@ -509,8 +509,6 @@ static int rndis_filter_receive_data(struct net_device *ndev,
 	return ret;
 
 drop:
-	/* Drop incomplete packet */
-	nvchan->rsc.cnt = 0;
 	return NVSP_STAT_FAIL;
 }
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Andrea Parri (Microsoft)

Commit 44144185951a0f ("hv_netvsc: Add validation for untrusted Hyper-V values") added validation to rndis_filter_receive_data() (and rndis_filter_receive()) which introduced NVSP_STAT_FAIL-scenarios where the count is not updated/reset. Fix this omission, and prevent similar scenarios from occurring in the future.

Quoted 6 lines
Cc "David S. Miller" <[email protected]>
Cc Jakub Kicinski <[email protected]>
Fixes 44144185951a0f ("hv_netvsc: Add validation for untrusted Hyper-V values")
#2 lore raw
In reply to Andrea Parri (Microsoft)
This patch was applied to netdev/net.git (refs/heads/master):

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

Quoted 6 lines · On Wed, 3 Feb 2021 12:36:02 +0100 you wrote:

Commit 44144185951a0f ("hv_netvsc: Add validation for untrusted Hyper-V values") added validation to rndis_filter_receive_data() (and rndis_filter_receive()) which introduced NVSP_STAT_FAIL-scenarios where the count is not updated/reset. Fix this omission, and prevent similar scenarios from occurring in the future.

Quoted 8 lines
Cc "David S. Miller" <[email protected]>
Cc Jakub Kicinski <[email protected]>
Fixes 44144185951a0f ("hv_netvsc: Add validation for untrusted Hyper-V values")

[...]

Here is the summary with links:
- [net] hv_netvsc: Reset the RSC count if NVSP_STAT_FAIL in netvsc_receive()

    https://git.kernel.org/netdev/net/c/12bc8dfb83b5

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html