]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: MGMT: validate LTK enc_size on load
authorKeenan Dong <keenanat2000@gmail.com>
Sat, 28 Mar 2026 08:46:47 +0000 (16:46 +0800)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 1 Apr 2026 20:46:09 +0000 (16:46 -0400)
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>
net/bluetooth/mgmt.c

index e5f9287fb826acc55f9b25a6c01e503981f0999d..adcd86c15b4e634b7f75bb15c4847e57c287089b 100644 (file)
@@ -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;