hv_netvsc: Reset the RSC count if NVSP_STAT_FAIL in netvsc_receive()
authorAndrea Parri (Microsoft) <parri.andrea@gmail.com>
Wed, 3 Feb 2021 11:36:02 +0000 (12:36 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Feb 2021 10:02:26 +0000 (11:02 +0100)
[ Upstream commit 12bc8dfb83b5292fe387b795210018b7632ee08b ]

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.

Reported-by: Juan Vazquez <juvazq@microsoft.com>
Signed-off-by: Andrea Parri (Microsoft) <parri.andrea@gmail.com>
Fixes: 44144185951a0f ("hv_netvsc: Add validation for untrusted Hyper-V values")
Reviewed-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Link: https://lore.kernel.org/r/20210203113602.558916-1-parri.andrea@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/hyperv/netvsc.c
drivers/net/hyperv/rndis_filter.c

index 0c3de94b51787b852b4d3e86b2a222d3051ce139..6a7ab930ef70d8bca496bfad20c36d9e86a77813 100644 (file)
@@ -1253,8 +1253,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,
index b22e47bcfeca1a94c43cb5defe35579dfcfae756..90bc0008fa2fd7172b551a8ae704bef1fdcdd61a 100644 (file)
@@ -508,8 +508,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;
 }