From: Nathan Rebello <nathan.c.rebello@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, marcel@holtmann.org,
stable@vger.kernel.org, kyungtae.kim@dartmouth.edu,
Nathan Rebello <nathan.c.rebello@gmail.com>
Subject: [PATCH v3] Bluetooth: ISO: fix NULL deref in iso_recv() ISO_END handling
Date: Mon, 30 Mar 2026 18:10:15 -0400 [thread overview]
Message-ID: <20260330221015.322337-1-nathan.c.rebello@gmail.com> (raw)
In-Reply-To: <20260328035813.296410-1-nathan.c.rebello@gmail.com>
The ISO_CONT case in iso_recv() properly checks for unexpected
continuation frames and oversized fragments before accessing
conn->rx_skb. The ISO_END case lacks both checks.
When an ISO_END packet arrives without a preceding ISO_START:
- conn->rx_skb is NULL (never allocated)
- skb_put(conn->rx_skb, ...) dereferences NULL -> kernel crash
When an ISO_END fragment length does not exactly match the
remaining expected length:
- the reassembly is malformed and must be rejected
KASAN confirmed the NULL-deref on kernel 7.0.0-rc5 via VHCI:
general protection fault, probably for non-canonical address 0xdffffc0000000018
KASAN: null-ptr-deref in range [0x00000000000000c0-0x00000000000000c7]
CPU: 0 UID: 0 PID: 72 Comm: kworker/u9:0 Not tainted 7.0.0-rc5
Workqueue: hci0 hci_rx_work
RIP: 0010:skb_put+0x27/0x1a0
Call Trace:
<TASK>
iso_recv+0x5e0/0xee0
hci_rx_work+0x226/0x730
process_one_work+0x633/0x1060
worker_thread+0x45b/0xd10
kthread+0x2c6/0x3b0
ret_from_fork+0x38d/0x5c0
</TASK>
Kernel panic - not syncing: Fatal exception
Fix by adding validation to the ISO_END case: reject end frames
when no rx_skb reassembly buffer exists, and reject end fragments
whose length does not exactly complete the expected reassembly.
Fixes: ccf74f2390d6 ("Bluetooth: Add ISO Socket")
Cc: stable@vger.kernel.org
Signed-off-by: Nathan Rebello <nathan.c.rebello@gmail.com>
---
Changes in v3:
- Check !conn->rx_skb instead of !conn->rx_len to correctly
handle the case where an ISO_CONT fragment completes rx_len
but a valid zero-length ISO_END still follows.
Changes in v2:
- Tighten end fragment check from (skb->len > conn->rx_len) to
(skb->len != conn->rx_len): the end fragment must exactly
complete the reassembly.
net/bluetooth/iso.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/net/bluetooth/iso.c b/net/bluetooth/iso.c
index be145e273..7c57b1d22 100644
--- a/net/bluetooth/iso.c
+++ b/net/bluetooth/iso.c
@@ -2587,6 +2587,20 @@ int iso_recv(struct hci_dev *hdev, u16 handle, struct sk_buff *skb, u16 flags)
break;
case ISO_END:
+ if (!conn->rx_skb) {
+ BT_ERR("Unexpected end frame (len %d)", skb->len);
+ goto drop;
+ }
+
+ if (skb->len != conn->rx_len) {
+ BT_ERR("End fragment length mismatch (len %d, expected %d)",
+ skb->len, conn->rx_len);
+ kfree_skb(conn->rx_skb);
+ conn->rx_skb = NULL;
+ conn->rx_len = 0;
+ goto drop;
+ }
+
skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len),
skb->len);
conn->rx_len -= skb->len;
--
2.43.0
next prev parent reply other threads:[~2026-03-30 22:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-28 3:58 [PATCH] Bluetooth: ISO: fix NULL deref in iso_recv() ISO_END handling Nathan Rebello
2026-03-28 4:22 ` bluez.test.bot
2026-03-30 21:21 ` [PATCH v2] " Nathan Rebello
2026-03-30 21:57 ` [v2] " bluez.test.bot
2026-03-30 22:10 ` Nathan Rebello [this message]
2026-03-30 22:51 ` [v3] " bluez.test.bot
2026-04-09 20:21 ` bluez.test.bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260330221015.322337-1-nathan.c.rebello@gmail.com \
--to=nathan.c.rebello@gmail.com \
--cc=kyungtae.kim@dartmouth.edu \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox