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)
committerJakub Kicinski <kuba@kernel.org>
Fri, 5 Feb 2021 02:59:17 +0000 (18:59 -0800)
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>
drivers/net/hyperv/netvsc.c
drivers/net/hyperv/rndis_filter.c

index 2350342b961fff457b1f682181eb38bca1cb0ddb..13bd48a75db7692fb5ab221ea587d60c088e325f 100644 (file)
@@ -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,
index 598713c0d5a8753f1692a82d7f68eb0b83e19375..3aab2b867fc0d082374683800e55b9a5ce418872 100644 (file)
@@ -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;
 }