diff options
| -rw-r--r-- | net/bluetooth/l2cap_core.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index a37f809591ad..15784d32108d 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
| @@ -5218,9 +5218,10 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn, | |||
| 5218 | u8 *data) | 5218 | u8 *data) |
| 5219 | { | 5219 | { |
| 5220 | struct l2cap_le_conn_rsp *rsp = (struct l2cap_le_conn_rsp *) data; | 5220 | struct l2cap_le_conn_rsp *rsp = (struct l2cap_le_conn_rsp *) data; |
| 5221 | struct hci_conn *hcon = conn->hcon; | ||
| 5221 | u16 dcid, mtu, mps, credits, result; | 5222 | u16 dcid, mtu, mps, credits, result; |
| 5222 | struct l2cap_chan *chan; | 5223 | struct l2cap_chan *chan; |
| 5223 | int err; | 5224 | int err, sec_level; |
| 5224 | 5225 | ||
| 5225 | if (cmd_len < sizeof(*rsp)) | 5226 | if (cmd_len < sizeof(*rsp)) |
| 5226 | return -EPROTO; | 5227 | return -EPROTO; |
| @@ -5259,6 +5260,26 @@ static int l2cap_le_connect_rsp(struct l2cap_conn *conn, | |||
| 5259 | l2cap_chan_ready(chan); | 5260 | l2cap_chan_ready(chan); |
| 5260 | break; | 5261 | break; |
| 5261 | 5262 | ||
| 5263 | case L2CAP_CR_AUTHENTICATION: | ||
| 5264 | case L2CAP_CR_ENCRYPTION: | ||
| 5265 | /* If we already have MITM protection we can't do | ||
| 5266 | * anything. | ||
| 5267 | */ | ||
| 5268 | if (hcon->sec_level > BT_SECURITY_MEDIUM) { | ||
| 5269 | l2cap_chan_del(chan, ECONNREFUSED); | ||
| 5270 | break; | ||
| 5271 | } | ||
| 5272 | |||
| 5273 | sec_level = hcon->sec_level + 1; | ||
| 5274 | if (chan->sec_level < sec_level) | ||
| 5275 | chan->sec_level = sec_level; | ||
| 5276 | |||
| 5277 | /* We'll need to send a new Connect Request */ | ||
| 5278 | clear_bit(FLAG_LE_CONN_REQ_SENT, &chan->flags); | ||
| 5279 | |||
| 5280 | smp_conn_security(hcon, chan->sec_level); | ||
| 5281 | break; | ||
| 5282 | |||
| 5262 | default: | 5283 | default: |
| 5263 | l2cap_chan_del(chan, ECONNREFUSED); | 5284 | l2cap_chan_del(chan, ECONNREFUSED); |
| 5264 | break; | 5285 | break; |
