* [PATCH v2 0/4] Accept HoG Report Map longer than 512 octets
[not found] <CABBYNZ+GNO-eVNC5B_4SqCdHOE+OHmXUaW0NwStd_BsbUzx35A@mail.gmail.com>
@ 2026-11-30 20:45 ` Sebastian
2026-11-30 20:45 ` [PATCH v2 1/4] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Sebastian @ 2026-11-30 20:45 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.
As discussed, accepting them is now controlled by a LongReportMap
option in a new [Input] section of main.conf, enabled by default and
disabled when Testing is, so the limit is enforced for qualification.
shared/hog itself keeps reading at most 512 octets unless told
otherwise with bt_hog_set_long_report_map.
The default depends on Testing as set from main.conf or with -T, as
parse_input runs after both; without any main.conf the option keeps
its default of true.
I took [Input] to mean a new section of main.conf, like [AVRCP], rather
than one in input.conf; I can move it there if you prefer.
v2:
- Add the LongReportMap option to [Input] in main.conf
- Keep the 512 octet limit by default in shared/hog, add
bt_hog_set_long_report_map
- Rebase on master
Sebastian (4):
shared/gatt-client: Add bt_gatt_client_read_long_value_max_len
main.conf: Add LongReportMap option to [Input]
shared/hog: Add bt_hog_set_long_report_map
input/hog: Accept Report Map longer than 512 octets
profiles/input/hog.c | 8 ++++++--
src/btd.h | 5 +++++
src/main.c | 20 +++++++++++++++++++
src/main.conf | 7 +++++++
src/shared/gatt-client.c | 40 +++++++++++++++++++++++++++++++++----
src/shared/gatt-client.h | 7 +++++++
src/shared/hog.c | 43 ++++++++++++++++++++++++++++++++++++----
src/shared/hog.h | 5 +++++
8 files changed, 125 insertions(+), 10 deletions(-)
--
2.56.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/4] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len
2026-11-30 20:45 ` [PATCH v2 0/4] Accept HoG Report Map longer than 512 octets Sebastian
@ 2026-11-30 20:45 ` Sebastian
2026-11-30 20:45 ` [PATCH v2 2/4] main.conf: Add LongReportMap option to [Input] Sebastian
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Sebastian @ 2026-11-30 20:45 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] 5+ messages in thread
* [PATCH v2 2/4] main.conf: Add LongReportMap option to [Input]
2026-11-30 20:45 ` [PATCH v2 0/4] Accept HoG Report Map longer than 512 octets Sebastian
2026-11-30 20:45 ` [PATCH v2 1/4] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian
@ 2026-11-30 20:45 ` Sebastian
2026-11-30 20:45 ` [PATCH v2 3/4] shared/hog: Add bt_hog_set_long_report_map Sebastian
2026-11-30 20:45 ` [PATCH v2 4/4] input/hog: Accept Report Map longer than 512 octets Sebastian
3 siblings, 0 replies; 5+ messages in thread
From: Sebastian @ 2026-11-30 20:45 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sebastian, Claude Opus 5.5
Add an option to accept HID over GATT Report Maps longer than the 512
octets an attribute value may have, as exposed by some non-compliant
devices. It defaults to true, as other operating systems accept them,
or to false when Testing is enabled so the limit is enforced for
qualification.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---
src/btd.h | 5 +++++
src/main.c | 20 ++++++++++++++++++++
src/main.conf | 7 +++++++
3 files changed, 32 insertions(+)
diff --git a/src/btd.h b/src/btd.h
index 9bf310271..378c567c3 100644
--- a/src/btd.h
+++ b/src/btd.h
@@ -126,6 +126,10 @@ struct btd_avrcp_opts {
bool volume_category;
};
+struct btd_input_opts {
+ bool long_report_map;
+};
+
struct btd_advmon_opts {
uint8_t rssi_sampling_period;
};
@@ -172,6 +176,7 @@ struct btd_opts {
struct btd_avdtp_opts avdtp;
struct btd_avrcp_opts avrcp;
+ struct btd_input_opts input;
uint8_t key_size;
diff --git a/src/main.c b/src/main.c
index 3a051c5a4..888fe42f6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -185,6 +185,11 @@ static const char *avrcp_options[] = {
NULL
};
+static const char *input_options[] = {
+ "LongReportMap",
+ NULL
+};
+
static const char *advmon_options[] = {
"RSSISamplingPeriod",
NULL
@@ -210,6 +215,7 @@ static const struct group_table {
{ "CSIS", csip_options },
{ "AVDTP", avdtp_options },
{ "AVRCP", avrcp_options },
+ { "Input", input_options },
{ "ChannelSounding", bcs_options },
{ "AdvMon", advmon_options },
{ "HDT", hdt_options },
@@ -1400,6 +1406,17 @@ static void parse_avrcp(GKeyFile *config)
&btd_opts.avrcp.volume_category);
}
+static void parse_input(GKeyFile *config)
+{
+ /* Cap the Report Map to 512 octets by default when testing, e.g.
+ * for qualification.
+ */
+ btd_opts.input.long_report_map = !btd_opts.testing;
+
+ parse_config_bool(config, "Input", "LongReportMap",
+ &btd_opts.input.long_report_map);
+}
+
static void parse_advmon(GKeyFile *config)
{
parse_config_u8(config, "AdvMon", "RSSISamplingPeriod",
@@ -1457,6 +1474,7 @@ static void parse_config(GKeyFile *config)
parse_csis(config);
parse_avdtp(config);
parse_avrcp(config);
+ parse_input(config);
parse_le_cs_config(config);
parse_advmon(config);
parse_hdt(config);
@@ -1514,6 +1532,8 @@ static void init_defaults(void)
btd_opts.avrcp.volume_without_target = false;
btd_opts.avrcp.volume_category = true;
+ btd_opts.input.long_report_map = true;
+
btd_opts.advmon.rssi_sampling_period = 0xFF;
btd_opts.csis.encrypt = true;
diff --git a/src/main.conf b/src/main.conf
index c9906148d..451a5281f 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -419,6 +419,13 @@
# notifications.
#VolumeCategory = true
+[Input]
+# Accept HID over GATT Report Maps longer than the 512 octets an attribute
+# value may have, as exposed by some non-compliant devices, which other
+# operating systems accept as well.
+# Defaults to true, or false when Testing is enabled.
+#LongReportMap = true
+
[Policy]
#
# The ReconnectUUIDs defines the set of remote services that should try
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/4] shared/hog: Add bt_hog_set_long_report_map
2026-11-30 20:45 ` [PATCH v2 0/4] Accept HoG Report Map longer than 512 octets Sebastian
2026-11-30 20:45 ` [PATCH v2 1/4] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian
2026-11-30 20:45 ` [PATCH v2 2/4] main.conf: Add LongReportMap option to [Input] Sebastian
@ 2026-11-30 20:45 ` Sebastian
2026-11-30 20:45 ` [PATCH v2 4/4] input/hog: Accept Report Map longer than 512 octets Sebastian
3 siblings, 0 replies; 5+ messages in thread
From: Sebastian @ 2026-11-30 20:45 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sebastian, Claude Opus 5.5
Add bt_hog_set_long_report_map to accept a Report Map longer than 512
octets, up to the 4096 octets of HID descriptor UHID_CREATE2 accepts,
by reading it with bt_gatt_client_read_long_value_max_len. It is
disabled by default, so the Report Map is read as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---
src/shared/hog.c | 43 +++++++++++++++++++++++++++++++++++++++----
src/shared/hog.h | 5 +++++
2 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/src/shared/hog.c b/src/shared/hog.c
index e62423fa4..1ef886e42 100644
--- a/src/shared/hog.c
+++ b/src/shared/hog.c
@@ -56,6 +56,13 @@
#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).
+ * When enabled, accept up to the size of HID descriptor UHID_CREATE2 can
+ * take.
+ */
+#define HOG_REPORT_MAP_LONG_MAX_LEN 4096
+
#define HOG_INFO_FLAG_SCI_SUPPORTED 0x04
#define HOG_INFO_FLAG_SCI_LOW_POWER 0x08
@@ -88,6 +95,7 @@ struct bt_hog {
uint16_t report_map_handle;
uint8_t *report_map;
uint16_t report_map_len;
+ uint16_t report_map_max_len;
uint16_t sci_mode_handle;
uint8_t sci_mode_props;
unsigned int sci_mode_id;
@@ -151,7 +159,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 +178,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 +1119,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;
@@ -1194,6 +1212,7 @@ static struct bt_hog *hog_new(int fd, const char *name, uint16_t vendor,
hog->version = version;
hog->type = type;
hog->attr = attr;
+ hog->report_map_max_len = BT_ATT_MAX_VALUE_LEN;
return hog;
}
@@ -1220,6 +1239,7 @@ static void foreach_hog_service(struct gatt_db_attribute *attr, void *user_data)
instance->debug_data = hog->debug_data;
instance->sci_mode_func = hog->sci_mode_func;
instance->sci_mode_data = hog->sci_mode_data;
+ instance->report_map_max_len = hog->report_map_max_len;
queue_push_tail(hog->instances, bt_hog_ref(instance));
}
@@ -1335,6 +1355,21 @@ void bt_hog_set_ids(struct bt_hog *hog, uint16_t vendor, uint16_t product,
bt_hog_set_ids(entry->data, vendor, product, version);
}
+void bt_hog_set_long_report_map(struct bt_hog *hog, bool enable)
+{
+ const struct queue_entry *entry;
+
+ if (!hog)
+ return;
+
+ hog->report_map_max_len = enable ? HOG_REPORT_MAP_LONG_MAX_LEN :
+ BT_ATT_MAX_VALUE_LEN;
+
+ for (entry = queue_get_entries(hog->instances); entry;
+ entry = entry->next)
+ bt_hog_set_long_report_map(entry->data, enable);
+}
+
static void discovery_idle(void *user_data)
{
struct bt_hog *hog = user_data;
diff --git a/src/shared/hog.h b/src/shared/hog.h
index 910a2261b..a4aa8a5d6 100644
--- a/src/shared/hog.h
+++ b/src/shared/hog.h
@@ -46,6 +46,11 @@ bool bt_hog_set_debug(struct bt_hog *hog, bt_hog_debug_func_t func,
void bt_hog_set_ids(struct bt_hog *hog, uint16_t vendor, uint16_t product,
uint16_t version);
+/* Accept a Report Map longer than the 512 octets an attribute value may
+ * have, as exposed by some non-compliant devices. Disabled by default.
+ */
+void bt_hog_set_long_report_map(struct bt_hog *hog, bool enable);
+
bool bt_hog_attach(struct bt_hog *hog, struct bt_gatt_client *client);
void bt_hog_detach(struct bt_hog *hog, bool force);
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 4/4] input/hog: Accept Report Map longer than 512 octets
2026-11-30 20:45 ` [PATCH v2 0/4] Accept HoG Report Map longer than 512 octets Sebastian
` (2 preceding siblings ...)
2026-11-30 20:45 ` [PATCH v2 3/4] shared/hog: Add bt_hog_set_long_report_map Sebastian
@ 2026-11-30 20:45 ` Sebastian
3 siblings, 0 replies; 5+ messages in thread
From: Sebastian @ 2026-11-30 20:45 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.
Accept them according to the LongReportMap option of [Input] in
main.conf, which is enabled unless Testing is.
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>
---
profiles/input/hog.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index 0f6224990..b7c293eee 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -29,6 +29,7 @@
#include "bluetooth/uuid.h"
#include "src/log.h"
+#include "src/btd.h"
#include "src/adapter.h"
#include "src/device.h"
#include "src/profile.h"
@@ -81,8 +82,11 @@ static void hog_device_accept(struct hog_device *dev, struct gatt_db *db)
product, version);
dev->hog = bt_hog_new_default(name, vendor, product, version, type, db);
- if (dev->hog)
- bt_hog_set_debug(dev->hog, hog_debug, NULL, NULL);
+ if (!dev->hog)
+ return;
+
+ bt_hog_set_debug(dev->hog, hog_debug, NULL, NULL);
+ bt_hog_set_long_report_map(dev->hog, btd_opts.input.long_report_map);
}
static struct hog_device *hog_device_new(struct btd_device *device)
--
2.56.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-30 20:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CABBYNZ+GNO-eVNC5B_4SqCdHOE+OHmXUaW0NwStd_BsbUzx35A@mail.gmail.com>
2026-11-30 20:45 ` [PATCH v2 0/4] Accept HoG Report Map longer than 512 octets Sebastian
2026-11-30 20:45 ` [PATCH v2 1/4] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian
2026-11-30 20:45 ` [PATCH v2 2/4] main.conf: Add LongReportMap option to [Input] Sebastian
2026-11-30 20:45 ` [PATCH v2 3/4] shared/hog: Add bt_hog_set_long_report_map Sebastian
2026-11-30 20:45 ` [PATCH v2 4/4] input/hog: Accept Report Map longer than 512 octets Sebastian
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox