All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: SMP: add missing skb len check in smp_cmd_keypress_notify
@ 2026-05-17 14:54 Muhammad Bilal
  2026-05-17 16:13 ` bluez.test.bot
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Muhammad Bilal @ 2026-05-17 14:54 UTC (permalink / raw)
  To: linux-bluetooth, linux-kernel
  Cc: marcel, luiz.dentz, johan.hedberg, stable, Muhammad Bilal

smp_cmd_keypress_notify() accesses the received payload as
struct smp_cmd_keypress_notify without verifying that skb->len
contains enough data.

smp_sig_channel() removes the opcode byte before dispatching to
command handlers, so a SMP_CMD_KEYPRESS_NOTIFY packet without a
payload leaves skb->len equal to zero on entry to the handler,
causing a 1-byte out-of-bounds read from the heap.

Add a length check before accessing the payload and return
SMP_INVALID_PARAMS when the packet is too short, matching the
pattern used by other SMP command handlers.

Fixes: 1408bb6efb04 ("Bluetooth: Add dummy handler for LE SC keypress notification")
Cc: stable@vger.kernel.org
Signed-off-by: Muhammad Bilal <meatuni001@gmail.com>
---
 net/bluetooth/smp.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 98f1da4f5..4c98e2a3a 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -2932,6 +2932,9 @@ static int smp_cmd_keypress_notify(struct l2cap_conn *conn,
 {
 	struct smp_cmd_keypress_notify *kp = (void *) skb->data;
 
+	if (skb->len < sizeof(*kp))
+		return SMP_INVALID_PARAMS;
+
 	bt_dev_dbg(conn->hcon->hdev, "value 0x%02x", kp->value);
 
 	return 0;
-- 
2.54.0


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

end of thread, other threads:[~2026-05-19  2:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-17 14:54 [PATCH] Bluetooth: SMP: add missing skb len check in smp_cmd_keypress_notify Muhammad Bilal
2026-05-17 16:13 ` bluez.test.bot
2026-05-17 17:47 ` [PATCH] " Paul Menzel
2026-05-17 18:08   ` Muhammad Bilal
2026-05-17 18:41     ` Paul Menzel
2026-05-17 19:03       ` Muhammad Bilal
2026-05-18 20:29         ` Paul Menzel
2026-05-18 20:37 ` Luiz Augusto von Dentz
2026-05-19  0:14 ` [PATCH v2] " Muhammad Bilal
2026-05-19  2:00   ` [v2] " bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.