Commit 965801e1 authored by Daniel Borkmann's avatar Daniel Borkmann Committed by David S. Miller

net: 6lowpan: fix lowpan_header_create non-compression memcpy call

In function lowpan_header_create(), we invoke the following code
construct:

  struct ipv6hdr *hdr;
  ...
  hdr = ipv6_hdr(skb);
  ...
  if (...)
    memcpy(hc06_ptr + 1, &hdr->flow_lbl[1], 2);
  else
    memcpy(hc06_ptr, &hdr, 4);

Where the else path of the condition, that is, non-compression
path, calls memcpy() with a pointer to struct ipv6hdr *hdr as
source, thus two levels of indirection. This cannot be correct,
and likely only one level of pointer was intended as source
buffer for memcpy() here.

Fixes: 44331fe2 ("IEEE802.15.4: 6LoWPAN basic support")
Signed-off-by: default avatarDaniel Borkmann <dborkman@redhat.com>
Cc: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Werner Almesberger <werner@almesberger.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7d30622d
...@@ -547,7 +547,7 @@ static int lowpan_header_create(struct sk_buff *skb, ...@@ -547,7 +547,7 @@ static int lowpan_header_create(struct sk_buff *skb,
hc06_ptr += 3; hc06_ptr += 3;
} else { } else {
/* compress nothing */ /* compress nothing */
memcpy(hc06_ptr, &hdr, 4); memcpy(hc06_ptr, hdr, 4);
/* replace the top byte with new ECN | DSCP format */ /* replace the top byte with new ECN | DSCP format */
*hc06_ptr = tmp; *hc06_ptr = tmp;
hc06_ptr += 4; hc06_ptr += 4;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment