From dbbbbcd6a31c838165cb72aecb42d8b395c65068 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 7 Aug 2024 15:17:07 +0200 Subject: Merging upstream version 6.9.12. Signed-off-by: Daniel Baumann --- drivers/net/tap.c | 5 +++++ drivers/net/tun.c | 3 +++ 2 files changed, 8 insertions(+) (limited to 'drivers/net') diff --git a/drivers/net/tap.c b/drivers/net/tap.c index 9f0495e8df..feeeac715c 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -1177,6 +1177,11 @@ static int tap_get_user_xdp(struct tap_queue *q, struct xdp_buff *xdp) struct sk_buff *skb; int err, depth; + if (unlikely(xdp->data_end - xdp->data < ETH_HLEN)) { + err = -EINVAL; + goto err; + } + if (q->flags & IFF_VNET_HDR) vnet_hdr_len = READ_ONCE(q->vnet_hdr_sz); diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 92da8c03d9..f0f3fa1fc6 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -2451,6 +2451,9 @@ static int tun_xdp_one(struct tun_struct *tun, bool skb_xdp = false; struct page *page; + if (unlikely(datasize < ETH_HLEN)) + return -EINVAL; + xdp_prog = rcu_dereference(tun->xdp_prog); if (xdp_prog) { if (gso->gso_type) { -- cgit v1.2.3