Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5931622pxv; Thu, 29 Jul 2021 01:58:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoTutp4WBjXwkIUpW+dflj4ez8xd5hHrPQfG9zKvEPBn0IEqvBKHyMLREKMBow9tDjun1P X-Received: by 2002:a6b:b795:: with SMTP id h143mr3283231iof.74.1627549117059; Thu, 29 Jul 2021 01:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627549117; cv=none; d=google.com; s=arc-20160816; b=zQ29pbKU45phgGqd086Psd/27LsZcYdH5Yt9+cI32EiSAEEkNskXllS+uXnuY3G+TO qcbsMaZo+ybNXBBcwrNwmi6dnGjBQETnI8e6zwwhCaysiBcgGSh3AT3qcUoFFacL4l4B ouiu37Aj+va6Fa60eRWkEn7vyxn4nO/nlc4kLgzrLIaj+RfbQ8uulvTxHDSSSsYq03l1 XcUya+mAkcY/ysAv0ogsBPcWMTNrE27C4+uNLP07cDq/X7QgkuTLj4F13kt+/B98wrFQ VTKPl3CyOdQMcld1cRmgpDsD9JDU7UjGvbfzhPrl6Pjf7hZSiCvKQWEd0AIEXiLtqu62 KMwA== 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=L7MblLuSrbsDGknoKMFU48tI/k3+p9nDFuXCQMLTjTI=; b=VtqlIFvBI+Z/Kiv49SIRmqpknZEK9NtPElH0EkarCpRauhIPDEQ0S3HB/2ARjtJ0HI 5HT5JO0/QWzNCGirc1G25CAv2Pxph95rF6Kw5hFWC2BCy/CbH3UkiuJgPfAbH86pyAYD etQAixRZL5W3M8I/dEd+hvD22FgO9JQGxyrrm4CdPviXaAuWMVYby5Rs0TU/1wQsj1Qe 3GsOeMsYDMLkj3AtrCcGjNlhJ4lRch6i+mgvfMbq0NhEUpkRvZwhmwksHPClW7CtALNZ ox+O+gve/0DRSMJPVmG2mdD5wpY4WubesQc2l2ojp02Okv0dHsZtqETqAk4tbjxJDeIX +p2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rYXSiq2E; 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 w4si2918226ilm.77.2021.07.29.01.58.06; Thu, 29 Jul 2021 01:58:37 -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=rYXSiq2E; 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 S234972AbhG2I5D (ORCPT + 99 others); Thu, 29 Jul 2021 04:57:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234886AbhG2I5C (ORCPT ); Thu, 29 Jul 2021 04:57:02 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3F8DC061757 for ; Thu, 29 Jul 2021 01:56:58 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id w26-20020a05620a129ab02903b9eeb8b45dso3420981qki.8 for ; Thu, 29 Jul 2021 01:56:58 -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=L7MblLuSrbsDGknoKMFU48tI/k3+p9nDFuXCQMLTjTI=; b=rYXSiq2EkZOOw6ARZzpT/N8pRWzodPMsraVi/YHroI3O9xwGloBY6HMmS+EvhcnLDq xdEHnZRnXTtfWkTRQgZak7kP306zIput7Ti1mhSN9f3VJP0H3MX1pVV12DOL3hxN8hmB LoDcl7K1vkdywTZmbRJpRfqlSL1qjkrti7FLfSd70DW+sUNqx4H7IN4XGRuR9ybL5tzU 07SrCAgyVQzFI1nQyfw/GwPQSBSCjv7SfqWpwtcPFYWvK7pCT/OBSQ/6OqG4Odbo2WXO Ti7/zgt2tzeCdesMQRi7G9n6lBcuyLtoa6jqB9m0Wkd2HHqUPfgZ+aoEKWaxEnXdSBoe hf5Q== 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=L7MblLuSrbsDGknoKMFU48tI/k3+p9nDFuXCQMLTjTI=; b=RX4IA/vt6ybbAxX0zTKIG5mkrSnDs8IJxXVQvIvTauE0RxZAhJzehf+mTr/30gsdgo tFj1ry7duBR6Ubd6Kxpdw25qNdx8Fw6qU0mPHuLpyZfvpATBDNZ2w3EsRviMJiJq7swg m6M2YRuHeG8o634sqfypDUnxnxxwzQIK8o5kXZ9FusIdx+w4+vxoTBs127RUPcDITa7I /jby/+vgYDJxe2IGQwsaeF7pmDo3fOoioiYlKkAINTrsDk0PjIaz+ZThgJyLGIiTcJX4 8o9WJjvDOitpBG0KlWmoVIMD+FpO8qEZbM8Kdosa1GDp/9DbH3HaXe3xwz4rrJU6IGWe Fy+g== X-Gm-Message-State: AOAM533Pk2oa+8BTjF9r5Emg7vZYP6rDbXOxyx+zfHlbGft/jXqnkJPx p0+7ybp1vjEdiRFZfXRbVItcA8aNM2Psu06KFDW3zPmLqOSN+0uxdCvThP3uE6xGNqCyMJE0ozb 9HMhz6xVTR04Q551AjbsRv+agjnImrHYkssrxkdfWJo4krlb01047C7tefYeICd4DsgLV5MYzMa xF2xNmBNg2mB8= X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:ff72:1420:4502:fdaf]) (user=howardchung job=sendgmr) by 2002:ad4:538c:: with SMTP id i12mr3926250qvv.51.1627549018014; Thu, 29 Jul 2021 01:56:58 -0700 (PDT) Date: Thu, 29 Jul 2021 16:56:38 +0800 Message-Id: <20210729085651.3600926-1-howardchung@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [Bluez PATCH v5 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 v5: - Fix compiler errors in plugins/admin.c Changes in v4: - Update commit message (admin_policy -> admin) - remove old plugins/admin_policy.c 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: add admin_policy adapter driver plugins/admin: add ServiceAllowList method plugins/admin: add ServiceAllowList property plugins/admin: add device callbacks plugins/admin: add AffectedByPolicy property plugins/admin: persist policy settings doc: add description of admin policy Makefile.plugins | 5 + android/health.c | 2 +- bootstrap-configure | 1 + configure.ac | 4 + doc/admin-policy-api.txt | 65 +++++ plugins/admin.c | 592 +++++++++++++++++++++++++++++++++++++++ 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 | 11 + src/service.c | 39 +++ src/service.h | 2 + tools/mcaptest.c | 2 +- 17 files changed, 992 insertions(+), 10 deletions(-) create mode 100644 doc/admin-policy-api.txt create mode 100644 plugins/admin.c -- 2.32.0.554.ge1b32706d8-goog