* [PATCH 0/2] Accept HoG Report Map longer than 512 octets
@ 2026-11-30 19:03 Sebastian
2026-11-30 19:03 ` [PATCH 1/2] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian
2026-11-30 19:03 ` [PATCH 2/2] shared/hog: Accept Report Map longer than 512 octets Sebastian
0 siblings, 2 replies; 4+ messages in thread
From: Sebastian @ 2026-11-30 19:03 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sebastian
Since 5.88, HID over GATT devices with a Report Map longer than 512
octets no longer work: the Report Map is truncated, the kernel fails to
parse it and no input device is created. Several keyboards and
touchpads are affected, see https://github.com/bluez/bluez/issues/2814.
Mine, an Inateck KB05113, sends 637 octets.
Commit 952c08ff50c5 ("hog-lib: Don't restrict Report MAP size") made
hog-lib accept Report Maps of any size, since other operating systems
don't enforce the 512 octet limit. The limit came back with commit
96f1201f5ac2 ("input/hog: Use shared/hog"), as bt_gatt_client long
reads truncate to BT_ATT_MAX_VALUE_LEN.
Patch 1 adds an opt-in variant of bt_gatt_client_read_long_value with a
caller-chosen maximum length; the existing function keeps the 512 octet
limit. Patch 2 uses it for the Report Map only, up to the 4096 octets
UHID_CREATE2 accepts.
Raising the limit for the Report Map makes the Inateck KB05113 work
again: keyboard, mouse and touchpad input devices are created. All unit
tests pass.
Sebastian (2):
shared/gatt-client: Add bt_gatt_client_read_long_value_max_len
shared/hog: Accept Report Map longer than 512 octets
src/shared/gatt-client.c | 40 ++++++++++++++++++++++++++++++++++++----
src/shared/gatt-client.h | 7 +++++++
src/shared/hog.c | 24 ++++++++++++++++++++----
3 files changed, 63 insertions(+), 8 deletions(-)
--
2.56.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/2] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len 2026-11-30 19:03 [PATCH 0/2] Accept HoG Report Map longer than 512 octets Sebastian @ 2026-11-30 19:03 ` Sebastian 2026-11-30 19:03 ` [PATCH 2/2] shared/hog: Accept Report Map longer than 512 octets Sebastian 1 sibling, 0 replies; 4+ messages in thread From: Sebastian @ 2026-11-30 19:03 UTC (permalink / raw) To: linux-bluetooth; +Cc: Sebastian, Claude Opus 5.5 Long reads are truncated to BT_ATT_MAX_VALUE_LEN (512 octets), the maximum length of an attribute value. Some non-compliant peripherals expose longer values that other stacks read in full, so add a variant of bt_gatt_client_read_long_value that lets the caller pick the maximum length to accept. bt_gatt_client_read_long_value keeps truncating to BT_ATT_MAX_VALUE_LEN. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- src/shared/gatt-client.c | 40 ++++++++++++++++++++++++++++++++++++---- src/shared/gatt-client.h | 7 +++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index 31982bd29..f9806b0e3 100644 --- a/src/shared/gatt-client.c +++ b/src/shared/gatt-client.c @@ -3064,6 +3064,7 @@ struct read_long_op { int ref_count; uint16_t value_handle; uint16_t offset; + uint16_t max_len; struct iovec iov; bt_gatt_client_read_callback_t callback; void *user_data; @@ -3085,8 +3086,8 @@ static bool append_chunk(struct read_long_op *op, const uint8_t *data, uint16_t len) { /* Truncate if the data would exceed maximum length */ - if (op->offset + len > BT_ATT_MAX_VALUE_LEN) - len = BT_ATT_MAX_VALUE_LEN - op->offset; + if (op->offset + len > op->max_len) + len = op->max_len - op->offset; if (!util_iov_append(&op->iov, data, len)) return false; @@ -3125,7 +3126,7 @@ static void read_long_cb(uint8_t opcode, const void *pdu, goto done; } - if (op->offset >= BT_ATT_MAX_VALUE_LEN) + if (op->offset >= op->max_len) goto success; if (length >= bt_att_get_mtu(op->client->att) - 1) { @@ -3160,8 +3161,9 @@ done: op->iov.iov_len, op->user_data); } -unsigned int bt_gatt_client_read_long_value(struct bt_gatt_client *client, +static unsigned int read_long_value(struct bt_gatt_client *client, uint16_t value_handle, uint16_t offset, + uint16_t max_len, bt_gatt_client_read_callback_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy) @@ -3186,6 +3188,7 @@ unsigned int bt_gatt_client_read_long_value(struct bt_gatt_client *client, op->client = client; op->value_handle = value_handle; op->offset = offset; + op->max_len = max_len; op->callback = callback; op->user_data = user_data; op->destroy = destroy; @@ -3227,6 +3230,35 @@ unsigned int bt_gatt_client_read_long_value(struct bt_gatt_client *client, return req->id; } +unsigned int bt_gatt_client_read_long_value(struct bt_gatt_client *client, + uint16_t value_handle, uint16_t offset, + bt_gatt_client_read_callback_t callback, + void *user_data, + bt_gatt_client_destroy_func_t destroy) +{ + return read_long_value(client, value_handle, offset, + BT_ATT_MAX_VALUE_LEN, callback, + user_data, destroy); +} + +/* + * Same as bt_gatt_client_read_long_value but allows the caller to accept + * values longer than the 512 octets permitted by the specification + * (Core v5.4, Vol 3, Part F, Section 3.2.9), as sent by some non-compliant + * peripherals. Reading stops once max_len octets have been received. + */ +unsigned int bt_gatt_client_read_long_value_max_len( + struct bt_gatt_client *client, + uint16_t value_handle, uint16_t offset, + uint16_t max_len, + bt_gatt_client_read_callback_t callback, + void *user_data, + bt_gatt_client_destroy_func_t destroy) +{ + return read_long_value(client, value_handle, offset, max_len, + callback, user_data, destroy); +} + unsigned int bt_gatt_client_write_without_response( struct bt_gatt_client *client, uint16_t value_handle, diff --git a/src/shared/gatt-client.h b/src/shared/gatt-client.h index 0c5d118c7..65266e11a 100644 --- a/src/shared/gatt-client.h +++ b/src/shared/gatt-client.h @@ -80,6 +80,13 @@ unsigned int bt_gatt_client_read_long_value(struct bt_gatt_client *client, bt_gatt_client_read_callback_t callback, void *user_data, bt_gatt_client_destroy_func_t destroy); +unsigned int bt_gatt_client_read_long_value_max_len( + struct bt_gatt_client *client, + uint16_t value_handle, uint16_t offset, + uint16_t max_len, + bt_gatt_client_read_callback_t callback, + void *user_data, + bt_gatt_client_destroy_func_t destroy); unsigned int bt_gatt_client_read_multiple(struct bt_gatt_client *client, uint16_t *handles, uint8_t num_handles, bt_gatt_client_read_callback_t callback, -- 2.56.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] shared/hog: Accept Report Map longer than 512 octets 2026-11-30 19:03 [PATCH 0/2] Accept HoG Report Map longer than 512 octets Sebastian 2026-11-30 19:03 ` [PATCH 1/2] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian @ 2026-11-30 19:03 ` Sebastian 2026-11-30 19:32 ` Luiz Augusto von Dentz 1 sibling, 1 reply; 4+ messages in thread From: Sebastian @ 2026-11-30 19:03 UTC (permalink / raw) To: linux-bluetooth; +Cc: Sebastian, Claude Opus 5.5 Some HID over GATT devices expose a Report Map longer than 512 octets, such as the Inateck KB05113 keyboard with touchpad (3373:7713), which sends 637 octets. Since 5.88 it is truncated when read, the kernel then fails to parse it and no input device is created: hid-generic 0005:3373:7713.0005: item fetching failed at offset 509/512 hid-generic 0005:3373:7713.0005: probe with driver hid-generic failed Other Inateck keyboards, the HP 720 keyboard and the Sanwa MA-PB521GM touchpad, with Report Maps of 612 to 902 octets, are reported to fail the same way. This is a regression: commit 952c08ff50c5 ("hog-lib: Don't restrict Report MAP size") made hog-lib read Report Maps of any size, since other operating systems don't enforce the limit and many devices exceed it. Since commit 96f1201f5ac2 ("input/hog: Use shared/hog") the Report Map is read with bt_gatt_client_read_value, which truncates to BT_ATT_MAX_VALUE_LEN. Read it with bt_gatt_client_read_long_value_max_len up to 4096 octets, the size of HID descriptor UHID_CREATE2 accepts, which makes the keyboard and touchpad work again. Fixes: 96f1201f5ac2 ("input/hog: Use shared/hog") Fixes: https://github.com/bluez/bluez/issues/2814 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --- src/shared/hog.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/shared/hog.c b/src/shared/hog.c index e62423fa4..be57399f7 100644 --- a/src/shared/hog.c +++ b/src/shared/hog.c @@ -56,6 +56,12 @@ #define HOG_PROTO_MODE_BOOT 0 #define HOG_PROTO_MODE_REPORT 1 +/* Some peripherals expose a Report Map longer than the 512 octets an + * attribute value may have (Core v5.4, Vol 3, Part F, Section 3.2.9). + * Accept up to the size of HID descriptor UHID_CREATE2 can take. + */ +#define HOG_REPORT_MAP_MAX_LEN 4096 + #define HOG_INFO_FLAG_SCI_SUPPORTED 0x04 #define HOG_INFO_FLAG_SCI_LOW_POWER 0x08 @@ -151,7 +157,8 @@ static void db_value_cb(struct gatt_db_attribute *attr, int err, * The requests are cancelled by cancelling all the requests of the client, * which is a clone owned by hog, once detached. */ -static void read_char(struct bt_hog *hog, uint16_t handle, bool cache, +static void read_char_max_len(struct bt_hog *hog, uint16_t handle, + bool cache, uint16_t max_len, bt_gatt_client_read_callback_t func, void *data) { if (cache) { @@ -169,11 +176,18 @@ static void read_char(struct bt_hog *hog, uint16_t handle, bool cache, } } - if (!bt_gatt_client_read_value(hog->client, handle, func, data, - NULL)) + if (!bt_gatt_client_read_long_value_max_len(hog->client, handle, 0, + max_len, func, data, NULL)) DBG(hog, "Could not read handle 0x%04x", handle); } +static void read_char(struct bt_hog *hog, uint16_t handle, bool cache, + bt_gatt_client_read_callback_t func, void *data) +{ + read_char_max_len(hog, handle, cache, BT_ATT_MAX_VALUE_LEN, func, + data); +} + /* Cache a static value in the gatt_db, see read_char */ static void cache_value(struct bt_hog *hog, uint16_t handle, const uint8_t *value, uint16_t length) @@ -1103,7 +1117,9 @@ static void foreach_hog_chrc(struct gatt_db_attribute *attr, void *user_data) * handled by reading it with Read Blob, unless cached. */ hog->report_map_handle = value_handle; - read_char(hog, value_handle, true, report_map_read_cb, hog); + read_char_max_len(hog, value_handle, true, + HOG_REPORT_MAP_MAX_LEN, + report_map_read_cb, hog); gatt_db_service_foreach_desc(attr, foreach_hog_external, hog); return; -- 2.56.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] shared/hog: Accept Report Map longer than 512 octets 2026-11-30 19:03 ` [PATCH 2/2] shared/hog: Accept Report Map longer than 512 octets Sebastian @ 2026-11-30 19:32 ` Luiz Augusto von Dentz 0 siblings, 0 replies; 4+ messages in thread From: Luiz Augusto von Dentz @ 2026-11-30 19:32 UTC (permalink / raw) To: Sebastian; +Cc: linux-bluetooth, Claude Opus 5.5 Hi Sebastian, On Mon, Nov 30, 2026 at 2:05 PM Sebastian <seb.witt@googlemail.com> wrote: > > Some HID over GATT devices expose a Report Map longer than 512 octets, > such as the Inateck KB05113 keyboard with touchpad (3373:7713), which > sends 637 octets. Since 5.88 it is truncated when read, the kernel then > fails to parse it and no input device is created: Sounds like a non-compliant device. > hid-generic 0005:3373:7713.0005: item fetching failed at offset 509/512 > hid-generic 0005:3373:7713.0005: probe with driver hid-generic failed > > Other Inateck keyboards, the HP 720 keyboard and the Sanwa MA-PB521GM > touchpad, with Report Maps of 612 to 902 octets, are reported to fail > the same way. > > This is a regression: commit 952c08ff50c5 ("hog-lib: Don't restrict > Report MAP size") made hog-lib read Report Maps of any size, since other > operating systems don't enforce the limit and many devices exceed it. > Since commit 96f1201f5ac2 ("input/hog: Use shared/hog") the Report Map > is read with bt_gatt_client_read_value, which truncates to > BT_ATT_MAX_VALUE_LEN. Yeah that used to be acceptable because it used the legacy GATT library. The new one attempts to enforce the limit since it may be subject to qualification. While this might be fine to keep it HoG only the problem is if the BT-SIG decides at any point that HoG qualification itself must check that the size doesn't surpass 512 octets, then this will start to fail and we will be back to having to disallow this. The HoG spec even has the following line: 'Multiple service instances of the HID Service may be supported to allow implementers to define composite HID Devices whose combined functions require more than 512 octets of data to describe.' https://www.bluetooth.com/specifications/specs/html/?src=hogp_v1-2_1777405843/HOGP_v1.2/out/en/index-en.html The problem is that no HoG test spec enforces this; only the GATT test spec has a 512-byte limit. Now the question is whether to report them as non-compliant or just keep working around and pray nobody files a complaint about these devices? If someone pursues qualification, they might test that we don't read past 512 bytes on HoG attributes which will backfire on us if we apply these changes. > Read it with bt_gatt_client_read_long_value_max_len up to 4096 octets, > the size of HID descriptor UHID_CREATE2 accepts, which makes the > keyboard and touchpad work again. > > Fixes: 96f1201f5ac2 ("input/hog: Use shared/hog") > Fixes: https://github.com/bluez/bluez/issues/2814 > Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> > --- > src/shared/hog.c | 24 ++++++++++++++++++++---- > 1 file changed, 20 insertions(+), 4 deletions(-) > > diff --git a/src/shared/hog.c b/src/shared/hog.c > index e62423fa4..be57399f7 100644 > --- a/src/shared/hog.c > +++ b/src/shared/hog.c > @@ -56,6 +56,12 @@ > #define HOG_PROTO_MODE_BOOT 0 > #define HOG_PROTO_MODE_REPORT 1 > > +/* Some peripherals expose a Report Map longer than the 512 octets an > + * attribute value may have (Core v5.4, Vol 3, Part F, Section 3.2.9). > + * Accept up to the size of HID descriptor UHID_CREATE2 can take. > + */ > +#define HOG_REPORT_MAP_MAX_LEN 4096 > + > #define HOG_INFO_FLAG_SCI_SUPPORTED 0x04 > #define HOG_INFO_FLAG_SCI_LOW_POWER 0x08 > > @@ -151,7 +157,8 @@ static void db_value_cb(struct gatt_db_attribute *attr, int err, > * The requests are cancelled by cancelling all the requests of the client, > * which is a clone owned by hog, once detached. > */ > -static void read_char(struct bt_hog *hog, uint16_t handle, bool cache, > +static void read_char_max_len(struct bt_hog *hog, uint16_t handle, > + bool cache, uint16_t max_len, > bt_gatt_client_read_callback_t func, void *data) > { > if (cache) { > @@ -169,11 +176,18 @@ static void read_char(struct bt_hog *hog, uint16_t handle, bool cache, > } > } > > - if (!bt_gatt_client_read_value(hog->client, handle, func, data, > - NULL)) > + if (!bt_gatt_client_read_long_value_max_len(hog->client, handle, 0, > + max_len, func, data, NULL)) > DBG(hog, "Could not read handle 0x%04x", handle); > } > > +static void read_char(struct bt_hog *hog, uint16_t handle, bool cache, > + bt_gatt_client_read_callback_t func, void *data) > +{ > + read_char_max_len(hog, handle, cache, BT_ATT_MAX_VALUE_LEN, func, > + data); > +} > + > /* Cache a static value in the gatt_db, see read_char */ > static void cache_value(struct bt_hog *hog, uint16_t handle, > const uint8_t *value, uint16_t length) > @@ -1103,7 +1117,9 @@ static void foreach_hog_chrc(struct gatt_db_attribute *attr, void *user_data) > * handled by reading it with Read Blob, unless cached. > */ > hog->report_map_handle = value_handle; > - read_char(hog, value_handle, true, report_map_read_cb, hog); > + read_char_max_len(hog, value_handle, true, > + HOG_REPORT_MAP_MAX_LEN, > + report_map_read_cb, hog); > > gatt_db_service_foreach_desc(attr, foreach_hog_external, hog); > return; > -- > 2.56.1 > > -- Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-30 19:32 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-30 19:03 [PATCH 0/2] Accept HoG Report Map longer than 512 octets Sebastian 2026-11-30 19:03 ` [PATCH 1/2] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian 2026-11-30 19:03 ` [PATCH 2/2] shared/hog: Accept Report Map longer than 512 octets Sebastian 2026-11-30 19:32 ` Luiz Augusto von Dentz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox