* [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) 2026-12-03 15:34 ` [PATCH v3 0/6] Accept HoG " Sebastian 1 sibling, 4 replies; 14+ 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] 14+ 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-12-01 0:02 ` Accept HoG Report Map longer than 512 octets bluez.test.bot 2026-11-30 20:45 ` [PATCH v2 2/4] main.conf: Add LongReportMap option to [Input] Sebastian ` (2 subsequent siblings) 3 siblings, 1 reply; 14+ 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] 14+ messages in thread
* RE: Accept HoG Report Map longer than 512 octets 2026-11-30 20:45 ` [PATCH v2 1/4] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian @ 2026-12-01 0:02 ` bluez.test.bot 2026-12-02 16:13 ` Luiz Augusto von Dentz 0 siblings, 1 reply; 14+ messages in thread From: bluez.test.bot @ 2026-12-01 0:02 UTC (permalink / raw) To: linux-bluetooth, seb.witt [-- Attachment #1: Type: text/plain, Size: 5424 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/1227285/ ---Test result--- Test Summary: CheckPatch FAIL 1.38 seconds GitLint PASS 0.86 seconds BuildEll PASS 20.77 seconds BluezMake PASS 319.60 seconds MakeCheck PASS 1.07 seconds MakeDistcheck PASS 150.87 seconds CheckValgrind PASS 165.54 seconds CheckSmatch WARNING 316.48 seconds bluezmakeextell PASS 100.56 seconds TestFunctional PASS 1240.37 seconds IncrementalBuild PASS 362.10 seconds ScanBuild PASS 1209.33 seconds Details ############################## Test: CheckPatch - FAIL Desc: Run checkpatch.pl script Output: [v2,1/4] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len WARNING:BAD_SIGN_OFF: Non-standard signature: Co-Authored-By: #130: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> WARNING:BAD_SIGN_OFF: 'Co-authored-by:' is the preferred signature form #130: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> /home/runner/work/bluez/bluez/src/patch/15039102.patch total: 0 errors, 2 warnings, 90 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/15039102.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. [v2,2/4] main.conf: Add LongReportMap option to [Input] WARNING:BAD_SIGN_OFF: Non-standard signature: Co-Authored-By: #127: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> WARNING:BAD_SIGN_OFF: 'Co-authored-by:' is the preferred signature form #127: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const #165: FILE: src/main.c:188: +static const char *input_options[] = { /home/runner/work/bluez/bluez/src/patch/15039103.patch total: 0 errors, 3 warnings, 80 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/15039103.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. [v2,3/4] shared/hog: Add bt_hog_set_long_report_map WARNING:BAD_SIGN_OFF: Non-standard signature: Co-Authored-By: #125: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> WARNING:BAD_SIGN_OFF: 'Co-authored-by:' is the preferred signature form #125: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> /home/runner/work/bluez/bluez/src/patch/15039104.patch total: 0 errors, 2 warnings, 105 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/15039104.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. [v2,4/4] input/hog: Accept Report Map longer than 512 octets WARNING:COMMIT_LOG_USE_LINK: Unknown link reference 'Fixes:', use 'Link:' or 'Closes:' instead #144: Fixes: https://github.com/bluez/bluez/issues/2814 WARNING:BAD_SIGN_OFF: Non-standard signature: Co-Authored-By: #145: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> WARNING:BAD_SIGN_OFF: 'Co-authored-by:' is the preferred signature form #145: Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> /home/runner/work/bluez/bluez/src/patch/15039105.patch total: 0 errors, 3 warnings, 20 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/15039105.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: CheckSmatch - WARNING Desc: Run smatch tool with source Output: src/main.c: note: in included file (through src/device.h): https://github.com/bluez/bluez/pull/2952 --- Regards, Linux Bluetooth ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Accept HoG Report Map longer than 512 octets 2026-12-01 0:02 ` Accept HoG Report Map longer than 512 octets bluez.test.bot @ 2026-12-02 16:13 ` Luiz Augusto von Dentz 0 siblings, 0 replies; 14+ messages in thread From: Luiz Augusto von Dentz @ 2026-12-02 16:13 UTC (permalink / raw) To: linux-bluetooth; +Cc: seb.witt Hi Sebastian, On Mon, Nov 30, 2026 at 7:03 PM <bluez.test.bot@gmail.com> wrote: > > 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/1227285/ > > ---Test result--- > > Test Summary: > CheckPatch FAIL 1.38 seconds > GitLint PASS 0.86 seconds > BuildEll PASS 20.77 seconds > BluezMake PASS 319.60 seconds > MakeCheck PASS 1.07 seconds > MakeDistcheck PASS 150.87 seconds > CheckValgrind PASS 165.54 seconds > CheckSmatch WARNING 316.48 seconds > bluezmakeextell PASS 100.56 seconds > TestFunctional PASS 1240.37 seconds > IncrementalBuild PASS 362.10 seconds > ScanBuild PASS 1209.33 seconds > > Details > ############################## > Test: CheckPatch - FAIL > Desc: Run checkpatch.pl script > Output: > [v2,1/4] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len > WARNING:BAD_SIGN_OFF: Non-standard signature: Co-Authored-By: > #130: > Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> > > WARNING:BAD_SIGN_OFF: 'Co-authored-by:' is the preferred signature form > #130: > Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> > > /home/runner/work/bluez/bluez/src/patch/15039102.patch total: 0 errors, 2 warnings, 90 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/15039102.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. > > > [v2,2/4] main.conf: Add LongReportMap option to [Input] > WARNING:BAD_SIGN_OFF: Non-standard signature: Co-Authored-By: > #127: > Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> > > WARNING:BAD_SIGN_OFF: 'Co-authored-by:' is the preferred signature form > #127: > Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> > > WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const > #165: FILE: src/main.c:188: > +static const char *input_options[] = { > > /home/runner/work/bluez/bluez/src/patch/15039103.patch total: 0 errors, 3 warnings, 80 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/15039103.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. > > > [v2,3/4] shared/hog: Add bt_hog_set_long_report_map > WARNING:BAD_SIGN_OFF: Non-standard signature: Co-Authored-By: > #125: > Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> > > WARNING:BAD_SIGN_OFF: 'Co-authored-by:' is the preferred signature form > #125: > Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> > > /home/runner/work/bluez/bluez/src/patch/15039104.patch total: 0 errors, 2 warnings, 105 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/15039104.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. > > > [v2,4/4] input/hog: Accept Report Map longer than 512 octets > WARNING:COMMIT_LOG_USE_LINK: Unknown link reference 'Fixes:', use 'Link:' or 'Closes:' instead > #144: > Fixes: https://github.com/bluez/bluez/issues/2814 > > WARNING:BAD_SIGN_OFF: Non-standard signature: Co-Authored-By: > #145: > Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> > > WARNING:BAD_SIGN_OFF: 'Co-authored-by:' is the preferred signature form > #145: > Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> > > /home/runner/work/bluez/bluez/src/patch/15039105.patch total: 0 errors, 3 warnings, 20 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/15039105.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: CheckSmatch - WARNING > Desc: Run smatch tool with source > Output: > src/main.c: note: in included file (through src/device.h): > > > https://github.com/bluez/bluez/pull/2952 Copilot flagged a couple of problems: https://github.com/bluez/bluez/pull/2952#pullrequestreview-6134624147 > --- > Regards, > Linux Bluetooth > -- Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 14+ 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; 14+ 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] 14+ 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; 14+ 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] 14+ 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; 14+ 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] 14+ messages in thread
* [PATCH v3 0/6] Accept HoG Report Map longer than 512 octets [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-12-03 15:34 ` Sebastian 2026-12-03 15:34 ` [PATCH v3 1/6] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian ` (5 more replies) 1 sibling, 6 replies; 14+ messages in thread From: Sebastian @ 2026-12-03 15:34 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, also when there is no main.conf. 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. This series was developed with the help of Claude, an AI assistant. 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 v3: - Refuse long reads starting beyond the maximum length, as the length appended would otherwise underflow - Apply the default depending on Testing without main.conf too - Add tests for long reads in unit/test-gatt and for long Report Maps in unit/test-hog - Use static const char * const for input_options - Use Closes: for the GitHub issue - Drop non-standard trailers flagged by checkpatch Sebastian (6): 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 unit/test-gatt: Add tests for long reads beyond 512 octets unit/test-hog: Add tests for long Report Map profiles/input/hog.c | 8 +++- src/btd.h | 5 +++ src/main.c | 26 ++++++++++- src/main.conf | 7 +++ src/shared/gatt-client.c | 46 +++++++++++++++++-- src/shared/gatt-client.h | 7 +++ src/shared/hog.c | 43 ++++++++++++++++-- src/shared/hog.h | 5 +++ unit/test-gatt.c | 96 ++++++++++++++++++++++++++++++++++++++++ unit/test-hog.c | 79 ++++++++++++++++++++++++++++++++- 10 files changed, 310 insertions(+), 12 deletions(-) -- 2.56.1 ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 1/6] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len 2026-12-03 15:34 ` [PATCH v3 0/6] Accept HoG " Sebastian @ 2026-12-03 15:34 ` Sebastian 2026-12-03 15:34 ` [PATCH v3 2/6] main.conf: Add LongReportMap option to [Input] Sebastian ` (4 subsequent siblings) 5 siblings, 0 replies; 14+ messages in thread From: Sebastian @ 2026-12-03 15:34 UTC (permalink / raw) To: linux-bluetooth; +Cc: Sebastian 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. Reads starting beyond the maximum length are refused, as the length of the data appended to the value would otherwise underflow in append_chunk, which also applies to bt_gatt_client_read_long_value. --- src/shared/gatt-client.c | 46 ++++++++++++++++++++++++++++++++++++---- src/shared/gatt-client.h | 7 ++++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c index 31982bd29..2870d5445 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) @@ -3175,6 +3177,12 @@ unsigned int bt_gatt_client_read_long_value(struct bt_gatt_client *client, if (!client) return 0; + /* Reading can't start beyond the maximum length of the value, the + * length of the data appended to it would otherwise underflow. + */ + if (offset > max_len) + return 0; + op = new0(struct read_long_op, 1); req = request_create(client); @@ -3186,6 +3194,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 +3236,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] 14+ messages in thread
* [PATCH v3 2/6] main.conf: Add LongReportMap option to [Input] 2026-12-03 15:34 ` [PATCH v3 0/6] Accept HoG " Sebastian 2026-12-03 15:34 ` [PATCH v3 1/6] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian @ 2026-12-03 15:34 ` Sebastian 2026-12-03 15:34 ` [PATCH v3 3/6] shared/hog: Add bt_hog_set_long_report_map Sebastian ` (3 subsequent siblings) 5 siblings, 0 replies; 14+ messages in thread From: Sebastian @ 2026-12-03 15:34 UTC (permalink / raw) To: linux-bluetooth; +Cc: Sebastian 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. --- src/btd.h | 5 +++++ src/main.c | 26 +++++++++++++++++++++++++- src/main.conf | 7 +++++++ 3 files changed, 37 insertions(+), 1 deletion(-) 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..8c7e5206f 100644 --- a/src/main.c +++ b/src/main.c @@ -185,6 +185,11 @@ static const char *avrcp_options[] = { NULL }; +static const char * const 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,18 @@ 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; + + if (config) + parse_config_bool(config, "Input", "LongReportMap", + &btd_opts.input.long_report_map); +} + static void parse_advmon(GKeyFile *config) { parse_config_u8(config, "AdvMon", "RSSISamplingPeriod", @@ -1442,8 +1460,11 @@ static void parse_hdt(GKeyFile *config) static void parse_config(GKeyFile *config) { - if (!config) + if (!config) { + /* Apply the defaults depending on Testing, set with -T */ + parse_input(NULL); return; + } check_config(config); @@ -1457,6 +1478,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 +1536,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] 14+ messages in thread
* [PATCH v3 3/6] shared/hog: Add bt_hog_set_long_report_map 2026-12-03 15:34 ` [PATCH v3 0/6] Accept HoG " Sebastian 2026-12-03 15:34 ` [PATCH v3 1/6] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian 2026-12-03 15:34 ` [PATCH v3 2/6] main.conf: Add LongReportMap option to [Input] Sebastian @ 2026-12-03 15:34 ` Sebastian 2026-12-03 15:34 ` [PATCH v3 4/6] input/hog: Accept Report Map longer than 512 octets Sebastian ` (2 subsequent siblings) 5 siblings, 0 replies; 14+ messages in thread From: Sebastian @ 2026-12-03 15:34 UTC (permalink / raw) To: linux-bluetooth; +Cc: Sebastian 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. --- 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] 14+ messages in thread
* [PATCH v3 4/6] input/hog: Accept Report Map longer than 512 octets 2026-12-03 15:34 ` [PATCH v3 0/6] Accept HoG " Sebastian ` (2 preceding siblings ...) 2026-12-03 15:34 ` [PATCH v3 3/6] shared/hog: Add bt_hog_set_long_report_map Sebastian @ 2026-12-03 15:34 ` Sebastian 2026-12-03 15:34 ` [PATCH v3 5/6] unit/test-gatt: Add tests for long reads beyond " Sebastian 2026-12-03 15:34 ` [PATCH v3 6/6] unit/test-hog: Add tests for long Report Map Sebastian 5 siblings, 0 replies; 14+ messages in thread From: Sebastian @ 2026-12-03 15:34 UTC (permalink / raw) To: linux-bluetooth; +Cc: Sebastian 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") Closes: https://github.com/bluez/bluez/issues/2814 --- 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] 14+ messages in thread
* [PATCH v3 5/6] unit/test-gatt: Add tests for long reads beyond 512 octets 2026-12-03 15:34 ` [PATCH v3 0/6] Accept HoG " Sebastian ` (3 preceding siblings ...) 2026-12-03 15:34 ` [PATCH v3 4/6] input/hog: Accept Report Map longer than 512 octets Sebastian @ 2026-12-03 15:34 ` Sebastian 2026-12-03 15:34 ` [PATCH v3 6/6] unit/test-hog: Add tests for long Report Map Sebastian 5 siblings, 0 replies; 14+ messages in thread From: Sebastian @ 2026-12-03 15:34 UTC (permalink / raw) To: linux-bluetooth; +Cc: Sebastian Check that a value longer than BT_ATT_MAX_VALUE_LEN is truncated by bt_gatt_client_read_long_value, read in full by bt_gatt_client_read_long_value_max_len and truncated to the maximum length given, and that reads starting beyond the maximum length are refused. --- unit/test-gatt.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/unit/test-gatt.c b/unit/test-gatt.c index 3a35ccbc1..70edf6c14 100644 --- a/unit/test-gatt.c +++ b/unit/test-gatt.c @@ -71,6 +71,13 @@ struct context { #define data(args...) ((const unsigned char[]) { args }) +#define array_pdu(array) \ + { \ + .valid = true, \ + .data = util_memdup(array, sizeof(array)), \ + .size = sizeof(array), \ + } + #define raw_pdu(args...) \ { \ .valid = true, \ @@ -373,6 +380,7 @@ struct test_step { uint16_t length; uint8_t features; bool init_fail; + uint16_t max_len; }; static void destroy_context(struct context *context) @@ -2496,6 +2504,66 @@ static const struct test_step test_long_read_8 = { .expected_att_ecode = 0x0c }; +/* A value longer than BT_ATT_MAX_VALUE_LEN, as exposed by some + * non-compliant devices, read with a Read Response and a Read Blob + * Response. + */ +static const uint8_t long_data_600[600] = { [0 ... 599] = 0xff }; +static const uint8_t long_read_rsp_600[512] = { + BT_ATT_OP_READ_RSP, [1 ... 511] = 0xff +}; +static const uint8_t long_read_blob_rsp_600[90] = { + BT_ATT_OP_READ_BLOB_RSP, [1 ... 89] = 0xff +}; + +static void test_long_read_max_len(struct context *context) +{ + const struct test_step *step = context->data->step; + + g_assert(bt_gatt_client_read_long_value_max_len(context->client, + step->handle, 0, step->max_len, + multiple_read_cb, context, + NULL)); +} + +static const struct test_step test_long_read_max_len_1 = { + .handle = 0x0003, + .func = test_long_read_max_len, + .max_len = 4096, + .value = long_data_600, + .length = sizeof(long_data_600) +}; + +static const struct test_step test_long_read_max_len_2 = { + .handle = 0x0003, + .func = test_long_read_max_len, + .max_len = 550, + .value = long_data_600, + .length = 550 +}; + +static void test_long_read_offset(struct context *context) +{ + const struct test_step *step = context->data->step; + + /* A read starting beyond the maximum length is refused without + * sending any request. + */ + g_assert(!bt_gatt_client_read_long_value(context->client, + step->handle, BT_ATT_MAX_VALUE_LEN + 1, + multiple_read_cb, context, NULL)); + g_assert(!bt_gatt_client_read_long_value_max_len(context->client, + step->handle, 101, 100, + multiple_read_cb, context, NULL)); + + context_quit(context); +} + +static const struct test_step test_long_read_offset_1 = { + .handle = 0x0003, + .func = test_long_read_offset, +}; + /* Descriptor test data's */ static const struct test_step test_long_read_9 = { @@ -3703,6 +3771,34 @@ int main(int argc, char *argv[]) raw_pdu(0x0a, 0x03, 0x00), raw_pdu(0x0b, 0x01, 0x02, 0x03)); + define_test_client("/robustness/read-long-512", test_client, + service_db_1, &test_long_read_2, + SERVICE_DATA_1_PDUS, + raw_pdu(0x0a, 0x03, 0x00), + array_pdu(long_read_rsp_600), + raw_pdu(0x0c, 0x03, 0x00, 0xff, 0x01), + array_pdu(long_read_blob_rsp_600)); + + define_test_client("/robustness/read-long-max-len", test_client, + service_db_1, &test_long_read_max_len_1, + SERVICE_DATA_1_PDUS, + raw_pdu(0x0a, 0x03, 0x00), + array_pdu(long_read_rsp_600), + raw_pdu(0x0c, 0x03, 0x00, 0xff, 0x01), + array_pdu(long_read_blob_rsp_600)); + + define_test_client("/robustness/read-long-max-len/truncated", + test_client, service_db_1, &test_long_read_max_len_2, + SERVICE_DATA_1_PDUS, + raw_pdu(0x0a, 0x03, 0x00), + array_pdu(long_read_rsp_600), + raw_pdu(0x0c, 0x03, 0x00, 0xff, 0x01), + array_pdu(long_read_blob_rsp_600)); + + define_test_client("/robustness/read-long-offset", test_client, + service_db_1, &test_long_read_offset_1, + SERVICE_DATA_1_PDUS); + define_test_client("/TP/GAR/CL/BI-17-C", test_client, service_db_1, &test_long_read_8, SERVICE_DATA_1_PDUS, -- 2.56.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v3 6/6] unit/test-hog: Add tests for long Report Map 2026-12-03 15:34 ` [PATCH v3 0/6] Accept HoG " Sebastian ` (4 preceding siblings ...) 2026-12-03 15:34 ` [PATCH v3 5/6] unit/test-gatt: Add tests for long reads beyond " Sebastian @ 2026-12-03 15:34 ` Sebastian 5 siblings, 0 replies; 14+ messages in thread From: Sebastian @ 2026-12-03 15:34 UTC (permalink / raw) To: linux-bluetooth; +Cc: Sebastian Check that a Report Map longer than 512 octets is read in full when bt_hog_set_long_report_map is enabled, and truncated to 512 octets otherwise. --- unit/test-hog.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) diff --git a/unit/test-hog.c b/unit/test-hog.c index 969e02f44..be6952984 100644 --- a/unit/test-hog.c +++ b/unit/test-hog.c @@ -99,6 +99,12 @@ struct test_config { uint8_t mode[2]; /* Number of HID SCI Mode notifications per mode */ unsigned int notifications; + /* Whether to accept a Report Map longer than 512 octets, and the + * length of the Report Map the uHID device is expected to be created + * with if not REPORT_MAP_LEN. + */ + bool long_report_map; + size_t report_map_len; /* uHID event expected after the action */ uint32_t uhid_type; const uint8_t *uhid_data; @@ -310,7 +316,9 @@ static bool uhid_read(struct io *io, void *user_data) g_assert_cmpint(ev.u.create2.product, ==, 0x0001); g_assert_cmpint(ev.u.create2.version, ==, 0x0001); g_assert_cmpint(ev.u.create2.bus, ==, BUS_BLUETOOTH); - g_assert_cmpint(ev.u.create2.rd_size, ==, REPORT_MAP_LEN); + g_assert_cmpint(ev.u.create2.rd_size, ==, + data->cfg->report_map_len ? + data->cfg->report_map_len : REPORT_MAP_LEN); uhid_send(data, UHID_START, 0); @@ -384,6 +392,7 @@ static void test_hog(const void *user_data) bt_hog_set_debug(data->hog, print_debug, "bt_hog: ", NULL); bt_hog_set_sci_mode_callback(data->hog, sci_mode_cb, data); + bt_hog_set_long_report_map(data->hog, data->cfg->long_report_map); g_assert(bt_hog_attach(data->hog, data->client)); } @@ -524,6 +533,56 @@ static void test_teardown(const void *user_data) IOV_DATA(0x0c, 0x05, 0x00, 0x3f, 0x00), \ IOV_DATA(0x0d, REPORT_MAP_2) +/* A Report Map of 600 octets, longer than the 512 octets an attribute + * value may have, read in chunks of HOG_GATT_CLIENT_MTU - 1 octets. + */ +#define IOV_ARRAY(array) \ + { .iov_base = (void *) array, .iov_len = sizeof(array) } + +static const uint8_t long_map_read_rsp[HOG_GATT_CLIENT_MTU] = { + 0x0b, [1 ... HOG_GATT_CLIENT_MTU - 1] = 0x01 +}; +static const uint8_t long_map_blob_rsp[HOG_GATT_CLIENT_MTU] = { + 0x0d, [1 ... HOG_GATT_CLIENT_MTU - 1] = 0x01 +}; +static const uint8_t long_map_last_blob_rsp[34] = { 0x0d, [1 ... 33] = 0x01 }; + +#define READ_LONG_MAP_BLOB(offset...) \ + IOV_DATA(0x0c, 0x05, 0x00, offset), \ + IOV_ARRAY(long_map_blob_rsp) + +/* Truncated to 512 octets, once 504 octets are read */ +#define READ_LONG_REPORT_MAP_512 \ + IOV_DATA(0x0a, 0x05, 0x00), \ + IOV_ARRAY(long_map_read_rsp), \ + READ_LONG_MAP_BLOB(0x3f, 0x00), \ + READ_LONG_MAP_BLOB(0x7e, 0x00), \ + READ_LONG_MAP_BLOB(0xbd, 0x00), \ + READ_LONG_MAP_BLOB(0xfc, 0x00), \ + READ_LONG_MAP_BLOB(0x3b, 0x01), \ + READ_LONG_MAP_BLOB(0x7a, 0x01), \ + READ_LONG_MAP_BLOB(0xb9, 0x01), \ + READ_LONG_MAP_BLOB(0xf8, 0x01) + +#define READ_LONG_REPORT_MAP_600 \ + READ_LONG_REPORT_MAP_512, \ + IOV_DATA(0x0c, 0x05, 0x00, 0x37, 0x02), \ + IOV_ARRAY(long_map_last_blob_rsp) + +#define LONG_MAP_ATTACH(read_report_map...) \ + READ_PROTO_MODE, \ + read_report_map, \ + READ_EXT_REPORT_REF, \ + READ_INFO, \ + READ_INPUT, \ + READ_INPUT_REF, \ + READ_OUTPUT, \ + READ_OUTPUT_REF, \ + READ_FEATURE, \ + READ_FEATURE_REF, \ + READ_INPUT_CCC, \ + ENABLE_INPUT_CCC + /* The uHID device is created once every request is complete */ #define ATTACH \ READ_PROTO_MODE, \ @@ -827,6 +886,19 @@ static const struct test_config cfg_attach = { .creates = 1, }; +static const struct test_config cfg_long_report_map = { + .action = ACT_NONE, + .creates = 1, + .long_report_map = true, + .report_map_len = 600, +}; + +static const struct test_config cfg_long_report_map_disabled = { + .action = ACT_NONE, + .creates = 1, + .report_map_len = 512, +}; + static const struct test_config cfg_multi_attach = { .action = ACT_NONE, .creates = 2, @@ -1104,6 +1176,11 @@ int main(int argc, char *argv[]) NOTIFY(0x0c, INPUT_REPORT)); /* Characteristic GGIT, the discovery being done by bt_gatt_client */ + define_test("/hog/long-report-map", setup_basic, &cfg_long_report_map, + LONG_MAP_ATTACH(READ_LONG_REPORT_MAP_600)); + define_test("/hog/long-report-map/disabled", setup_basic, + &cfg_long_report_map_disabled, + LONG_MAP_ATTACH(READ_LONG_REPORT_MAP_512)); define_test("HOGP/RH/CGGIT/CHA/BV-01-C [Characteristic GGIT - Report " "Map - RH]", setup_basic, &cfg_attach, -- 2.56.1 ^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-12-03 15:34 UTC | newest]
Thread overview: 14+ 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-12-01 0:02 ` Accept HoG Report Map longer than 512 octets bluez.test.bot
2026-12-02 16:13 ` Luiz Augusto von Dentz
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
2026-12-03 15:34 ` [PATCH v3 0/6] Accept HoG " Sebastian
2026-12-03 15:34 ` [PATCH v3 1/6] shared/gatt-client: Add bt_gatt_client_read_long_value_max_len Sebastian
2026-12-03 15:34 ` [PATCH v3 2/6] main.conf: Add LongReportMap option to [Input] Sebastian
2026-12-03 15:34 ` [PATCH v3 3/6] shared/hog: Add bt_hog_set_long_report_map Sebastian
2026-12-03 15:34 ` [PATCH v3 4/6] input/hog: Accept Report Map longer than 512 octets Sebastian
2026-12-03 15:34 ` [PATCH v3 5/6] unit/test-gatt: Add tests for long reads beyond " Sebastian
2026-12-03 15:34 ` [PATCH v3 6/6] unit/test-hog: Add tests for long Report Map Sebastian
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox