Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: iso: fix socket matching ambiguity between BIS and CIS

When both BIS and CIS links exist, their sockets are in
the BT_LISTEN state.
dump sock:
sk 000000001977ef51 state 6
src 10:a5:62:31:05:cf dst 00:00:00:00:00:00
sk 0000000031d28700 state 7
src 10:a5:62:31:05:cf dst00:00:00:00:00:00
sk 00000000613af00e state 4 # listen sock of bis
src 10:a5:62:31:05:cf dst 54:00:00:d4:99:30
sk 000000001710468c state 9
src 10:a5:62:31:05:cf dst 54:00:00:d4:99:30
sk 000000005d97dfde state 4 #listen sock of cis
src 10:a5:62:31:05:cf dst 00:00:00:00:00:00

To locate the CIS socket correctly, check both the BT_LISTEN
state and whether dst addr is BDADDR_ANY.

Link: https://github.com/bluez/bluez/issues/1224
Signed-off-by: Yang Li <yang.li@amlogic.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Yang Li and committed by
Luiz Augusto von Dentz
56f765ce 027473ef

+7 -2
+7 -2
net/bluetooth/iso.c
··· 2021 2021 return test_bit(BT_SK_PA_SYNC, &iso_pi(sk)->flags); 2022 2022 } 2023 2023 2024 + static bool iso_match_dst(struct sock *sk, void *data) 2025 + { 2026 + return !bacmp(&iso_pi(sk)->dst, (bdaddr_t *)data); 2027 + } 2028 + 2024 2029 static void iso_conn_ready(struct iso_conn *conn) 2025 2030 { 2026 2031 struct sock *parent = NULL; ··· 2110 2105 2111 2106 if (!parent) 2112 2107 parent = iso_get_sock(hdev, &hcon->src, BDADDR_ANY, 2113 - BT_LISTEN, NULL, NULL); 2108 + BT_LISTEN, iso_match_dst, BDADDR_ANY); 2114 2109 2115 2110 if (!parent) 2116 2111 return; ··· 2379 2374 } 2380 2375 } else { 2381 2376 sk = iso_get_sock(hdev, &hdev->bdaddr, BDADDR_ANY, 2382 - BT_LISTEN, NULL, NULL); 2377 + BT_LISTEN, iso_match_dst, BDADDR_ANY); 2383 2378 } 2384 2379 2385 2380 done: