Commit 977f8fce authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann

Bluetooth: Introduce a flag to track who really initiates authentication

Even though our side requests authentication, the original action that
caused it may be remotely triggered, such as an incoming L2CAP or RFCOMM
connect request. To track this information introduce a new hci_conn flag
called HCI_CONN_AUTH_INITIATOR.
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent e7cafc45
...@@ -547,6 +547,7 @@ enum { ...@@ -547,6 +547,7 @@ enum {
HCI_CONN_SECURE, HCI_CONN_SECURE,
HCI_CONN_FIPS, HCI_CONN_FIPS,
HCI_CONN_STK_ENCRYPT, HCI_CONN_STK_ENCRYPT,
HCI_CONN_AUTH_INITIATOR,
}; };
static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) static inline bool hci_conn_ssp_enabled(struct hci_conn *conn)
......
...@@ -1027,6 +1027,9 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type, ...@@ -1027,6 +1027,9 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type,
if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags))
return 0; return 0;
if (initiator)
set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags);
if (!hci_conn_auth(conn, sec_level, auth_type)) if (!hci_conn_auth(conn, sec_level, auth_type))
return 0; return 0;
......
...@@ -1645,6 +1645,8 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status) ...@@ -1645,6 +1645,8 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status)
if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
struct hci_cp_auth_requested auth_cp; struct hci_cp_auth_requested auth_cp;
set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags);
auth_cp.handle = __cpu_to_le16(conn->handle); auth_cp.handle = __cpu_to_le16(conn->handle);
hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED,
sizeof(auth_cp), &auth_cp); sizeof(auth_cp), &auth_cp);
...@@ -2387,6 +2389,9 @@ static void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -2387,6 +2389,9 @@ static void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb)
if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) { if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->flags)) {
struct hci_cp_auth_requested cp; struct hci_cp_auth_requested cp;
set_bit(HCI_CONN_AUTH_INITIATOR, &conn->flags);
cp.handle = __cpu_to_le16(conn->handle); cp.handle = __cpu_to_le16(conn->handle);
hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp); hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, sizeof(cp), &cp);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment