Bluetooth: GATT: Verify security when notifiying or indicating
Adds a security checks when notifying or indicating, such that we don't send notifications for characteristics that require encryption on an unencrypted link. Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
parent
d3747db66f
commit
2f4ee7dcb6
1 changed files with 16 additions and 0 deletions
|
@ -1887,6 +1887,11 @@ static int gatt_notify(struct bt_conn *conn, uint16_t handle,
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Confirm that the connection has the correct level of security */
|
||||
if (bt_gatt_check_perm(conn, params->attr, BT_GATT_PERM_READ_ENCRYPT)) {
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_GATT_NOTIFY_MULTIPLE)
|
||||
if (gatt_cf_notify_multi(conn)) {
|
||||
int err;
|
||||
|
@ -2013,6 +2018,12 @@ static int gatt_indicate(struct bt_conn *conn, uint16_t handle,
|
|||
return -EAGAIN;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Confirm that the connection has the correct level of security */
|
||||
if (bt_gatt_check_perm(conn, params->attr, BT_GATT_PERM_READ_ENCRYPT)) {
|
||||
return -EPERM;
|
||||
}
|
||||
|
||||
len = sizeof(*ind) + params->len;
|
||||
|
||||
req = gatt_req_alloc(gatt_indicate_rsp, params, NULL,
|
||||
|
@ -2115,6 +2126,11 @@ static uint8_t notify_cb(const struct bt_gatt_attr *attr, uint16_t handle,
|
|||
continue;
|
||||
}
|
||||
|
||||
/* Confirm that the connection has the correct level of security */
|
||||
if (bt_gatt_check_perm(conn, attr, BT_GATT_PERM_READ_ENCRYPT)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Use the Characteristic Value handle discovered since the
|
||||
* Client Characteristic Configuration descriptor may occur
|
||||
* in any position within the characteristic definition after
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue