diff options
author | Glenn Ruben Bakke <glenn.ruben.bakke@nordicsemi.no> | 2016-01-13 10:41:42 -0500 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2016-01-23 07:21:47 -0500 |
commit | 4c58f3282e3de43d34f8955f8eca676294380bf9 (patch) | |
tree | dbb0b1fe7cf4ebe4fe1496bc0d2e0e969ae3eb16 /net | |
parent | 00ae40e71d85ea3fed1b906951ffd80e0321a96d (diff) |
Bluetooth: 6lowpan: Fix kernel NULL pointer dereferences
The fixes provided in this patch assigns a valid net_device structure to
skb before dispatching it for further processing.
Scenario #1:
============
Bluetooth 6lowpan receives an uncompressed IPv6 header, and dispatches it
to netif. The following error occurs:
Null pointer dereference error #1 crash log:
[ 845.854013] BUG: unable to handle kernel NULL pointer dereference at
0000000000000048
[ 845.855785] IP: [<ffffffff816e3d36>] enqueue_to_backlog+0x56/0x240
...
[ 845.909459] Call Trace:
[ 845.911678] [<ffffffff816e3f64>] netif_rx_internal+0x44/0xf0
The first modification fixes the NULL pointer dereference error by
assigning dev to the local_skb in order to set a valid net_device before
processing the skb by netif_rx_ni().
Scenario #2:
============
Bluetooth 6lowpan receives an UDP compressed message which needs further
decompression by nhc_udp. The following error occurs:
Null pointer dereference error #2 crash log:
[ 63.295149] BUG: unable to handle kernel NULL pointer dereference at
0000000000000840
[ 63.295931] IP: [<ffffffffc0559540>] udp_uncompress+0x320/0x626
[nhc_udp]
The second modification fixes the NULL pointer dereference error by
assigning dev to the local_skb in the case of a udp compressed packet.
The 6lowpan udp_uncompress function expects that the net_device is set in
the skb when checking lltype.
Signed-off-by: Glenn Ruben Bakke <glenn.ruben.bakke@nordicsemi.no>
Signed-off-by: Lukasz Duda <lukasz.duda@nordicsemi.no>
Acked-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Cc: stable@vger.kernel.org # 4.4+
Diffstat (limited to 'net')
-rw-r--r-- | net/bluetooth/6lowpan.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index d040365ba98e..58e1b3c97ed7 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c | |||
@@ -317,6 +317,7 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev, | |||
317 | 317 | ||
318 | local_skb->protocol = htons(ETH_P_IPV6); | 318 | local_skb->protocol = htons(ETH_P_IPV6); |
319 | local_skb->pkt_type = PACKET_HOST; | 319 | local_skb->pkt_type = PACKET_HOST; |
320 | local_skb->dev = dev; | ||
320 | 321 | ||
321 | skb_set_transport_header(local_skb, sizeof(struct ipv6hdr)); | 322 | skb_set_transport_header(local_skb, sizeof(struct ipv6hdr)); |
322 | 323 | ||
@@ -335,6 +336,8 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev, | |||
335 | if (!local_skb) | 336 | if (!local_skb) |
336 | goto drop; | 337 | goto drop; |
337 | 338 | ||
339 | local_skb->dev = dev; | ||
340 | |||
338 | ret = iphc_decompress(local_skb, dev, chan); | 341 | ret = iphc_decompress(local_skb, dev, chan); |
339 | if (ret < 0) { | 342 | if (ret < 0) { |
340 | kfree_skb(local_skb); | 343 | kfree_skb(local_skb); |
@@ -343,7 +346,6 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev, | |||
343 | 346 | ||
344 | local_skb->protocol = htons(ETH_P_IPV6); | 347 | local_skb->protocol = htons(ETH_P_IPV6); |
345 | local_skb->pkt_type = PACKET_HOST; | 348 | local_skb->pkt_type = PACKET_HOST; |
346 | local_skb->dev = dev; | ||
347 | 349 | ||
348 | if (give_skb_to_upper(local_skb, dev) | 350 | if (give_skb_to_upper(local_skb, dev) |
349 | != NET_RX_SUCCESS) { | 351 | != NET_RX_SUCCESS) { |