Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: gadget: g_ether: fix frame size check

Checking skb->len against ETH_FRAME_LEN assumes a 1514
ethernet frame size. With an 802.1Q VLAN header, ethernet
frame length can now be 1518. Validate frame length against that.

Signed-off-by: Ian Coolidge <iancoolidge@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Ian Coolidge and committed by
Felipe Balbi
23834e53 be44f1c8

+2 -1
+2 -1
drivers/usb/gadget/u_ether.c
··· 20 20 #include <linux/ctype.h> 21 21 #include <linux/etherdevice.h> 22 22 #include <linux/ethtool.h> 23 + #include <linux/if_vlan.h> 23 24 24 25 #include "u_ether.h" 25 26 ··· 296 295 while (skb2) { 297 296 if (status < 0 298 297 || ETH_HLEN > skb2->len 299 - || skb2->len > ETH_FRAME_LEN) { 298 + || skb2->len > VLAN_ETH_FRAME_LEN) { 300 299 dev->net->stats.rx_errors++; 301 300 dev->net->stats.rx_length_errors++; 302 301 DBG(dev, "rx length %d\n", skb2->len);