Skip to content

Commit af65ea4

Browse files
committed
Merge branch 'tap-tun-harden-by-dropping-short-frame'
Dongli Zhang says: ==================== tap/tun: harden by dropping short frame This is to harden all of tap/tun to avoid any short frame smaller than the Ethernet header (ETH_HLEN). While the xen-netback already rejects short frame smaller than ETH_HLEN ... 914 static void xenvif_tx_build_gops(struct xenvif_queue *queue, 915 int budget, 916 unsigned *copy_ops, 917 unsigned *map_ops) 918 { ... ... 1007 if (unlikely(txreq.size < ETH_HLEN)) { 1008 netdev_dbg(queue->vif->dev, 1009 "Bad packet size: %d\n", txreq.size); 1010 xenvif_tx_err(queue, &txreq, extra_count, idx); 1011 break; 1012 } ... the short frame may not be dropped by vhost-net/tap/tun. This fixes CVE-2024-41090 and CVE-2024-41091. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 61ab751 + 0495848 commit af65ea4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

drivers/net/tap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,11 @@ static int tap_get_user_xdp(struct tap_queue *q, struct xdp_buff *xdp)
11771177
struct sk_buff *skb;
11781178
int err, depth;
11791179

1180+
if (unlikely(xdp->data_end - xdp->data < ETH_HLEN)) {
1181+
err = -EINVAL;
1182+
goto err;
1183+
}
1184+
11801185
if (q->flags & IFF_VNET_HDR)
11811186
vnet_hdr_len = READ_ONCE(q->vnet_hdr_sz);
11821187

drivers/net/tun.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,6 +2455,9 @@ static int tun_xdp_one(struct tun_struct *tun,
24552455
bool skb_xdp = false;
24562456
struct page *page;
24572457

2458+
if (unlikely(datasize < ETH_HLEN))
2459+
return -EINVAL;
2460+
24582461
xdp_prog = rcu_dereference(tun->xdp_prog);
24592462
if (xdp_prog) {
24602463
if (gso->gso_type) {

0 commit comments

Comments
 (0)