summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorKeenan Dong <keenanat2000@gmail.com>2026-03-28 11:46:47 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-04-11 15:29:32 +0300
commit40ba329e8b4cd2fb11b0caf5e6a543ceaebb6009 (patch)
tree42229fb5e2ec0f7877cfe7ebdf85634bcdbec1f3 /net
parent981b4fd2baf3d741ddf26d5f369daec098328390 (diff)
downloadlinux-40ba329e8b4cd2fb11b0caf5e6a543ceaebb6009.tar.xz
Bluetooth: MGMT: validate LTK enc_size on load
[ Upstream commit b8dbe9648d69059cfe3a28917bfbf7e61efd7f15 ] 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> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/mgmt.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index f3da1bc38a55..996cef033e48 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;