|
21 | 21 | #include "host/buf_view.h"
|
22 | 22 | #include "host/hci_core.h"
|
23 | 23 | #include "host/conn_internal.h"
|
| 24 | +#include "host/keys.h" |
24 | 25 | #include "l2cap_br_internal.h"
|
25 | 26 | #include "avdtp_internal.h"
|
26 | 27 | #include "a2dp_internal.h"
|
@@ -766,7 +767,9 @@ enum l2cap_br_conn_security_result {
|
766 | 767 | * - channel connection process is on hold since there were valid security
|
767 | 768 | * conditions triggering authentication indirectly in subcall.
|
768 | 769 | * Returns L2CAP_CONN_SECURITY_REJECT if:
|
769 |
| - * - bt_conn_set_security API returns < 0. |
| 770 | + * - bt_conn_set_security API returns < 0, |
| 771 | + * - Or, the ACL connection has been encrypted, the security level of link key cannot be upgraded, |
| 772 | + * and the security level is less than the required security level. |
770 | 773 | */
|
771 | 774 |
|
772 | 775 | static enum l2cap_br_conn_security_result
|
@@ -807,6 +810,18 @@ l2cap_br_conn_security(struct bt_l2cap_chan *chan, const uint16_t psm)
|
807 | 810 | break;
|
808 | 811 | }
|
809 | 812 |
|
| 813 | + if (chan->conn->sec_level < br_chan->required_sec_level && |
| 814 | + chan->conn->encrypt && chan->conn->br.link_key && |
| 815 | + (chan->conn->br.link_key->flags & BT_LINK_KEY_AUTHENTICATED)) { |
| 816 | + /* |
| 817 | + * If the ACL link has been encrypted and it has a authenticated link key, it means |
| 818 | + * the pairing procedure has been done. And the security level of the link key can |
| 819 | + * not be upgraded. In this case, if `conn->sec_level` is less than the required |
| 820 | + * security level of the L2CAP channel, reject the L2CAP conn request. |
| 821 | + */ |
| 822 | + return L2CAP_CONN_SECURITY_REJECT; |
| 823 | + } |
| 824 | + |
810 | 825 | check = bt_conn_set_security(chan->conn, br_chan->required_sec_level);
|
811 | 826 |
|
812 | 827 | /*
|
|
0 commit comments