Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5935771rwb; Wed, 21 Sep 2022 14:55:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4b6fPQpQibHjEKFm0brCPpyWZtxtyXe0UVH9Gus7doHXt5G3mV17cl5PdrykQ46pPTxouZ X-Received: by 2002:a05:6402:254f:b0:452:be91:c0d3 with SMTP id l15-20020a056402254f00b00452be91c0d3mr189351edb.314.1663797319181; Wed, 21 Sep 2022 14:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663797319; cv=none; d=google.com; s=arc-20160816; b=cucokpN2QwaxRvmtXrZfmRsIR87renR//3ldj8QkJ/Xjae4jFYAZO+b90YQWWuq5Gz QbYLOukqj8MN0GG2FDw1MYQsZQl3vuAEHLV8qHTyoPhXfzmdJboKDG/m1ppLy6VwgBta wS/vxiRN75BGw1htIq5rOOOyp4PnAi0TDjU2i2rL5a9mYjn9oStCIvFm8CklFjNPcWge 2Xm+yl/37UXAyv5QaAARXA909CUx7zGb6xubx3y1gs+Eq9WMHCYhsycNm7JSCswElJMD LHG4Mqe7hWe2X7S/sSR4Eh6i2wJ4yqc/QCx65PyYEFW4ck5HV7R2Iz2dobKMxyn0gBZj wtPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=vwM4v1MnP7853alqfAnZiMdkfGJRHdUbxt+yknv4j4Q=; b=A3QyRF4k8b7tN2dpJ5WIK5q+trYvnymybJoa/lJBWIbyD37BIXazYjIpPTzOQn/FSj LZUOjLwUXKNxtesqc12QtoiTe33Kqeguvr5WchswCAdqguSnqhnh4rwVeZqa53DBKty4 87C/h0AfXD6k2W35ye6hxADWTQZZb0aj3ENWwtYyoGscAsgZgp56Kjesf3SQNjAoyhSI PDjbjkcywtw9/gIgyl2g82bpzaTd0ir8+RkO8AWuPEkyRGpyXDXSHp5BHLgjlR5zeX1L D+OpoY8tHaSCIa2duI/A18rX4OXcbn8xgt85eTA3pqQ0WKdla2mJesLfptGq7mreTiUA 4CRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bCBmV2Bv; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb13-20020a170907160d00b0076f23cf9c76si4293306ejc.195.2022.09.21.14.54.27; Wed, 21 Sep 2022 14:55:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=bCBmV2Bv; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229762AbiIUVrC (ORCPT + 99 others); Wed, 21 Sep 2022 17:47:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229844AbiIUVrB (ORCPT ); Wed, 21 Sep 2022 17:47:01 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57B77A6C09 for ; Wed, 21 Sep 2022 14:46:59 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id q35-20020a17090a752600b002038d8a68fbso201219pjk.0 for ; Wed, 21 Sep 2022 14:46:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date; bh=vwM4v1MnP7853alqfAnZiMdkfGJRHdUbxt+yknv4j4Q=; b=bCBmV2BvznmUXhOYE54f6j/Ijqj1bRHoHhNTgYMa+aa2i58/QSMAw6EpE+kh/8W+jg TypN7q3Ipv7c0PVv/h4WZBYpHxmwyJPNZacmRAPQbj+w55gfx1Ta9cONtWHSbLtwhqyk Cb7d9sULus/3mXDXv7XM7kj31JBfNA0EsKxA/NNB1GOH5xHdBbRYXnOdUxFC7Uzn4w8I bTa1aYMq+W9acPKddVp3JXcxEg55dtQzt+mAIelmCtrB6Rqbf4g56CLZ66h7MqLIEPeP Y7ZWmh6DMSOoMomLDR6lqsz5X5xHPvxCh/YuJovbFddTX5BeB5kcE4Q7vNNRe1Z+A7zc 0yrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date; bh=vwM4v1MnP7853alqfAnZiMdkfGJRHdUbxt+yknv4j4Q=; b=LbYaEtxr1Fv2vL+KNKTe8QunfJ6x7OQY4pta+zyVreH2Dx6karTLdbMwz1nBBoxALG XkVqO5N08QIXLhJuVm/80agyEAeS0OP8Vd50z5k3vAFYVhSmrL4XvzvTEeE0JOBNXfUA CbwsT5KmcLPrHEQoXUc5MNbAUvBbHhP3/ZzG0UdZOlXovWyPrvbPiif4vh7g7cjrCwwl TYt4pUJRmbMj9VdiBJPilApWy3YgfUti39Zxz0F3DItgB3JOTR9uo/Nnn6VhkDQAxGZV XBYDXfATlAq1zKNwCgZ3pZ+5NK54xaGJNWhSU8c3FGXPJecZbI1KmLPuG7uTAybCpUV9 xu1g== X-Gm-Message-State: ACrzQf1/STC7Kx+gxVd3p+fcXYFFibmtd6/wT7x1wcAqy5XjLOg99eks jPGoPwuPuULCesm3wwYs9itEVYlEMIM= X-Received: by 2002:a17:902:c410:b0:177:82b6:e6ed with SMTP id k16-20020a170902c41000b0017782b6e6edmr232748plk.27.1663796818299; Wed, 21 Sep 2022 14:46:58 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id t11-20020a170902e84b00b001782a6fbcacsm2506526plg.101.2022.09.21.14.46.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 14:46:57 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 1/3] gatt: Fix not setting permissions for CCC Date: Wed, 21 Sep 2022 14:46:54 -0700 Message-Id: <20220921214656.2241730-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz CCC shall always have both Read and Write permissions set in addition to what application set. Fixes: https://github.com/bluez/bluez/issues/399 --- src/gatt-database.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gatt-database.c b/src/gatt-database.c index 89a3dc47560b..a212dfc4e694 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -1238,7 +1238,8 @@ static void populate_gatt_service(struct btd_gatt_database *database) NULL, NULL, database); database->svc_chngd_ccc = service_add_ccc(service, database, NULL, NULL, - 0, NULL); + BT_ATT_PERM_READ | + BT_ATT_PERM_WRITE, NULL); bt_uuid16_create(&uuid, GATT_CHARAC_CLI_FEAT); database->cli_feat = gatt_db_service_add_characteristic(service, @@ -1726,8 +1727,10 @@ static bool parse_chrc_flags(DBusMessageIter *array, uint8_t *props, *perm |= BT_ATT_PERM_WRITE; } else if (!strcmp("notify", flag)) { *props |= BT_GATT_CHRC_PROP_NOTIFY; + *ccc_perm |= BT_ATT_PERM_WRITE; } else if (!strcmp("indicate", flag)) { *props |= BT_GATT_CHRC_PROP_INDICATE; + *ccc_perm |= BT_ATT_PERM_WRITE; } else if (!strcmp("authenticated-signed-writes", flag)) { *props |= BT_GATT_CHRC_PROP_AUTH; *perm |= BT_ATT_PERM_WRITE; @@ -2896,6 +2899,9 @@ static bool database_add_ccc(struct external_service *service, !(chrc->props & BT_GATT_CHRC_PROP_INDICATE)) return true; + /* Always set read/write permissions */ + chrc->ccc_perm |= BT_ATT_PERM_WRITE | BT_ATT_PERM_READ; + chrc->ccc = service_add_ccc(service->attrib, service->app->database, ccc_write_cb, chrc, chrc->ccc_perm, NULL); if (!chrc->ccc) { -- 2.37.3