Linux bluetooth development
 help / color / mirror / Atom feed
From: Sebastian <seb.witt@googlemail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Sebastian <seb.witt@googlemail.com>,
	"Claude Opus 5.5" <noreply@anthropic.com>
Subject: [PATCH 2/2] shared/hog: Accept Report Map longer than 512 octets
Date: Mon, 30 Nov 2026 20:03:40 +0100	[thread overview]
Message-ID: <20261130190340.201189-3-seb.witt@googlemail.com> (raw)
In-Reply-To: <20261130190340.201189-1-seb.witt@googlemail.com>

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


  parent reply	other threads:[~2026-11-30 19:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2026-11-30 19:32   ` [PATCH 2/2] shared/hog: Accept Report Map longer than 512 octets Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130190340.201189-3-seb.witt@googlemail.com \
    --to=seb.witt@googlemail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=noreply@anthropic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox