Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5229765pxv; Wed, 28 Jul 2021 06:17:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTWen8YgWzlHujgHq29f3/Xb6Q3k+gdR8b0uEsIqcDxqtL0iEMdlQOE1MD6aE9yQ23rkke X-Received: by 2002:a5d:9585:: with SMTP id a5mr24696206ioo.28.1627478268643; Wed, 28 Jul 2021 06:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627478268; cv=none; d=google.com; s=arc-20160816; b=QVHy+YvsxkHDDmsGOFU02J350IEog+eO2FFCPZKfohhaBASsi0DZZHXY+WczZll8NB UJdnK3CnklLxId3NysraRpY8GSAmhQ3i7W8WFq31qUo8H22FTXXgCcxc+65UYgjsSjrW g3l+591AaRNsb4hwekD0Piqnnj4UtaWdsmTyWMIrg4ntie1V3mNSeF9bC2i3WKf2WuPm ouhzhezUu1ul/HDJWigd2oDMCwciG3cXkRjC24eU6h271OKaX96D+vsi1zRCrN3CiTF9 KiuGD7JV0hrpwT2rVXtI6aIhXZRvg+Qu6VNk/dbw1nf+xT2e6FNsG2b2Cl3RGRmI8oj6 QaXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=6hWrRnNYi2s/+4xHmBf9CSF55NC5a1hg1KjWcJFX+ds=; b=hzNq+XyNCB29GhglpgBnGi80ONlRzxVg3XbQI95nMUVvPWbNz4sv+7cZz5u+JX2PDj jkpNAZjtKgE9/Y8ZNj7lCRFsAW9AoobZo02NzQdvmXAK+PJtp9xLKvPljxHW4inIgvSO DofjmryJriKPTQIPX+S96xCT8jHyC4xgg27y8LLVf3dnO6VUVWYP4VIG/le3oiI5CLLn +m/3Op/0GP4ZHRnSXnbvit5Se4egLaTLbSfQDHAd8KQNnIPOewxS9mnmyAgs0ggECe6i QLSxK/zmYd5JrNSlazAccRtElzp2U9tUPDSs2hpHjUSdzjRTsOtzPylQkU5J61AZNHgv bCPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lR6bIXF8; 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 d131si9337229iog.11.2021.07.28.06.17.13; Wed, 28 Jul 2021 06:17:48 -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=lR6bIXF8; 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 S235304AbhG1NPm (ORCPT + 99 others); Wed, 28 Jul 2021 09:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233315AbhG1NPm (ORCPT ); Wed, 28 Jul 2021 09:15:42 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9CF4C061757 for ; Wed, 28 Jul 2021 06:15:39 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id x7-20020a0569021027b029055b9b68cd3eso2803388ybt.8 for ; Wed, 28 Jul 2021 06:15:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=6hWrRnNYi2s/+4xHmBf9CSF55NC5a1hg1KjWcJFX+ds=; b=lR6bIXF8UQllB3ebg0N6vfQ1+MLgEuS6baPh/Je6kwv+4mgzEVMJXQuQdkz1TQqVLw QkgdunjaxI9ZL8uOXKmlFdRf6VWJ/aROy5WPGBiuYSXh8fUPFqcGZ5Xomps3YlZTdP14 SJVnobQ5cwiJhMYcvg9gv6fUDkxdLJ8fVGHMvSlZzfqcOjH7SlbsEnwiCIFVzJsJfm1f V4mq1Y6myiVU0J+UvpUTelgSqh5XOPVi4fsKmyHKLaKolILTASATvhQL1YtyAspuuksc xkDOCca7VSzqW3pniH3rCrXSeZWglWJxsLv69Y7pIzMnzGOQW7YFKtYPJT0p7yfn3tHY b/Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=6hWrRnNYi2s/+4xHmBf9CSF55NC5a1hg1KjWcJFX+ds=; b=i3r9Zws7EKcBelt1L1WcKk7qly4Ejr2OEp/zC1ftuo6vCEbHNyhH9n5b+ndH3ZeKAY uhDHmfb1BCR7rarGGzRx6V1WmV8JYVekBLdXBI1VhksItRU3NmY6RnfNISQHVkMSNaO+ hBrZTiJtw/qrsdMxcdDXz8Ab5r3sZ2dnDXHsobwgLJ3CFgwK7L1iM6P4pNVbzBCMuKtD R28p5oIip9kg6WuaSsVPTl5xmkmpD+WJF02GPcWhUUta4Touhg9UHUSrmtc+xv5UV5wl 0ASESWEgbtizcFf5ZmRNWyznYfXpYMdA0sY+5uYTtR1SKvJ4tHqRb112fovO2g5PsIr9 dpaw== X-Gm-Message-State: AOAM530YxdTNBDlOuiTxWgtfMQCa/8cUCqnRI9SW7150HrwZd+ldSWzZ 1RFJtgaiGMGjhZd1ANx9jtkFCG1LKDaVag0ViHM/mQNA9DIC93WSphH4w0c3iSO8wRGFnYWk4od O/goq0DPRiqEP6T5HKqVVxMs+LeX+WmKZmbqOj+1d3Hw+zaQfqdhzcGnb4bSp7oDEAavJGfBbOc rxtpBY2FSfDdg= X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:9b6a:9d1f:2f3e:45de]) (user=howardchung job=sendgmr) by 2002:a25:c5d2:: with SMTP id v201mr24955611ybe.409.1627478138899; Wed, 28 Jul 2021 06:15:38 -0700 (PDT) Date: Wed, 28 Jul 2021 21:15:16 +0800 Message-Id: <20210728131529.3310558-1-howardchung@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog Subject: [Bluez PATCH v3 00/13] Admin policy series From: Howard Chung To: linux-bluetooth@vger.kernel.org, luiz.dentz@gmail.com Cc: Yun-Hao Chung Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Yun-Hao Chung Hi manintainers, This series is to 1. Implement a few methods in core so that a plugin can have control of allowing / disallowing certain service connections. 2. Implement the AdminPolicy plugin. The plugin provides interfaces AdminPolicySet and AdminPolicyStatus. For each policy, users should set the value thorugh AdminPolicySet and query the current setting through AdminPolicyStatus. We separeted these two interfaces so that developers can assign different groups of users to these interfaces. Currently the only policy is ServiceAllowList, which make bluez only allow a list of service by specified their UUIDs, but the plugin is also expected to provide more controls over other bluez behaviors. Since the second part is a plugin, it might not be necessary to land in upstream tree. Thanks. Changes in v3: - Rename plugins/admin_policy.c -> plugins/admin.c - Use device_added callback in btd_adapter_driver instead of listen for dbus - Add authorization method in profiles/health/mcap.c and block incoming connections in adapter authorization function. Changes in v2: - Move bt_uuid_hash and bt_uuid_equal functions to adapter.c. - Modify the criteria to say a device is `Affected` from any-of-uuid to any-of-auto-connect-profile. - Remove the code to remove/reprobe disallowed/allowed profiles, instead, check if the service is allowed in bt_io_accept connect_cb. - Fix a typo in emit_property_change in plugin/admin_policy.c:set_service_allowlist - Instead of using device_state_cb, utilize D-BUS client to watch device added/removed. - Add a document in doc/ Yun-Hao Chung (13): core: add is_allowed property in btd_service core: add adapter and device allowed_uuid functions mcap: add adapter authorization core: block not allowed UUID connect in auth core: add device_added and device_removed to adapter driver plugins: new plugin plugins/admin_policy: add admin_policy adapter driver plugins/admin_policy: add ServiceAllowList method plugins/admin_policy: add ServiceAllowList property plugins/admin_policy: add device callbacks plugins/admin_policy: add AffectedByPolicy property plugins/admin_policy: persist policy settings doc: add description of admin policy Makefile.plugins | 5 + bootstrap-configure | 1 + configure.ac | 4 + doc/admin-policy-api.txt | 65 ++++ plugins/admin.c | 589 +++++++++++++++++++++++++++++++++++ plugins/admin_policy.c | 653 +++++++++++++++++++++++++++++++++++++++ profiles/health/hdp.c | 1 + profiles/health/mcap.c | 39 ++- profiles/health/mcap.h | 7 + src/adapter.c | 154 ++++++++- src/adapter.h | 12 + src/device.c | 64 +++- src/device.h | 2 + src/profile.c | 12 + src/service.c | 39 +++ src/service.h | 2 + tools/mcaptest.c | 2 +- 17 files changed, 1642 insertions(+), 9 deletions(-) create mode 100644 doc/admin-policy-api.txt create mode 100644 plugins/admin.c create mode 100644 plugins/admin_policy.c -- 2.32.0.432.gabb21c7263-goog