Skip to content

Commit ad32a2f

Browse files
Johan Hedbergholtmann
authored andcommitted
Bluetooth: Add smp_sufficient_security helper function
This function is needed both by the smp_conn_security function as well as upcoming code to check for the security requirements when receiving an L2CAP connect request over LE. Signed-off-by: Johan Hedberg <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent f1496de commit ad32a2f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

net/bluetooth/smp.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,17 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
750750
return 0;
751751
}
752752

753+
bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level)
754+
{
755+
if (sec_level == BT_SECURITY_LOW)
756+
return true;
757+
758+
if (hcon->sec_level >= sec_level)
759+
return true;
760+
761+
return false;
762+
}
763+
753764
int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
754765
{
755766
struct l2cap_conn *conn = hcon->l2cap_data;
@@ -761,10 +772,7 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
761772
if (!test_bit(HCI_LE_ENABLED, &hcon->hdev->dev_flags))
762773
return 1;
763774

764-
if (sec_level == BT_SECURITY_LOW)
765-
return 1;
766-
767-
if (hcon->sec_level >= sec_level)
775+
if (smp_sufficient_security(hcon, sec_level))
768776
return 1;
769777

770778
if (hcon->link_mode & HCI_LM_MASTER)

net/bluetooth/smp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ struct smp_chan {
136136
};
137137

138138
/* SMP Commands */
139+
bool smp_sufficient_security(struct hci_conn *hcon, u8 sec_level);
139140
int smp_conn_security(struct hci_conn *hcon, __u8 sec_level);
140141
int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb);
141142
int smp_distribute_keys(struct l2cap_conn *conn, __u8 force);

0 commit comments

Comments
 (0)