Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc110922 authored by Vinicius Costa Gomes's avatar Vinicius Costa Gomes Committed by Gustavo Padovan
Browse files

Bluetooth: Change signature of smp_conn_security()



To make it clear that it may be called from contexts that may not have
any knowledge of L2CAP, we change the connection parameter, to receive
a hci_conn.

This also makes it clear that it is checking the security of the link.

Signed-off-by: default avatarVinicius Costa Gomes <vinicius.gomes@openbossa.org>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent 1fa6535f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -136,7 +136,7 @@ struct smp_chan {
};
};


/* SMP Commands */
/* SMP Commands */
int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level);
int smp_conn_security(struct hci_conn *hcon, __u8 sec_level);
int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb);
int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb);
int smp_distribute_keys(struct l2cap_conn *conn, __u8 force);
int smp_distribute_keys(struct l2cap_conn *conn, __u8 force);
int smp_user_confirm_reply(struct hci_conn *conn, u16 mgmt_op, __le32 passkey);
int smp_user_confirm_reply(struct hci_conn *conn, u16 mgmt_op, __le32 passkey);
+6 −5
Original line number Original line Diff line number Diff line
@@ -1199,14 +1199,15 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
static void l2cap_conn_ready(struct l2cap_conn *conn)
static void l2cap_conn_ready(struct l2cap_conn *conn)
{
{
	struct l2cap_chan *chan;
	struct l2cap_chan *chan;
	struct hci_conn *hcon = conn->hcon;


	BT_DBG("conn %p", conn);
	BT_DBG("conn %p", conn);


	if (!conn->hcon->out && conn->hcon->type == LE_LINK)
	if (!hcon->out && hcon->type == LE_LINK)
		l2cap_le_conn_ready(conn);
		l2cap_le_conn_ready(conn);


	if (conn->hcon->out && conn->hcon->type == LE_LINK)
	if (hcon->out && hcon->type == LE_LINK)
		smp_conn_security(conn, conn->hcon->pending_sec_level);
		smp_conn_security(hcon, hcon->pending_sec_level);


	mutex_lock(&conn->chan_lock);
	mutex_lock(&conn->chan_lock);


@@ -1219,8 +1220,8 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
			continue;
			continue;
		}
		}


		if (conn->hcon->type == LE_LINK) {
		if (hcon->type == LE_LINK) {
			if (smp_conn_security(conn, chan->sec_level))
			if (smp_conn_security(hcon, chan->sec_level))
				l2cap_chan_ready(chan);
				l2cap_chan_ready(chan);


		} else if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) {
		} else if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -615,7 +615,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
				break;
				break;
			}
			}


			if (smp_conn_security(conn, sec.level))
			if (smp_conn_security(conn->hcon, sec.level))
				break;
				break;
			sk->sk_state = BT_CONFIG;
			sk->sk_state = BT_CONFIG;
			chan->state = BT_CONFIG;
			chan->state = BT_CONFIG;
+2 −2
Original line number Original line Diff line number Diff line
@@ -760,9 +760,9 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
	return 0;
	return 0;
}
}


int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level)
int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
{
{
	struct hci_conn *hcon = conn->hcon;
	struct l2cap_conn *conn = hcon->l2cap_data;
	struct smp_chan *smp = conn->smp_chan;
	struct smp_chan *smp = conn->smp_chan;
	__u8 authreq;
	__u8 authreq;