public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: MGMT: validate LTK enc_size on load
@ 2026-03-28  8:46 Keenan Dong
  2026-03-28  8:46 ` [PATCH] Bluetooth: MGMT: require exact mesh send payload length Keenan Dong
  2026-03-28  9:52 ` Bluetooth: MGMT: validate LTK enc_size on load bluez.test.bot
  0 siblings, 2 replies; 4+ messages in thread
From: Keenan Dong @ 2026-03-28  8:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, luiz.dentz, linux-kernel, Keenan Dong

Load Long Term Keys stores the user-provided enc_size and later uses
it to size fixed-size stack operations when replying to LE LTK
requests. An enc_size larger than the 16-byte key buffer can therefore
overflow the reply stack buffer.

Reject oversized enc_size values while validating the management LTK
record so invalid keys never reach the stored key state.

Fixes: 346af67b8d11 ("Bluetooth: Add MGMT handlers for dealing with SMP LTK's")
Reported-by: Keenan Dong <keenanat2000@gmail.com>
Signed-off-by: Keenan Dong <keenanat2000@gmail.com>
---
 net/bluetooth/mgmt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index e5f9287fb..adcd86c15 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -7248,6 +7248,9 @@ static bool ltk_is_valid(struct mgmt_ltk_info *key)
 	if (key->initiator != 0x00 && key->initiator != 0x01)
 		return false;
 
+	if (key->enc_size > sizeof(key->val))
+		return false;
+
 	switch (key->addr.type) {
 	case BDADDR_LE_PUBLIC:
 		return true;
-- 
2.43.0


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

end of thread, other threads:[~2026-03-28  9:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-28  8:46 [PATCH] Bluetooth: MGMT: validate LTK enc_size on load Keenan Dong
2026-03-28  8:46 ` [PATCH] Bluetooth: MGMT: require exact mesh send payload length Keenan Dong
2026-03-28  9:53   ` bluez.test.bot
2026-03-28  9:52 ` Bluetooth: MGMT: validate LTK enc_size on load bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox