Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5229761pxv; Wed, 28 Jul 2021 06:17:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHLxp1rLRwKDogJ6tNep/xiVOCCunqWr1ia86v0xIlHIkl2EpyVhioiuYr9RDqn0CUwoef X-Received: by 2002:a6b:b24e:: with SMTP id b75mr23846592iof.94.1627478268471; 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=C19m4yaIJy1VKd4eXMTxwZsDCRoCCA+uy+smkzueo7ca++caAMuvAWiEhV1e8fRA+f 8+BZPOvub2GHCIScztWv/lvaV6k8vFMb5B6AzCJZ/mLP3OTT9+Yo6pg2B8V4eFIWQETG 9acFXM77FNo1JsGGAHQ3k9jXiPSzXBrpMZBj7N2b94ZmPGs0eUxpV8f8jIh6qSK0/78y HkTaQU/cDNOLpBjGrkwIeNhg+eHyQvyTwXmdhIJal3Sop8bKfsaPdu3PTd/VDXg8379B XtiXBCQOE8Cr1GSgYaWlIcQHwyM7vIb0V5HG+IcNXDJKDWMlEGpgCVzyQ+w+t/ozQiRn EqcQ== 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=7edK40cZnbgtgLANdMuyepBsOSk6qB2TDi4Pn5PpTyw=; b=u4Y2tAtlAii3nYwVv1KUXVx5jQ5EYoWtWYO2aPi0+9pGFi8YaZmYYYcBHnwTl2yyvt XeK4acl/i9W3y9CP4imNfcmAsPo34fFu5bcYoNQdodvlVmCTgkj7d/X3wyXGxMN1aXv4 3mWi4e0owzklieEl1lnIE2gBXERc4WOkIvMc2e058OTmBMFR40aPaIZnwbeErx39BAus AZhQKGNqXdd0W94cQOnQQhTGh8MiV5OnXm5Tww6lkUTEZb5JSZVwGk9oo02Q61JnV+4R H1cLNpg5pxjSN9AZGTsqiKd7VWNQkNDgukastRFIzYUpLjwIVDHkUGsxynafrUk2+A+A mcCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Od7Mgcum; 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 b26si7158809ioa.63.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=Od7Mgcum; 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 S236217AbhG1NQB (ORCPT + 99 others); Wed, 28 Jul 2021 09:16:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233315AbhG1NQA (ORCPT ); Wed, 28 Jul 2021 09:16:00 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4250AC061757 for ; Wed, 28 Jul 2021 06:15:59 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id t101-20020a25aaee0000b0290578c0c455b2so2766697ybi.13 for ; Wed, 28 Jul 2021 06:15:59 -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=7edK40cZnbgtgLANdMuyepBsOSk6qB2TDi4Pn5PpTyw=; b=Od7MgcumYt0KOUlJyJNmq8fACOSs2CE+5j71UFOU/YCvZRTjh/WG0k90PAw8fan+L+ pmeL8jt7WPH4q5C6bovT/69PzzflxMKX9U7Pl0Fw1Yb1TAVG/vGjPPRxUP3ANuvfi/JU YN1MerMq/st7FY7307UtTQdgewq/MW027eIJVlQUQ5vfl1LHnHtBkulN7YQs9dPnjA13 QDN7/DqGEd0PEMlmw4keBAkadI+U66AWwvxCZrCsxW50l28hvLOc9wGUId9tJES50Phh hqvPyvNVXii15GZG1K0oVLsWqtmqHMi87SeuKay1cHaWV+pUhicD8IU60bbRofh2vvrD M7ng== 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=7edK40cZnbgtgLANdMuyepBsOSk6qB2TDi4Pn5PpTyw=; b=WJcOXeeyP5NaQQoVj8YFFdwdIE3fYp4ngdt5X/I8XAHeA/BxLOBgeEKYJv0PmR8gGB 11JvwavucwekkOXO12IMUNQJP2zv7RbtEKX0esqEbP5GfR+Tcq68ue2eADVcdAScfZr1 xSFEbJVMBfJsBDYnfqcHgxBlgRuovOzY08zByjToHsDgBTNUwp+jbYjmajxUD5WUWpz0 qSOnkuZNGM9zn++Py8cLWMzkvhv6HN1wYwGX6Su/m5aIWcBLSwypcWpHhy6bR1eQWGCR N8yuLutDkb3Q98xsverwc8OQaQfOwd+YcNnmOg9P1L7/mByG5+Ynh1lZ0MnZcMKJY2dx gxcg== X-Gm-Message-State: AOAM531cvsfz82/+ZM+38EF3wu/Gt6RFS8xFmujNhIeNEmtZ9G8yTUtp z6PexEU0X/U7I7k7rcx6hdcQ8zONkuFd/tZgYXhWyYIgAzTxIe+5OOujZZYS7CZaJoSjmqXTUTa Jpa71o1oq11GWtfL1dfsc+fIX7MxbZpFFzh4z4kvdHK7zqo7TUs3eVkYQGf7IxZWVqg3HRzpvuJ TNvUrbtSsg1W4= X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:9b6a:9d1f:2f3e:45de]) (user=howardchung job=sendgmr) by 2002:a25:d1c4:: with SMTP id i187mr4813620ybg.200.1627478158415; Wed, 28 Jul 2021 06:15:58 -0700 (PDT) Date: Wed, 28 Jul 2021 21:15:20 +0800 In-Reply-To: <20210728131529.3310558-1-howardchung@google.com> Message-Id: <20210728211405.Bluez.v3.4.Ia4dc489979e4bf7ffa3421199b1b9fd8d7f00bbc@changeid> Mime-Version: 1.0 References: <20210728131529.3310558-1-howardchung@google.com> X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog Subject: [Bluez PATCH v3 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_policy 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 | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index c7fe27d19..6c8096147 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 60d17b6ae..58500c747 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,12 @@ static void ext_direct_connect(GIOChannel *io, GError *err, gpointer user_data) return; } + if (btd_adapter_is_uuid_allowed(adapter_find(&src), ext->uuid)) { + info("UUID %s is not allowed. Igoring the connection", + ext->uuid); + return; + } + conn = create_conn(server, io, &src, &dst); if (conn == NULL) return; -- 2.32.0.432.gabb21c7263-goog