Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1203777iof; Tue, 7 Jun 2022 00:11:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI5rERe4Rsxp+z7kxS6myoFUdqWyXDmaI1Yit98umkROJlr9jb4REfyD5PbieU5hyhDuWb X-Received: by 2002:a17:906:b898:b0:711:ca46:24ec with SMTP id hb24-20020a170906b89800b00711ca4624ecmr9643935ejb.111.1654585860839; Tue, 07 Jun 2022 00:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654585860; cv=none; d=google.com; s=arc-20160816; b=H7JciQUQqLhzrWMwMLe1fpoBmi9lgJ2Y9U56Ya5Xej2Gj4pWqGF9vFgTT0V3t5Vsgn MJF+grtpSi6nHzQ8XogZ1SjgfdunPEHJlWSyNdbLOYyiF+zNgLNa3Olem8PdZKtMFtLA 4BryZ3wBknEV1mCOfUuyeomXJBzY3Cs88fxRInkvpAA5ZWphPrgCIEvUQIsP+DoOVHw6 JQ97/bd3kLWCfRReNp0FdpUupVpcmsmd3fMEU++nLmJW55GfuCWemcn4n+DEgf/jZhOS vW6Eze3iuqwxdPmnfn5ylXG/jHmO/h00Qz3GjcDM7u8ieRG+Rcp0EvMMESMy6TXe0LM+ h0sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=EyxY25byEgH9PupGgRfXpgr6xzg5W4K5+h4sm2X9mxs=; b=Nazi+PWEd2/CMu2Ke6qoOsmLgbMFOjZscu0GZ+c0VCsMz/95IO0U4Xzfyd8C/ijou4 CgRYBoCtgrXR8874csMYpRRVjMsVMQ7AY0nk4Z1quy+yVzq4ynQQBCxvvpU8Ig10KvIk hxF/MXjL+8A2rFl5Q35vz4F/ZkJExgvrxophgcml6fGx5OLhD0wJSxv1mq426yc05MAg OTAg2do0ijr5UyBTf3mMKb9ZNMzKnhavao+y6pWyFORJj3AWMzx/QCZ3R9EcwPmH/36s ayXlcBNeyKGdFY5b3NOV6zSRiJM7gse94PlSCEeE+ibmbUL9HKNCMa/Nvk5kTMjLmTzB 2mig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PPDfKeVH; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr36-20020a1709073fa400b006ff288d1c02si16237612ejc.805.2022.06.07.00.10.11; Tue, 07 Jun 2022 00:11:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=PPDfKeVH; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232869AbiFGFeC (ORCPT + 99 others); Tue, 7 Jun 2022 01:34:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229930AbiFGFeB (ORCPT ); Tue, 7 Jun 2022 01:34:01 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2823CB716C for ; Mon, 6 Jun 2022 22:33:59 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id e9so4155916pju.5 for ; Mon, 06 Jun 2022 22:33:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=EyxY25byEgH9PupGgRfXpgr6xzg5W4K5+h4sm2X9mxs=; b=PPDfKeVHjScLHvr06n11D9khp+Ud+obtP+9KhWZeVWNy1VHhcvZzOAXXlq2HFtYHEo lNb8QCxuzJ6qRNOhkrkF3GfS39AmUYP6mL6HyFvIi1OWkRiNc0u34Fnrj0QsWsiRCPH1 FuoIEOXkZigr/TEPAHSkseBQ+7SZE8fbDEyOBTrS00aI0zQytfXjE0u+pJ7XduYKHWpp DKNjV5HQ9M8xo1In4kzhQ29W4yUETpS/C98J2WCvUThFYA4fahSS/xzuxtv/TskkT+aH scMmravcxfuL33NCnDtI6gUWB3XHyG3UkDcZdKuDY/GtvzvaeJhtgS5MHvT1adNAYWWr GFBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=EyxY25byEgH9PupGgRfXpgr6xzg5W4K5+h4sm2X9mxs=; b=YQH2XNXcgnHxdSS3JtWKtE2ZAPTt1JH4Ks4YfVPL8oLamyTLPlbNL5BDYLVsPZDT8P YDsc2AdgrK/EmoJeqCnqy0fXAu/j/l3Ph+IH/TipBuifCTlAH6z6/5RUA1hAGKrfm5h7 csI1XByAlC0W9UWKLHBt88gTqEJcLwvjUwKQ/0J4cRJHtMTVO7hbpzXellN+8MvkyA4P Oi+OKDljiKvknn8+RKhRqgtbVxVY0WFNIwxqmCDM4wINtbxnCiGqSPsMVyTuO4Xw0lwS pwQwqzfNioSiw7X87hdYHASAb4aPFLSjfYu+M9tpaUmeOcq6asJK/rADe/Axc60BSA7l jRgw== X-Gm-Message-State: AOAM533N1XtuZALBDuyJTXsW0sittSvVVjvnV+HxZcSQk8KzomX3y25i /22ySsFzpKjGk82TLnbVkK5FhE0QioUPvXh/rPXAZ/LU X-Received: by 2002:a17:902:7884:b0:167:4d5b:7a2f with SMTP id q4-20020a170902788400b001674d5b7a2fmr20160425pll.18.1654580038503; Mon, 06 Jun 2022 22:33:58 -0700 (PDT) MIME-Version: 1.0 References: <20220605122927.110627-1-pav@iki.fi> In-Reply-To: <20220605122927.110627-1-pav@iki.fi> From: Luiz Augusto von Dentz Date: Mon, 6 Jun 2022 22:33:46 -0700 Message-ID: Subject: Re: [PATCH BlueZ 1/2] a2dp: disallow multiple SetConfiguration to same local SEP To: Pauli Virtanen Cc: "linux-bluetooth@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Pauli, On Sun, Jun 5, 2022 at 9:47 PM Pauli Virtanen wrote: > > 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). Not sure I follow I follow why it would be invalid for a stack to enable connecting the same local SEP with different remote SEP, afaik this depends only if the underline codec does support multiple streams, as far I can remember the folks at BMW were actually the ones proposing such a change back in the days so perhaps something broke the proper support so we should be able to fix it. If, and only if, the codec itself don't support multiple simultaneous stream then it should reject the SetConfiguration by replying with an error. > 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 > -- Luiz Augusto von Dentz