[PATCH] Bluetooth: 6lowpan: fix uninit-value read in bt_xmit()

Jiale Yao posted 1 patch 1 week, 6 days ago
net/bluetooth/6lowpan.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] Bluetooth: 6lowpan: fix uninit-value read in bt_xmit()
Posted by Jiale Yao 1 week, 6 days ago
The bt_xmit() function lacks the skb->protocol check for IPv6 packets
that commit 3a5f3f7aff18 ("ieee802154: 6lowpan: only accept IPv6 packets
in lowpan_xmit()") added to the parallel IEEE 802.15.4 path.

A non-IPv6 packet (e.g. ETH_P_AOE) queued on a Bluetooth 6LoWPAN netdev
reaches setup_header(), which unconditionally treats the skb as IPv6 and
reads 16 bytes of uninitialized memory, causing a KMSAN uninit-value bug.

Add the missing protocol check to reject non-IPv6 packets before they
reach setup_header().

Fixes: 3a5f3f7aff18bcc36a57839cf50cf0cc8de707f3 ("ieee802154: 6lowpan: only accept IPv6 packets in lowpan_xmit()")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
 net/bluetooth/6lowpan.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index d504a363a30f..5729c6fbaf15 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -524,6 +524,11 @@ static netdev_tx_t bt_xmit(struct sk_buff *skb, struct net_device *netdev)
 	 *   0 - this is a multicast packet
 	 *   1 - this is unicast packet
 	 */
+	if (skb->protocol != htons(ETH_P_IPV6)) {
+		kfree_skb(skb);
+		return NET_XMIT_DROP;
+	}
+
 	err = setup_header(skb, netdev, &addr, &addr_type);
 	if (err < 0) {
 		kfree_skb(skb);
-- 
2.34.1