Skip to content

Commit 747a713

Browse files
gfreewinddavem330
authored andcommitted
ipvlan: Fix insufficient skb linear check for ipv6 icmp
In the function ipvlan_get_L3_hdr, current codes use pskb_may_pull to make sure the skb header has enough linear room for ipv6 header. But it would use the latter memory directly without linear check when it is icmp. So it still may access the unepxected memory in ipvlan_addr_lookup. Now invoke the pskb_may_pull again if it is ipv6 icmp. Signed-off-by: Gao Feng <gfree.wind@vip.163.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5fc9220 commit 747a713

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

drivers/net/ipvlan/ipvlan_core.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,26 @@ static void *ipvlan_get_L3_hdr(struct ipvl_port *port, struct sk_buff *skb, int
165165
/* Only Neighbour Solicitation pkts need different treatment */
166166
if (ipv6_addr_any(&ip6h->saddr) &&
167167
ip6h->nexthdr == NEXTHDR_ICMP) {
168+
struct icmp6hdr *icmph;
169+
170+
if (unlikely(!pskb_may_pull(skb, sizeof(*ip6h) + sizeof(*icmph))))
171+
return NULL;
172+
173+
ip6h = ipv6_hdr(skb);
174+
icmph = (struct icmp6hdr *)(ip6h + 1);
175+
176+
if (icmph->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) {
177+
/* Need to access the ipv6 address in body */
178+
if (unlikely(!pskb_may_pull(skb, sizeof(*ip6h) + sizeof(*icmph)
179+
+ sizeof(struct in6_addr))))
180+
return NULL;
181+
182+
ip6h = ipv6_hdr(skb);
183+
icmph = (struct icmp6hdr *)(ip6h + 1);
184+
}
185+
168186
*type = IPVL_ICMPV6;
169-
lyr3h = ip6h + 1;
187+
lyr3h = icmph;
170188
}
171189
break;
172190
}

0 commit comments

Comments
 (0)