netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] 6lowpan: iphc: reset mac_header after decompress to fix panic
@ 2018-06-19 23:44 Michael Scott
  2018-07-02 18:54 ` Alexander Aring
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Michael Scott @ 2018-06-19 23:44 UTC (permalink / raw)
  Cc: Michael Scott, Alexander Aring, Jukka Rissanen, David S. Miller,
	linux-bluetooth, linux-wpan, netdev, linux-kernel

After decompression of 6lowpan socket data, an IPv6 header is inserted
before the existing socket payload.  After this, we reset the
network_header value of the skb to account for the difference in payload
size from prior to decompression + the addition of the IPv6 header.

However, we fail to reset the mac_header value.

Leaving the mac_header value untouched here, can cause a calculation
error in net/packet/af_packet.c packet_rcv() function when an
AF_PACKET socket is opened in SOCK_RAW mode for use on a 6lowpan
interface.

On line 2088, the data pointer is moved backward by the value returned
from skb_mac_header().  If skb->data is adjusted so that it is before
the skb->head pointer (which can happen when an old value of mac_header
is left in place) the kernel generates a panic in net/core/skbuff.c
line 1717.

This panic can be generated by BLE 6lowpan interfaces (such as bt0) and
802.15.4 interfaces (such as lowpan0) as they both use the same 6lowpan
sources for compression and decompression.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
---
 net/6lowpan/iphc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index 6b1042e21656..52fad5dad9f7 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -770,6 +770,7 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
 		hdr.hop_limit, &hdr.daddr);
 
 	skb_push(skb, sizeof(hdr));
+	skb_reset_mac_header(skb);
 	skb_reset_network_header(skb);
 	skb_copy_to_linear_data(skb, &hdr, sizeof(hdr));
 
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-07-06 10:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-19 23:44 [PATCH] 6lowpan: iphc: reset mac_header after decompress to fix panic Michael Scott
2018-07-02 18:54 ` Alexander Aring
2018-07-02 19:45   ` Michael Scott
2018-07-02 20:43     ` Alexander Aring
2018-07-02 21:31       ` Alexander Aring
2018-07-03 13:48 ` Alexander Aring
2018-07-05 11:34 ` Stefan Schmidt
2018-07-05 11:42 ` Jukka Rissanen
2018-07-05 11:59 ` Stefan Schmidt
2018-07-06 10:46 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).