Skip to content

Commit 12bc8df

Browse files
andrea-parrikuba-moo
authored andcommitted
hv_netvsc: Reset the RSC count if NVSP_STAT_FAIL in netvsc_receive()
Commit 4414418 ("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: 4414418 ("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>
1 parent 52cbd23 commit 12bc8df

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

drivers/net/hyperv/netvsc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,11 @@ static int netvsc_receive(struct net_device *ndev,
12621262
ret = rndis_filter_receive(ndev, net_device,
12631263
nvchan, data, buflen);
12641264

1265-
if (unlikely(ret != NVSP_STAT_SUCCESS))
1265+
if (unlikely(ret != NVSP_STAT_SUCCESS)) {
1266+
/* Drop incomplete packet */
1267+
nvchan->rsc.cnt = 0;
12661268
status = NVSP_STAT_FAIL;
1269+
}
12671270
}
12681271

12691272
enq_receive_complete(ndev, net_device, q_idx,

drivers/net/hyperv/rndis_filter.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,6 @@ static int rndis_filter_receive_data(struct net_device *ndev,
509509
return ret;
510510

511511
drop:
512-
/* Drop incomplete packet */
513-
nvchan->rsc.cnt = 0;
514512
return NVSP_STAT_FAIL;
515513
}
516514

0 commit comments

Comments
 (0)