Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2361960pxy; Tue, 3 Aug 2021 04:46:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjolhUBD6oHCk96MYYZqQqfTps07pLi5fpQqbmis5x3B/eyRywH8ROhmbOrmEJXkqcfjsz X-Received: by 2002:a05:6402:1cb6:: with SMTP id cz22mr24703144edb.148.1627991179484; Tue, 03 Aug 2021 04:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627991179; cv=none; d=google.com; s=arc-20160816; b=wKxHFZu4O1JB1+2wdIunKA3X3EkW2MckVyeguH6jEFW5MWFYyeEEwf5/tClLMygmRn GVT+odbPxIUbB5Vm6IF3MHmOVzC/Y3CCgdMUJ0qX0X3wxAx9TWpQbBlsaekYtFMNJ1qr cX6bJH+ZbIVD4Y8/7rT687yv4OMqO2SS7clpNwZj0o66bhR28BH6HuXgMOAI1TmkG++U bOtvLfl8Y8t9ncZe4aneCDRi8PAGc063nnocZMOgsqa/b0eX9+mm3Lbw/aylELWt0bb8 IQpnZk3rMv1MvEoubIuO0Zrbfbo9Icg0FK1TwlZg438fjaX/yv/xImiJuqD/JI+Nr7r9 lZ+Q== 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=b/tp9qPc1ZnMdrHLzMJAUnrnMira869jxfHG/TPZ/u8=; b=p937oBNjvbZK69E00zmhxL9RSDNnUOwM9rJtjpZJCy6oOF+SPconwBZqI5CF3ZbG77 WI2HzwFsxqCkKXVoCozYp5bysoPZlLGhAnOfrJy+7apb8ydjHbCLfI/S0IqueNhk6MlE tzqgJ36wxP+1WHTGFf4AX0BXmUBohVzgYhENwA2mytWAR2S/Xl/qjD3MiE+ZlioVg9Vk 9FkWi3XtcmL2yNXYOwU/Xs3WZC+Z+YFLo/7tV1qf+pNemcNFLGoq7CQ7LcCg2Ay2cAJo lNYL2q9bCz/GU2WXSGmh/JEianwTi/Um7gR6y3TYvXdtcQVq2ZINZAVXhilOAiC8TqcN RPSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VF23Zivb; 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 j18si6691997edw.279.2021.08.03.04.45.35; Tue, 03 Aug 2021 04:46:19 -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=VF23Zivb; 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 S235959AbhHCLoo (ORCPT + 99 others); Tue, 3 Aug 2021 07:44:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235681AbhHCLnz (ORCPT ); Tue, 3 Aug 2021 07:43:55 -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 365D3C06179A for ; Tue, 3 Aug 2021 04:43:42 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 16-20020a250b100000b029055791ebe1e6so22761898ybl.20 for ; Tue, 03 Aug 2021 04:43:42 -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=b/tp9qPc1ZnMdrHLzMJAUnrnMira869jxfHG/TPZ/u8=; b=VF23ZivbdSXYTWGC/enst2V8RDUXp+yMyWQ2hYPR0AWuA7mrN/Kt9r7X2B5ZDZzAbk b8pNeKodvsgvMEhv/pz5b5hlEcOc/xz6THxia0UlotSWEoJH4P5X19evJozF78k5tNbC re3FmkJjNc1DOBQ9RFahnhBJ9KKZ/x6XsuwdzzNXWLvLxWMzR9LNbSzd2Sy/qSKk/g+8 wxh5ap6CSq1TZ4W6ZHSZbcTzlEndvb8w5DjPIMPygiaU12VicxBltPqhyrZ3DA7pbcP0 6P6oP1v71cLRxpcuaToUdWLaSSLWraUF2qfMsCFE1tDrmaxcJnbQ0uBuqNcYIe+FGvoc Itgw== 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=b/tp9qPc1ZnMdrHLzMJAUnrnMira869jxfHG/TPZ/u8=; b=M/hE0urAwtH17ME5ik5Xxnvs0bxw8Icw53yqkGQR0Bq+bMgEhXrpAon03SO9P4958A zyhF5QMdFIUyP2u9HwRoKq0bxIbPV0L6aCITI6WNoIQfodQsno/rtLX5Wouf+icK1Xhq PbNhC9eSs/WegaOIKHehFsw7/oo/7bho01wIuyjZipLHjFWGxRX2AQIIu9Cun3jiH/Ev ADqBIh+Bf966glhm735BNMQanO2h5ek/XDX3D8Ht5yhcPoYw9KSERAnlQ6hyB81KFTer fTGVTQLTBUWddK3l2EMPVti7vJHeUhdHce31Q+0R1ZMA827FZ0XqrJqTVr5jpkVrRwgp I/5Q== X-Gm-Message-State: AOAM533FTSH427+pAoR52BzdM0UYw4n2LDXptzyrYSrlTq8OAiTcPdwo kuSLvwKVOr0Gcj+cly8uYD5UAqpo5r1EJASwUA+rLDc+tPr/MQJBgeIpwewXECqF4HvhAopiaMQ 4FXlwM4qXwbogB+VG5st/K+de80AiLvbonl2FRnk930cUnTfDyg4M2TQHX2YC6OQzonVjlwW8Bm e3ha23Dqvlm7I= X-Received: from howardchung-p920.tpe.corp.google.com ([2401:fa00:1:10:ef55:8161:c77b:7a8d]) (user=howardchung job=sendgmr) by 2002:a25:bec2:: with SMTP id k2mr28804346ybm.234.1627991021403; Tue, 03 Aug 2021 04:43:41 -0700 (PDT) Date: Tue, 3 Aug 2021 19:43:08 +0800 In-Reply-To: <20210803114317.801840-1-howardchung@google.com> Message-Id: <20210803194127.Bluez.v9.4.Ia4dc489979e4bf7ffa3421199b1b9fd8d7f00bbc@changeid> Mime-Version: 1.0 References: <20210803114317.801840-1-howardchung@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [Bluez PATCH v9 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 0ca4b4f6ff56..3c2008285fbd 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -7182,6 +7182,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