* [PATCH] Bluetooth: L2CAP: validate frame length before control and FCS access
@ 2026-09-15 16:02 Aldo Ariel Panzardo
2026-09-16 18:00 ` patchwork-bot+bluetooth
0 siblings, 1 reply; 2+ messages in thread
From: Aldo Ariel Panzardo @ 2026-09-15 16:02 UTC (permalink / raw)
To: Luiz Augusto von Dentz
Cc: linux-bluetooth, linux-kernel, stable, Aldo Ariel Panzardo
l2cap_data_rcv() unpacks either a two-byte or four-byte control field
without first ensuring that it is present. A short ERTM or streaming-mode
frame can therefore cause an out-of-bounds read.
There is a second short-frame case when CRC16 is enabled. After the
control field is pulled, l2cap_check_fcs() subtracts two from skb->len
without checking it. If fewer than two bytes remain, the subtraction
wraps; skb_trim() leaves the buffer unchanged and the subsequent FCS
load reads past the logical end of the frame.
Validate that the frame contains both its control field and, when
enabled, its FCS before either field is accessed.
Fixes: 1c2acffb76d4 ("Bluetooth: Add initial support for ERTM packets transfers")
Fixes: fcc203c30d72 ("Bluetooth: Add support for FCS option to L2CAP")
Cc: stable@vger.kernel.org
Signed-off-by: Aldo Ariel Panzardo <qwe.aldo@gmail.com>
---
net/bluetooth/l2cap_core.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 1156aba4e..40ebabe34 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -6683,9 +6683,17 @@ static int l2cap_stream_rx(struct l2cap_chan *chan, struct l2cap_ctrl *control,
static int l2cap_data_rcv(struct l2cap_chan *chan, struct sk_buff *skb)
{
struct l2cap_ctrl *control = &bt_cb(skb)->l2cap;
- u16 len;
+ u16 len, min_len;
u8 event;
+ min_len = test_bit(FLAG_EXT_CTRL, &chan->flags) ?
+ L2CAP_EXT_CTRL_SIZE : L2CAP_ENH_CTRL_SIZE;
+ if (chan->fcs == L2CAP_FCS_CRC16)
+ min_len += L2CAP_FCS_SIZE;
+
+ if (skb->len < min_len)
+ goto drop;
+
__unpack_control(chan, skb);
len = skb->len;
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] Bluetooth: L2CAP: validate frame length before control and FCS access
2026-09-15 16:02 [PATCH] Bluetooth: L2CAP: validate frame length before control and FCS access Aldo Ariel Panzardo
@ 2026-09-16 18:00 ` patchwork-bot+bluetooth
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+bluetooth @ 2026-09-16 18:00 UTC (permalink / raw)
To: Aldo Ariel Panzardo; +Cc: luiz.dentz, linux-bluetooth, linux-kernel, stable
Hello:
This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Tue, 15 Sep 2026 13:02:39 -0300 you wrote:
> l2cap_data_rcv() unpacks either a two-byte or four-byte control field
> without first ensuring that it is present. A short ERTM or streaming-mode
> frame can therefore cause an out-of-bounds read.
>
> There is a second short-frame case when CRC16 is enabled. After the
> control field is pulled, l2cap_check_fcs() subtracts two from skb->len
> without checking it. If fewer than two bytes remain, the subtraction
> wraps; skb_trim() leaves the buffer unchanged and the subsequent FCS
> load reads past the logical end of the frame.
>
> [...]
Here is the summary with links:
- Bluetooth: L2CAP: validate frame length before control and FCS access
https://git.kernel.org/bluetooth/bluetooth-next/c/6c78a213d907
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-16 18:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-15 16:02 [PATCH] Bluetooth: L2CAP: validate frame length before control and FCS access Aldo Ariel Panzardo
2026-09-16 18:00 ` patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®