Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1376740pxy; Sun, 1 Aug 2021 23:14:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6Dgl1+7GL1M7NK630Xe0TuiUEfFycrhRdL8+WmR/uAImWEF7qpfmicm34MX1QrlHXb/mn X-Received: by 2002:a92:c142:: with SMTP id b2mr746216ilh.26.1627884886054; Sun, 01 Aug 2021 23:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627884886; cv=none; d=google.com; s=arc-20160816; b=vIG18Pcm+VCUZSla5oObT08IYD1OsoUwYyb+VoegW1A0BkMtOe6/scmPYFJD++eTuP 2e0tbPwyJiWzQ5JNSnD74px2fd2whORHkkzjbK4DwHBuTD1DyLb86rNLQEyYGkV6F7Ay eI52HxlaWjrzQxck3sjme+wxivloq9StBOWPFV2drGR4R1kRds4HLq6OFXKpRoN+9u9J WFrCcLJb9q09jGkphaHF4Fo22PygrGzmMrM4MTEJ2f3EfHGNUe+hNifh1IfRpPYKnFeI 2xzID8EL6YPeSnSLZSnNeZ78jKdkXbT7pgWdv1Y6HFGAfhcQJNUwEBrAwyRdnKz60j0u tNvg== 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:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=L6lNNaSX6qQORZqT2VoBUMM9LUS7LaDIzlSN+vZ3p6I=; b=o3Nphge7jTnHmV+v6VbwuCgR32t1dTEBuUlp87xSDNSNmAEriPeSfyRxRXGH1AFlew tYF1fArr2cgyKrbGfLg2KeV2/QvqHEY2eWsgeg9J3NtIr/ahtWPe7axpI5aPDzMVLWvu iLa+AeBP9zDgb+/qeQJCUtvsmzs0cDXsNBvQXGUroYYHD7whQGb6MACeuXIqQWBOAi5l F3JwpTHZHKw3UiYss7rIr+4cD+SMk/XT4pyLR1xulET8np0WTmQk1M+Q4VPe0qGsFofy Gyhaifd6b/X8M21XbQTUcyLiqGEg8S6VgD/0VwcqCcgroCyIF13hZOxRCQAJhOfqrxLD vjxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ddkLMzzN; 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 d14si11463455ilq.43.2021.08.01.23.14.14; Sun, 01 Aug 2021 23:14:46 -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=ddkLMzzN; 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 S232123AbhHBGNV (ORCPT + 99 others); Mon, 2 Aug 2021 02:13:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbhHBGNU (ORCPT ); Mon, 2 Aug 2021 02:13:20 -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 A30B6C06175F for ; Sun, 1 Aug 2021 23:13:11 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id v71-20020a252f4a0000b029055b51419c7dso17971281ybv.23 for ; Sun, 01 Aug 2021 23:13:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=L6lNNaSX6qQORZqT2VoBUMM9LUS7LaDIzlSN+vZ3p6I=; b=ddkLMzzNl3oi3sd5UJx1c7+EXItedK9/+8CUUNGsnphjIWU7+Nhitaxv+FfulDUD3X qFOem8iviLclDogPvc5Tk1UKO4COECPtcj1yri2IDOoUSbgVjMcGYhdN4bCBZ9sfM/g1 d6hPLw77jqxDYAVRVgn8MRn9fuetwIoMZ5G4jWht5IsSA164qQUn4hwvQejyQfpSyy7s 3Om5Wy8JfrUPAQ4GEZqrRpNtqs79+RFPMQBpDHvKj6r1vYel68zoRFPEf7oUF4jwjtii zcVV3u6w3FoimzUn9HkBM18bKQBZMZNw/oOCgM5L+9JVfgJJMeg7Vn5/GAkYcJ6xvr49 ztaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=L6lNNaSX6qQORZqT2VoBUMM9LUS7LaDIzlSN+vZ3p6I=; b=hwMNKlwk20aAAQwTl74JY5/b526IfzOi3BOgEeHNV82Z3nfXvsqvWhZ1s0N9EuHNZN f0mpi1V74uyBon/kks8/0eWNU0DUnvIfXkXTuOT2DYyR8yXpvuQ1NqvfXKHs6ZgvRpG3 zSALWY8nwInYN6gJS3sOs/OKNQ6w2MXArXauMYKjaCXSMtngrehfEb93RagdM0MO3wzP voIYEuRTLrrAT5XuY3/8zXuWoaxPhwtratL2/RQryE+I6wC0hh5x9yOppcg3zxKWABo3 1nahumzWq/kxjypHianUUh6Lyo0kTCe4duxcHSnT/UIN3EJ+P9q9dVeyTu3rEGVF1z+a InRQ== X-Gm-Message-State: AOAM5326R6nubrY6X1/PzYNRIWBJpav4STFkYOv22VO+N0M9JEm+gVKJ zEaj6Qsn4ugWyXM03N6HUCg68mwm7/crK6QGLM1Az6MTV5hRJmMZccwYiaTD30SoigIITmpkM2b 3aO7oYf/akTIJNk56SgifpDXshtppwdgd1658Vb8wqZVLqbP1cd6opX4GBNIYk78NMsDQf9ImKV 6AfSs5RcpTWZM= X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:9f82:5515:89:f2cb]) (user=howardchung job=sendgmr) by 2002:a25:af81:: with SMTP id g1mr18498936ybh.172.1627884790844; Sun, 01 Aug 2021 23:13:10 -0700 (PDT) Date: Mon, 2 Aug 2021 14:12:41 +0800 In-Reply-To: <20210802061250.170975-1-howardchung@google.com> Message-Id: <20210802141140.Bluez.v7.4.Ia4dc489979e4bf7ffa3421199b1b9fd8d7f00bbc@changeid> Mime-Version: 1.0 References: <20210802061250.170975-1-howardchung@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [Bluez PATCH v7 04/13] core: block not allowed UUID connect in auth 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 This ensures any incoming profile connection will be blocked if its UUID is not allowed by the following assumption: 1. Each system profile asks adapter authorization when seeing a incoming connection. 2. Each external profile checks if its UUID is allowed by adapter when seeing a incoming connection. --- The following test steps were performed after enabling admin plugin: 1. Set ServiceAllowList to ["1234"]. 2. Turn on a paired classic keyboard. Verify it can not be connected. 3. Set ServiceAllowList to ["1800","1801","180A","180F","1812"] 4. Turn off and turn on the keyboard. Verift it can be connected. (no changes since v1) src/adapter.c | 5 +++++ src/profile.c | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index c7fe27d19a5d..6c8096147bdd 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -7118,6 +7118,11 @@ static gboolean process_auth_queue(gpointer user_data) if (auth->svc_id > 0) return FALSE; + if (!btd_adapter_is_uuid_allowed(adapter, auth->uuid)) { + auth->cb(&err, auth->user_data); + goto next; + } + if (device_is_trusted(device) == TRUE) { auth->cb(NULL, auth->user_data); goto next; diff --git a/src/profile.c b/src/profile.c index 60d17b6ae657..e1bebf1ee19c 100644 --- a/src/profile.c +++ b/src/profile.c @@ -1249,6 +1249,11 @@ static void ext_confirm(GIOChannel *io, gpointer user_data) DBG("incoming connect from %s", addr); + if (!btd_adapter_is_uuid_allowed(adapter_find(&src), uuid)) { + info("UUID %s is not allowed. Igoring the connection", uuid); + return; + } + conn = create_conn(server, io, &src, &dst); if (conn == NULL) return; @@ -1272,6 +1277,7 @@ static void ext_direct_connect(GIOChannel *io, GError *err, gpointer user_data) struct ext_profile *ext = server->ext; GError *gerr = NULL; struct ext_io *conn; + const char *uuid = ext->service ? ext->service : ext->uuid; bdaddr_t src, dst; bt_io_get(io, &gerr, @@ -1285,6 +1291,11 @@ static void ext_direct_connect(GIOChannel *io, GError *err, gpointer user_data) return; } + if (!btd_adapter_is_uuid_allowed(adapter_find(&src), uuid)) { + info("UUID %s is not allowed. Igoring the connection", uuid); + return; + } + conn = create_conn(server, io, &src, &dst); if (conn == NULL) return; -- 2.32.0.554.ge1b32706d8-goog