[PATCH net] net: vrf: Remove direct access to skb->data

Subsystems: networking drivers, the rest, vrf

STALE3821d

3 messages, 3 authors, 2016-02-25 · open the first message on its own page

[PATCH net] net: vrf: Remove direct access to skb->data

From: David Ahern <hidden>
Date: 2016-02-23 18:11:34

Nik pointed that the VRF driver should be using skb_header_pointer
instead of accessing skb->data and bits beyond directly which can
be garbage.

Cc: Nikolay Aleksandrov <redacted>
Signed-off-by: David Ahern <redacted>
---
Dave: This should go into v4.4 stable as well.

 drivers/net/vrf.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 9ce088bb28ab..9a9fabb900c1 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -103,20 +103,23 @@ static struct dst_ops vrf_dst_ops = {
 #if IS_ENABLED(CONFIG_IPV6)
 static bool check_ipv6_frame(const struct sk_buff *skb)
 {
-	const struct ipv6hdr *ipv6h = (struct ipv6hdr *)skb->data;
-	size_t hlen = sizeof(*ipv6h);
+	const struct ipv6hdr *ipv6h;
+	struct ipv6hdr _ipv6h;
 	bool rc = true;
 
-	if (skb->len < hlen)
+	ipv6h = skb_header_pointer(skb, 0, sizeof(_ipv6h), &_ipv6h);
+	if (!ipv6h)
 		goto out;
 
 	if (ipv6h->nexthdr == NEXTHDR_ICMP) {
 		const struct icmp6hdr *icmph;
+		struct icmp6hdr _icmph;
 
-		if (skb->len < hlen + sizeof(*icmph))
+		icmph = skb_header_pointer(skb, sizeof(_ipv6h),
+					   sizeof(_icmph), &_icmph);
+		if (!icmph)
 			goto out;
 
-		icmph = (struct icmp6hdr *)(skb->data + sizeof(*ipv6h));
 		switch (icmph->icmp6_type) {
 		case NDISC_ROUTER_SOLICITATION:
 		case NDISC_ROUTER_ADVERTISEMENT:
-- 
2.1.4

Re: [PATCH net] net: vrf: Remove direct access to skb->data

From: Nikolay Aleksandrov <hidden>
Date: 2016-02-23 18:20:46

On 02/23/2016 07:10 PM, David Ahern wrote:
Nik pointed that the VRF driver should be using skb_header_pointer
instead of accessing skb->data and bits beyond directly which can
be garbage.

Cc: Nikolay Aleksandrov <redacted>
Signed-off-by: David Ahern <redacted>
---
Dave: This should go into v4.4 stable as well.

 drivers/net/vrf.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
Thanks for the quick fix,

Fixes: 35402e313663 ("net: Add IPv6 support to VRF device")

Signed-off-by: Nikolay Aleksandrov <redacted>

Re: [PATCH net] net: vrf: Remove direct access to skb->data

From: David Miller <davem@davemloft.net>
Date: 2016-02-25 20:36:19

From: David Ahern <redacted>
Date: Tue, 23 Feb 2016 10:10:26 -0800
Nik pointed that the VRF driver should be using skb_header_pointer
instead of accessing skb->data and bits beyond directly which can
be garbage.

Cc: Nikolay Aleksandrov <redacted>
Signed-off-by: David Ahern <redacted>
---
Dave: This should go into v4.4 stable as well.
Applied and queued up for -stable, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help