a2dp: disallow multiple SetConfiguration to same local SEP
authorPauli Virtanen <pav@iki.fi>
Sun, 5 Jun 2022 12:29:26 +0000 (15:29 +0300)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:54 +0000 (14:55 +0530)
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.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
profiles/audio/a2dp.c
profiles/audio/avdtp.c

index d32aa8e..f7c8fce 100644 (file)
@@ -1946,6 +1946,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;
index 2ac389e..c046374 100644 (file)
@@ -4057,6 +4057,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);