All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] a2dp: disallow multiple SetConfiguration to same local SEP
@ 2022-06-05 12:29 Pauli Virtanen
  2022-06-05 12:29 ` [PATCH BlueZ 2/2] a2dp: error return paths in a2dp_reconfig must free allocated setup Pauli Virtanen
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Pauli Virtanen @ 2022-06-05 12:29 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Pauli Virtanen

Using the remote SEP SetConfiguration DBus API, it's possible to make
multiple remote endpoints use the same local SEP, if they are endpoints
from different connected devices. This is invalid: successful
configuration shall prevent a different device configuring the same SEP
(AVDTP v1.3 Sec. 5.3).  Moreover, this breaks the assumption in the
AVDTP code that each SEP has at most a single stream, and causes
misbehavior later on (subsequent transport acquires fail with EPERM).

Fix this by first checking the SEP is free before proceeding in the DBus
API call.  Also add a sanity check in avdtp_set_configuration, to reject
configuring an already configured SEP similarly as in avdtp_setconf_cmd.
---

Notes:
    E.g. trying to set the same codec for two simultaneously connected
    devices for the same adapter in Pulseaudio, causes the A2DP
    connection of the first device stop working, as its transport
    acquires start failing with EPERM. Disconnecting the first device
    also breaks the second device connection.
    This patch fixes it so that only the invalid SetConfiguration fails.

 profiles/audio/a2dp.c  | 5 +++++
 profiles/audio/avdtp.c | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 6f5b13711..f3e2cdd9e 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -1843,6 +1843,11 @@ static int a2dp_reconfig(struct a2dp_channel *chan, const char *sender,
 	GSList *l;
 	int err;
 
+	/* Check SEP not used by a different session */
+	if (lsep->stream && chan->session &&
+	    !avdtp_has_stream(chan->session, lsep->stream))
+		return -EBUSY;
+
 	setup = a2dp_setup_get(chan->session);
 	if (!setup)
 		return -ENOMEM;
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index da4114e0f..bc7afad81 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -3523,6 +3523,9 @@ int avdtp_set_configuration(struct avdtp *session,
 	if (!(lsep && rsep))
 		return -EINVAL;
 
+	if (lsep->stream)
+		return -EBUSY;
+
 	DBG("%p: int_seid=%u, acp_seid=%u", session,
 			lsep->info.seid, rsep->seid);
 
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-13 21:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-05 12:29 [PATCH BlueZ 1/2] a2dp: disallow multiple SetConfiguration to same local SEP Pauli Virtanen
2022-06-05 12:29 ` [PATCH BlueZ 2/2] a2dp: error return paths in a2dp_reconfig must free allocated setup Pauli Virtanen
2022-06-05 14:21 ` [BlueZ,1/2] a2dp: disallow multiple SetConfiguration to same local SEP bluez.test.bot
2022-06-07  5:33 ` [PATCH BlueZ 1/2] " Luiz Augusto von Dentz
2022-06-07  7:44   ` Pauli Virtanen
2022-06-07 19:28     ` Luiz Augusto von Dentz
2022-06-13 18:10 ` patchwork-bot+bluetooth
2022-06-13 21:02   ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.