* [PATCH] shared/gatt-client: Do not assume single descriptor is CCC
@ 2026-11-30 7:33 Matthew Garrett
2026-11-30 10:39 ` bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Matthew Garrett @ 2026-11-30 7:33 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Matthew Garrett
3.3.1.1 of the spec notes that notify and indicate properties require
that a CCC descriptor must be present, which implies that if a
characteristic only has a single descriptor it must be a CCC.
e8b9e6e33087 implements this logic, and assigns the descriptor to the
characteristic's CCC role.
Unfortunately, reality disagrees. We already handle notification
characteristics that lack a CCC - we allow notifications to be enabled
and assume that something else will happen to enable them, and then
deliver them. But because of e8b9e6e33087, if a notification
characteristic has a single descriptor following it, we will assume that
it's a CCC and so will assume that we can write to it in order to enable
notifications, and will error out if we can't.
The GE Cync bulbs that I have here have make use of the Telink BLE mesh
protocol. They provide a service with the following characteristics:
Service 00010203-0405-0607-0809-0a0b0c0d1910 (handle 0x0010)
Characteristic 00010203-0405-0607-0809-0a0b0c0d1911
decl 0x0011, value 0x0012, props 0x1e (read/write-no-resp/write/notify)
Descriptor 0x0013: 0x2901 (User Description), value "Status"
Characteristic 00010203-0405-0607-0809-0a0b0c0d1912
decl 0x0014, value 0x0015, props 0x0e (read/write-no-resp/write)
Descriptor 0x0016: 0x2901 (User Description), value "Command"
Characteristic 00010203-0405-0607-0809-0a0b0c0d1913
decl 0x0017, value 0x0018, props 0x06 (read/write-no-resp)
Descriptor 0x0019: 0x2901 (User Description), value "OTA"
Characteristic 00010203-0405-0607-0809-0a0b0c0d1914
decl 0x001a, value 0x001b, props 0x0e (read/write-no-resp/write)
Descriptor 0x001c: 0x2901 (User Description), value "Pair"
Note that ...1911 has notify support, but the following descriptor is
User Description rather than CCC. e8b9e6e33087 means we assume that it's
a CCC anyway, and as a result attempting to enable notifications results
in a write to 0x13 which is read-only and gets an error and we're all
sad. We do not get any notifications today, or any other day. What the
hardware actually expects is that we write 0x01 to 0x0012, at which
point notifications are enabled, but if we've already errored out on
notification enabled then they'll never be delivered even if the
hardware is sending them.
This patch reverts most of e8b9e6e33087 and adds additional test cases
that correspond to the behaviour seen in this device, and now I get
notifications.
Fixes: e8b9e6e33087 ("shared/gatt-client: Automatically add CCC when discovering")
---
src/shared/gatt-client.c | 19 -------------------
unit/test-gatt.c | 31 ++++++++++++++++++++++++++++++-
2 files changed, 30 insertions(+), 20 deletions(-)
diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c
index 31982bd29..6b177ebc0 100644
--- a/src/shared/gatt-client.c
+++ b/src/shared/gatt-client.c
@@ -787,25 +787,6 @@ static bool discover_descs(struct discovery_op *op, bool *discovering)
desc_start = chrc_data->value_handle + 1;
- if (desc_start == chrc_data->end_handle &&
- (chrc_data->properties & BT_GATT_CHRC_PROP_NOTIFY ||
- chrc_data->properties & BT_GATT_CHRC_PROP_INDICATE)) {
- bt_uuid_t ccc_uuid;
-
- /* If there is only one descriptor that must be the CCC
- * in case either notify or indicate are supported.
- */
- bt_uuid16_create(&ccc_uuid,
- GATT_CLIENT_CHARAC_CFG_UUID);
- attr = gatt_db_insert_descriptor(client->db, desc_start,
- &ccc_uuid, 0, NULL,
- NULL, NULL);
- if (attr) {
- free(chrc_data);
- continue;
- }
- }
-
/* Check if the start range is within characteristic range */
if (desc_start > chrc_data->end_handle) {
free(chrc_data);
diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index 3a35ccbc1..e25991639 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
@@ -321,7 +321,9 @@ struct context {
raw_pdu(0x09, 0x07, 0x02, 0x00, props, 0x03, 0x00, 0x05,\
0x2a), \
raw_pdu(0x08, 0x03, 0x00, 0x04, 0x00, 0x03, 0x28), \
- raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a)
+ raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a), \
+ raw_pdu(0x04, 0x04, 0x00, 0x04, 0x00), \
+ raw_pdu(0x05, 0x01, 0x04, 0x00, 0x02, 0x29)
#define SERVER_MTU_EXCHANGE_PDU raw_pdu(0x02, 0x17, 0x00)
@@ -3922,6 +3924,33 @@ int main(int argc, char *argv[])
raw_pdu(),
raw_pdu(0x1B, 0x03, 0x00, 0x01, 0x02, 0x03));
+ /*
+ * Characteristic declaring Notify with a single non-CCC descriptor
+ * (0x2901 User Description): descriptor discovery must not assume
+ * 0x2902, and notification registration must succeed without writing
+ * to the non-CCC descriptor.
+ */
+ define_test_client("/robustness/notify-single-non-ccc-desc",
+ test_client, NULL, &test_notification_1,
+ CLIENT_INIT_PDUS,
+ raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
+ raw_pdu(0x11, 0x06, 0x01, 0x00, 0x04, 0x00, 0x10, 0x19),
+ raw_pdu(0x10, 0x05, 0x00, 0xff, 0xff, 0x00, 0x28),
+ raw_pdu(0x01, 0x10, 0x05, 0x00, 0x0a),
+ raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x01, 0x28),
+ raw_pdu(0x01, 0x10, 0x01, 0x00, 0x0a),
+ raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x02, 0x28),
+ raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a),
+ raw_pdu(0x08, 0x01, 0x00, 0x04, 0x00, 0x03, 0x28),
+ raw_pdu(0x09, 0x07, 0x02, 0x00, 0x10, 0x03, 0x00, 0x11,
+ 0x19),
+ raw_pdu(0x08, 0x03, 0x00, 0x04, 0x00, 0x03, 0x28),
+ raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
+ raw_pdu(0x04, 0x04, 0x00, 0x04, 0x00),
+ raw_pdu(0x05, 0x01, 0x04, 0x00, 0x01, 0x29),
+ raw_pdu(),
+ raw_pdu(0x1B, 0x03, 0x00, 0x01, 0x02, 0x03));
+
/* Service Changed with Indicate: indications are enabled */
define_test_client("/robustness/svc-chngd-indicate", test_client,
NULL, &test_svc_chngd_register_1,
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: shared/gatt-client: Do not assume single descriptor is CCC
2026-11-30 7:33 [PATCH] shared/gatt-client: Do not assume single descriptor is CCC Matthew Garrett
@ 2026-11-30 10:39 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2026-11-30 10:39 UTC (permalink / raw)
To: linux-bluetooth, mjg59
[-- Attachment #1: Type: text/plain, Size: 5260 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/series/1226420/
---Test result---
Test Summary:
CheckPatch FAIL 0.43 seconds
GitLint PASS 0.27 seconds
BuildEll PASS 18.75 seconds
BluezMake PASS 276.06 seconds
MakeCheck FAIL 4.12 seconds
MakeDistcheck FAIL 113.66 seconds
CheckValgrind FAIL 172.93 seconds
CheckSmatch PASS 252.51 seconds
bluezmakeextell PASS 93.40 seconds
TestFunctional PASS 1128.87 seconds
IncrementalBuild PASS 277.24 seconds
ScanBuild PASS 971.88 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
shared/gatt-client: Do not assume single descriptor is CCC
ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit e8b9e6e33087 ("shared/gatt-client: Automatically add CCC when discovering")'
#103:
e8b9e6e33087 implements this logic, and assigns the descriptor to the
WARNING:COMMIT_LOG_LONG_LINE: Prefer a maximum 75 chars per line (possible unwrapped commit description?)
#119:
decl 0x0011, value 0x0012, props 0x1e (read/write-no-resp/write/notify)
ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit e8b9e6e33087 ("shared/gatt-client: Automatically add CCC when discovering")'
#132:
User Description rather than CCC. e8b9e6e33087 means we assume that it's
ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit e8b9e6e33087 ("shared/gatt-client: Automatically add CCC when discovering")'
#141:
This patch reverts most of e8b9e6e33087 and adds additional test cases
/home/runner/work/bluez/bluez/src/patch/15036435.patch total: 3 errors, 1 warnings, 68 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/home/runner/work/bluez/bluez/src/patch/15036435.patch has style problems, please review.
NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: MakeCheck - FAIL
Desc: Run Bluez Make Check
Output:
./test-driver: line 119: 41366 Aborted "$@" >> "$log_file" 2>&1
./test-driver: line 119: 41376 Aborted "$@" >> "$log_file" 2>&1
./test-driver: line 119: 41446 Aborted "$@" >> "$log_file" 2>&1
./test-driver: line 119: 41489 Aborted "$@" >> "$log_file" 2>&1
make[3]: *** [Makefile:10436: test-suite.log] Error 1
make[2]: *** [Makefile:10571: check-TESTS] Error 2
make[1]: *** [Makefile:11074: check-am] Error 2
make: *** [Makefile:11076: check] Error 2
##############################
Test: MakeDistcheck - FAIL
Desc: Run Bluez Make Distcheck
Output:
make[4]: warning: -j4 forced in submake: resetting jobserver mode.
../../test-driver: line 119: 72123 Aborted (core dumped) "$@" >> "$log_file" 2>&1
../../test-driver: line 119: 72131 Aborted (core dumped) "$@" >> "$log_file" 2>&1
../../test-driver: line 119: 72171 Aborted (core dumped) "$@" >> "$log_file" 2>&1
../../test-driver: line 119: 72202 Aborted (core dumped) "$@" >> "$log_file" 2>&1
make[4]: *** [Makefile:10436: test-suite.log] Error 1
make[3]: *** [Makefile:10571: check-TESTS] Error 2
make[2]: *** [Makefile:11074: check-am] Error 2
make[1]: *** [Makefile:11076: check] Error 2
make: *** [Makefile:10993: distcheck] Error 1
##############################
Test: CheckValgrind - FAIL
Desc: Run Bluez Make Check with Valgrind
Output:
tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:14518:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
14518 | int main(int argc, char *argv[])
| ^~~~
make[3]: warning: -j4 forced in submake: resetting jobserver mode.
./test-driver: line 119: 102389 Aborted (core dumped) "$@" >> "$log_file" 2>&1
./test-driver: line 119: 102399 Aborted (core dumped) "$@" >> "$log_file" 2>&1
./test-driver: line 119: 102459 Aborted (core dumped) "$@" >> "$log_file" 2>&1
./test-driver: line 119: 102489 Aborted (core dumped) "$@" >> "$log_file" 2>&1
make[3]: *** [Makefile:10436: test-suite.log] Error 1
make[2]: *** [Makefile:10571: check-TESTS] Error 2
make[1]: *** [Makefile:11074: check-am] Error 2
make: *** [Makefile:11076: check] Error 2
https://github.com/bluez/bluez/pull/2947
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-30 10:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 7:33 [PATCH] shared/gatt-client: Do not assume single descriptor is CCC Matthew Garrett
2026-11-30 10:39 ` bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox