summaryrefslogtreecommitdiff
path: root/drivers/net/hyperv/netvsc_bpf.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/hyperv/netvsc_bpf.c')
-rw-r--r--drivers/net/hyperv/netvsc_bpf.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/net/hyperv/netvsc_bpf.c b/drivers/net/hyperv/netvsc_bpf.c
index d60dcf6c9829..aa877da113f8 100644
--- a/drivers/net/hyperv/netvsc_bpf.c
+++ b/drivers/net/hyperv/netvsc_bpf.c
@@ -37,6 +37,12 @@ u32 netvsc_run_xdp(struct net_device *ndev, struct netvsc_channel *nvchan,
if (!prog)
goto out;
+ /* Ensure that the below memcpy() won't overflow the page buffer. */
+ if (len > ndev->mtu + ETH_HLEN) {
+ act = XDP_DROP;
+ goto out;
+ }
+
/* allocate page buffer for data */
page = alloc_page(GFP_ATOMIC);
if (!page) {