Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp81612iof; Sun, 5 Jun 2022 21:47:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiuyd+Kdrl6moLuwyi8omm9gsJyh/LZkS/jPePbEzdzUL5IbCaWQKKAF6Xkp8KO0MSiIr5 X-Received: by 2002:a17:902:e84c:b0:167:6ef7:b09b with SMTP id t12-20020a170902e84c00b001676ef7b09bmr7232953plg.43.1654490870693; Sun, 05 Jun 2022 21:47:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654490870; cv=pass; d=google.com; s=arc-20160816; b=KPZYKq7lEZWs7K3GlxluL8wOiS7z/G8pcDv/hyIE2S71H+nuL++PH+WbVSltWGfv1u F+kyU/znCQB6K2Kg69FKq5FRBsmVtQAoAcFOEtpXs7klMqDn0JD8boPEdt4CaWtkPLUQ e0uPgefyn9mrzF8sEZ0VtcUgd2txLQLd4IpqfWJIwSVjyeYJNiHIt7bcCJSzklwt949O 0dT10iJOznUYorxDPB3ieaKTVF4ioOJWTklDvtFMePZ0SWNLQDW7M6+TCR3AUql1Ot19 Z2hJFdr0nt/v9ylipGSUvj+Qrw4ZusWHuCiU8P4GPYSIzHBo0j4rpm96Mbcx0qPZDrsD 9fdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QbxEKfLmTpAx89riYevxz97lUEPCfkWBrIsCIjRh+Kg=; b=0gwdcnFmM9T2BTKG3ThG9UGlsAkeGNWBmjPsjwkrikYoMwI0BkbDhnwLIcse5qvH9n xLjOP9m1L/uSOsWCy9W9Mvwjpn48ZALsuipaNG/QRf4+YkImFOQ+kE57Tsk/CKc91UwB wnYdVCq6nhLM3MrRDWhPrn4lpJIbiNPpNPXB5YrkjglAYul5+oWms1kit6TJ3uMJoQ+U /wkfdjPFGFzpXwaDI2FCAj8zy7DJ+If6741doDlVkWSTzYC+v/hDb5TR//F18SLZEhG0 seOAbu9Vg9mxPjH7O7DUFmXxOj/0ktMRQjeBgDc8mgJJsK1/YadaJ9XwdFAGP75x+v2c yKkQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=meesny header.b=oTevq3aw; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id cn6-20020a056a00340600b0051bc4d20274si6144619pfb.23.2022.06.05.21.47.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 21:47:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@iki.fi header.s=meesny header.b=oTevq3aw; arc=pass (i=1); spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0C46C9B1A2; Sun, 5 Jun 2022 21:05:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233372AbiFEM3l (ORCPT + 99 others); Sun, 5 Jun 2022 08:29:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbiFEM3k (ORCPT ); Sun, 5 Jun 2022 08:29:40 -0400 Received: from meesny.iki.fi (meesny.iki.fi [IPv6:2001:67c:2b0:1c1::201]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D904844A0E for ; Sun, 5 Jun 2022 05:29:39 -0700 (PDT) Received: from monolith.lan (91-152-121-49.elisa-laajakaista.fi [91.152.121.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pav) by meesny.iki.fi (Postfix) with ESMTPSA id 3C5162009B; Sun, 5 Jun 2022 15:29:37 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1654432177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QbxEKfLmTpAx89riYevxz97lUEPCfkWBrIsCIjRh+Kg=; b=oTevq3awvQaKQbxqg+sX0uDCnzoNsUUmjvbaANz1xArZEy7no6VK2lLdQ8zCCv17rdKwJV jevCe9X+fZcu8V1hRd/kiwE09sVR37+g4MnMW0kOG7EXKT0dIm4sse1dLVkEAxKZfyNm7v CAqQFK/3k4NKPKpDBqPsY9NXXgtg1OA= From: Pauli Virtanen To: linux-bluetooth@vger.kernel.org Cc: Pauli Virtanen Subject: [PATCH BlueZ 1/2] a2dp: disallow multiple SetConfiguration to same local SEP Date: Sun, 5 Jun 2022 15:29:26 +0300 Message-Id: <20220605122927.110627-1-pav@iki.fi> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1654432177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=QbxEKfLmTpAx89riYevxz97lUEPCfkWBrIsCIjRh+Kg=; b=Qa96YoA0TbJ428THJpuYoUZeBHP7mn7owm5fTCVv7UxZrNmtmVWvWLlyoG496r8okp8CU+ UVF0VIwU0hfmTsTxTBmOFomdanuAElCH6FKQ7sPWJSjUV+DqLLt85q9I0LmNxk7WG6VP6i d6fUUvEmQuU85Qms5fNZ+mqkhr2CUDo= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=pav smtp.mailfrom=pav@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1654432177; a=rsa-sha256; cv=none; b=EM276tBWWfK4s8X8FiwKMvZnZc9PTQHZZ5F8eGBxi0+ojhKDhZw6yYSM8bsfpIbxZ10voL 2YXjhnfGdQj+FMQnhsbVhlPNtEIHQkXNinXDrc3JMGTpqSQyr/bTrwFOfjoioCJMr90x1F j1iA2+NbjstQSLYLjYI0f2XhFunYK98= X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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