Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2779953pxv; Mon, 12 Jul 2021 01:31:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2Gs4J1fjBB9yAqB1AU8MaKc2CoRiJF77eQW/7tUPI01uAKu7Cfv6llUJXQxicO2bxJn6w X-Received: by 2002:a6b:b882:: with SMTP id i124mr39248274iof.80.1626078681300; Mon, 12 Jul 2021 01:31:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626078681; cv=none; d=google.com; s=arc-20160816; b=U3piS7rpSwwEWyl3fJRFVaRcVcGUgFodIRWe8DJPvicDSlViFFt6JzH4goas+lJ0AI HBtKGFfmqYBoHMoqUSeXVUj4kS/JDJI5oQDgEujKjvvj2JOSGFNTIUTMLIu/7naqqEFy ORyMg5rvAGKtIKnlZxxOU4F+sx/WM3E4901gqyWcIY/cKjrtFH1WPyZ2C1ZN8HLIO6Kg 0NkoRgHHSdmVkz2HUNwtL/Yt54xoUPOOPkuzEYhN+ctdGeWMRDak3WJfipGl5dvUfclG NKzeD8YDllNbetBOHe5OeIeTsl81eMDbS7HKsMvtN5TAxrUPzNHRGoJRoe0bW843o9Mr OjVg== 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=wxHpiYfDuncik6i5FwRpbNUnKMGIA/9+EY+s+sQQfMA=; b=sVOCPXsrAeffkMs8vA1YzKy9m06ZncpH+jS8iUb0ma4Gh8p0xthrYOC2AftNM+m1GY BqZH2gNowBwE2vlqmxoLZcnsBkAJ6o4d5f/nEB5IgVWzHtZMPireb8+hI9AceDTQjSJU OK5YWbwYW5dk4Wl5o1UZV6Pv9EjRYAvmX8xMZIgCOp9rlGyWlT2NtVLaQhqD0n/cpf5p +OjPbvp9T157as+GL4e26SsNBhPuK8yARr+/dk5zSY1n0Arw/ldnflhEe7m144HJ3euo rKBLXkkmRQGiBG1SdcKDH6Yw7o8Ixeuq22w9umqPgBXB6JacvPe590pyxih5adYYGAgS 4wkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="CGypMf/P"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j23si15057075iok.60.2021.07.12.01.30.54; Mon, 12 Jul 2021 01:31:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="CGypMf/P"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353757AbhGLIcJ (ORCPT + 99 others); Mon, 12 Jul 2021 04:32:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358378AbhGLIZx (ORCPT ); Mon, 12 Jul 2021 04:25:53 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0B8FC09CE7A for ; Mon, 12 Jul 2021 01:17:08 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id h8so13437342eds.4 for ; Mon, 12 Jul 2021 01:17:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wxHpiYfDuncik6i5FwRpbNUnKMGIA/9+EY+s+sQQfMA=; b=CGypMf/PuT/GG5nredzePwHjCCdYQd2+769x+EJWPBa+/JiSMa++TYKlpZdoyyUENA ZdAUeg8+rzYQZHSUkJM17exv38C/ToG2CU9mTk+cBatA8U+h/Wn79tFyqc7SY5w7aJnA kwP9j4YgCmZSbNeRmg1NMol0xrKJuwnBHU34uSsOU6rQrmrnkOuLp3KpNRSQf6+5D3lW v8Mufq/KV49cf9Iy9lUGJmeqzBYDv9x0AjeO2IMaW/djCEMm39BA4B8PXUnpa+aD3Qyj F1DEfDSpF/9X53L65Od4InQ5lByJdPHkuv80Kq28vI6i9ZN+YklvnDZJgxgCjcvkBiMk Igtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wxHpiYfDuncik6i5FwRpbNUnKMGIA/9+EY+s+sQQfMA=; b=iYpEWL5vWMSWsx5/dDkVRsKTuJJy4/sqhJ1gJcWkLSJGe037oiO4R27GXKzIROXSKW dZl9gGqXtrilMmq6Tm6wbQ/M/ZgQN/E7cArkUgMISQr+0NKXfSgyKXH9bXlwoNQ7lZ1B p8CJ8RERwi8GDsRpLYFRCrQ/FWOj/JJy9ozBoZeWbnBRcbr/Kma5MFwziuG4igJh8u8H TgYzKnge/4Zj4+7+em7BZ5bCtC0CVXM9B2Rn5FeHfjbSzUFvNH5s1fvF/X2s3MoaeQjs MeCqlYuzdgjkXrKSCwERtSGLkZbgFiLUQ4RCypo5/NawvSzOnUFsjAVVTCCilMQZ41FW L6mA== X-Gm-Message-State: AOAM530ESdtAvaAoXS7NaP4aVf6BdVZWNyqOzAU9Ce2wKEKcg21yUuvH oaXbpwyP0rBOEcossP09yDqSdhsO3TVRLeuv5ajfvg== X-Received: by 2002:aa7:dd0d:: with SMTP id i13mr50853521edv.97.1626077826901; Mon, 12 Jul 2021 01:17:06 -0700 (PDT) MIME-Version: 1.0 References: <20210708062314.245754-1-howardchung@google.com> <20210708142059.Bluez.v1.6.I123189fa93aad2c2d1be645d38dbc494aa15563c@changeid> In-Reply-To: From: Yun-hao Chung Date: Mon, 12 Jul 2021 16:16:55 +0800 Message-ID: Subject: Re: [Bluez PATCH v1 06/14] audio: Remove Media1 interface when a2dp source disallowed To: Luiz Augusto von Dentz Cc: "linux-bluetooth@vger.kernel.org" , Miao-chen Chou Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org I agree this is a trick for CrOS and probably not suitable for upstreaming. If we want to allow/disallow profiles without reprobing/removing them, here is what we need to do: For each profile in profiles/, reject the connection if its UUID is not allowed. Note that checking the UUID in btd_request_authorization is not enough since some profiles like profiles/health/mcap.c don't call btd_request_authorization. The same check will need to be added in src/profiles.c as well so that we can also manage external profiles. Does that make sense? On Fri, Jul 9, 2021 at 1:49 PM Luiz Augusto von Dentz wrote: > > Hi Howard, > > On Wed, Jul 7, 2021 at 11:23 PM Howard Chung wrote: > > > > When A2DP source profile is removed from adapter, a2dp_server and > > everything inside the object will be removed, which also releases all > > MediaEndpoints and MediaPlayer. When A2DP source profile is re-added, > > although a2dp_server will be created, clients are not able to know they > > can register their endpoints and player by then. > > > > This patch handles this case by unregistering Media1 interface > > when we remove a2dp_server, and register it back when a2dp_source is > > allowed. > > This sounds more like a bug fix for a regression introduced by the > very set, so Id recommend fixup the original patch that introduced the > problem, also Im afraid there could other instances like this perhaps > it would have been better to propagate the allow/block to the profiles > that way they don't have to be reprobed, I also have my doubts clients > would react properly to Media1 disappearing and appearing again so Id > leave it up if there is any endpoint/player registered to avoid having > them to re-register. > > > > > Reviewed-by: Miao-chen Chou > > --- > > perform following steps > > 1. SetServiceAllowList to empty list > > 2. pair with an LE headset, then turn off the headset > > 3. SetServiceAllowList to "0x1234" > > 4. SetServiceAllowList to empty list > > 5. turn on the headset and check if it is reconnected. > > > > profiles/audio/a2dp.c | 2 ++ > > profiles/audio/avrcp.c | 3 +++ > > 2 files changed, 5 insertions(+) > > > > diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c > > index d31ed845cbe7..26d4f365207e 100644 > > --- a/profiles/audio/a2dp.c > > +++ b/profiles/audio/a2dp.c > > @@ -3275,6 +3275,7 @@ static int a2dp_source_server_probe(struct btd_profile *p, > > { > > struct a2dp_server *server; > > > > + media_register(adapter); > > DBG("path %s", adapter_get_path(adapter)); > > > > server = find_server(servers, adapter); > > @@ -3315,6 +3316,7 @@ static void a2dp_source_server_remove(struct btd_profile *p, > > return; > > > > a2dp_server_unregister(server); > > + media_unregister(adapter); > > } > > > > static int a2dp_sink_server_probe(struct btd_profile *p, > > diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c > > index ccf34b2207a9..997a5be9a0f4 100644 > > --- a/profiles/audio/avrcp.c > > +++ b/profiles/audio/avrcp.c > > @@ -4751,6 +4751,8 @@ static void avrcp_controller_server_remove(struct btd_profile *p, > > > > if (server->tg_record_id == 0) > > avrcp_server_unregister(server); > > + > > + media_unregister(adapter); > > } > > > > static int avrcp_controller_server_probe(struct btd_profile *p, > > @@ -4761,6 +4763,7 @@ static int avrcp_controller_server_probe(struct btd_profile *p, > > > > DBG("path %s", adapter_get_path(adapter)); > > > > + media_register(adapter); > > server = find_server(servers, adapter); > > if (server != NULL) > > goto done; > > -- > > 2.32.0.93.g670b81a890-goog > > > > > -- > Luiz Augusto von Dentz