Skip to content

Commit 927ef40

Browse files
claudiadraghigregkh
authored andcommitted
Bluetooth: ISO: Copy BASE if service data matches EIR_BAA_SERVICE_UUID
[ Upstream commit f4da3ee ] Copy the content of a Periodic Advertisement Report to BASE only if the service UUID is Basic Audio Announcement Service UUID. Signed-off-by: Claudia Draghicescu <claudia.rosu@nxp.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a444c3d commit 927ef40

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

net/bluetooth/iso.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <net/bluetooth/bluetooth.h>
1515
#include <net/bluetooth/hci_core.h>
1616
#include <net/bluetooth/iso.h>
17+
#include "eir.h"
1718

1819
static const struct proto_ops iso_sock_ops;
1920

@@ -47,6 +48,7 @@ static void iso_sock_kill(struct sock *sk);
4748

4849
#define EIR_SERVICE_DATA_LENGTH 4
4950
#define BASE_MAX_LENGTH (HCI_MAX_PER_AD_LENGTH - EIR_SERVICE_DATA_LENGTH)
51+
#define EIR_BAA_SERVICE_UUID 0x1851
5052

5153
/* iso_pinfo flags values */
5254
enum {
@@ -1587,6 +1589,8 @@ static int iso_sock_getsockopt(struct socket *sock, int level, int optname,
15871589
len = min_t(unsigned int, len, base_len);
15881590
if (copy_to_user(optval, base, len))
15891591
err = -EFAULT;
1592+
if (put_user(len, optlen))
1593+
err = -EFAULT;
15901594

15911595
break;
15921596

@@ -1928,12 +1932,16 @@ int iso_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags)
19281932

19291933
ev3 = hci_recv_event_data(hdev, HCI_EV_LE_PER_ADV_REPORT);
19301934
if (ev3) {
1935+
size_t base_len = ev3->length;
1936+
u8 *base;
1937+
19311938
sk = iso_get_sock_listen(&hdev->bdaddr, bdaddr,
19321939
iso_match_sync_handle_pa_report, ev3);
1933-
1934-
if (sk) {
1935-
memcpy(iso_pi(sk)->base, ev3->data, ev3->length);
1936-
iso_pi(sk)->base_len = ev3->length;
1940+
base = eir_get_service_data(ev3->data, ev3->length,
1941+
EIR_BAA_SERVICE_UUID, &base_len);
1942+
if (base && sk && base_len <= sizeof(iso_pi(sk)->base)) {
1943+
memcpy(iso_pi(sk)->base, base, base_len);
1944+
iso_pi(sk)->base_len = base_len;
19371945
}
19381946
} else {
19391947
sk = iso_get_sock_listen(&hdev->bdaddr, BDADDR_ANY, NULL, NULL);

0 commit comments

Comments
 (0)