]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
Bluetooth: SMP: derive legacy responder STK authentication from MITM state
authorOleh Konko <security@1seal.org>
Tue, 31 Mar 2026 11:52:13 +0000 (11:52 +0000)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 1 Apr 2026 20:48:06 +0000 (16:48 -0400)
The legacy responder path in smp_random() currently labels the stored
STK as authenticated whenever pending_sec_level is BT_SECURITY_HIGH.
That reflects what the local service requested, not what the pairing
flow actually achieved.

For Just Works/Confirm legacy pairing, SMP_FLAG_MITM_AUTH stays clear
and the resulting STK should remain unauthenticated even if the local
side requested HIGH security. Use the established MITM state when
storing the responder STK so the key metadata matches the pairing result.

This also keeps the legacy path aligned with the Secure Connections code,
which already treats JUST_WORKS/JUST_CFM as unauthenticated.

Fixes: fff3490f4781 ("Bluetooth: Fix setting correct authentication information for SMP STK")
Cc: stable@vger.kernel.org
Signed-off-by: Oleh Konko <security@1seal.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/smp.c

index deb8dd244b77bd2f0d89135d48d480b8a65035cf..98f1da4f5f559bdfd53aeb87f9a636c88fb19ca0 100644 (file)
@@ -1018,10 +1018,7 @@ static u8 smp_random(struct smp_chan *smp)
 
                smp_s1(smp->tk, smp->prnd, smp->rrnd, stk);
 
-               if (hcon->pending_sec_level == BT_SECURITY_HIGH)
-                       auth = 1;
-               else
-                       auth = 0;
+               auth = test_bit(SMP_FLAG_MITM_AUTH, &smp->flags) ? 1 : 0;
 
                /* Even though there's no _RESPONDER suffix this is the
                 * responder STK we're adding for later lookup (the initiator