History

vxlan: use pskb_network_may_pull() in route_shortcircuit()

route_shortcircuit() currently calls pskb_may_pull(skb, sizeof(struct iphdr)) (or ipv6hdr), which checks if bytes are available starting from skb->data. However, in vxlan_xmit(), skb->data points to the MAC header, so skb_network_offset(skb) is ETH_HLEN (14 bytes). Using pskb_may_pull(skb, 20) only checks 20 bytes from skb->data (which is 14 bytes MAC header + 6 bytes of IP header), leaving the rest of the IP header potentially un-pulled in non-linear frags. Subsequent dereferences of ip_hdr(skb)->daddr can read beyond the pulled linear buffer length. Fix this by using pskb_network_may_pull(), which adds skb_network_offset(skb) to the length check to ensure the full network header is present in the linear buffer.

Eric Dumazet committed 3 months ago

Commit 26bb2dd1 parent 8eca4111 file · +2 −2Browse files

Unified · Split

drivers/net/vxlan/vxlan_core.c+2−2
@@ -2111,7 +2111,7 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb) · 2110 unmodified lines
2111 {2111 {
2112 struct iphdr *pip;2112 struct iphdr *pip;
2113 2113
2114 if (!pskb_may_pull(skb, sizeof(struct iphdr)))2114 if (!pskb_network_may_pull(skb, sizeof(struct iphdr)))
2115 return false;2115 return false;
2116 pip = ip_hdr(skb);2116 pip = ip_hdr(skb);
2117 n = neigh_lookup(&arp_tbl, &pip->daddr, dev);2117 n = neigh_lookup(&arp_tbl, &pip->daddr, dev);
@@ -2137,7 +2137,7 @@ static bool route_shortcircuit(struct net_device *dev, struct sk_buff *skb) · 19 unmodified lines
2137 */2137 */
2138 if (!ipv6_mod_enabled())2138 if (!ipv6_mod_enabled())
2139 return false;2139 return false;
2140 if (!pskb_may_pull(skb, sizeof(struct ipv6hdr)))2140 if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr)))
2141 return false;2141 return false;
2142 pip6 = ipv6_hdr(skb);2142 pip6 = ipv6_hdr(skb);
2143 n = neigh_lookup(&nd_tbl, &pip6->daddr, dev);2143 n = neigh_lookup(&nd_tbl, &pip6->daddr, dev);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t