Skip to content

Commit b8dbe96

Browse files
Niebelungen-DVudentz
authored andcommitted
Bluetooth: MGMT: validate LTK enc_size on load
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: 346af67 ("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>
1 parent 0ffac65 commit b8dbe96

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

net/bluetooth/mgmt.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7248,6 +7248,9 @@ static bool ltk_is_valid(struct mgmt_ltk_info *key)
72487248
if (key->initiator != 0x00 && key->initiator != 0x01)
72497249
return false;
72507250

7251+
if (key->enc_size > sizeof(key->val))
7252+
return false;
7253+
72517254
switch (key->addr.type) {
72527255
case BDADDR_LE_PUBLIC:
72537256
return true;

0 commit comments

Comments
 (0)