[PATCH 0/3] HID: bpf: fix __hid_bpf_hw_check_params report length computation

Benjamin Tissoires posted 3 patches 3 weeks ago
drivers/hid/bpf/hid_bpf_dispatch.c       | 12 +++--
tools/testing/selftests/hid/hid_bpf.c    | 91 ++++++++++++++++++++++----------
tools/testing/selftests/hid/hid_common.h | 25 ++++++++-
tools/testing/selftests/hid/progs/hid.c  |  2 +-
4 files changed, 96 insertions(+), 34 deletions(-)
[PATCH 0/3] HID: bpf: fix __hid_bpf_hw_check_params report length computation
Posted by Benjamin Tissoires 3 weeks ago
While playing with hid_bpf_hw_output_report() on a device without report
IDs, I realized I wasn't able to send proper reports to the USB
endpoint.

This is because the __hid_bpf_hw_check_params() check wasn't taking into
account the report ID reserved space, and it was trimming down one
element in the report.

Of course, things are not simple, because sending an input report is not
taking this extra space into account, so we need to account for the type
of request as well.

Cheers,
Benjamin

Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
---
Benjamin Tissoires (3):
      selftests/hid: add define for commonly used buf size
      HID: bpf: fix __hid_bpf_hw_check_params report length
      selftests/hid: add unnumbered variant to the hid_bpf tests

 drivers/hid/bpf/hid_bpf_dispatch.c       | 12 +++--
 tools/testing/selftests/hid/hid_bpf.c    | 91 ++++++++++++++++++++++----------
 tools/testing/selftests/hid/hid_common.h | 25 ++++++++-
 tools/testing/selftests/hid/progs/hid.c  |  2 +-
 4 files changed, 96 insertions(+), 34 deletions(-)
---
base-commit: a93f3bf4e1d60777b1659b812c9e818cfc53b449
change-id: 20260904-wip-bpf-check_report-f490de16b864

Best regards,
--  
Benjamin Tissoires <bentiss@kernel.org>
Re: [PATCH 0/3] HID: bpf: fix __hid_bpf_hw_check_params report length computation
Posted by Benjamin Tissoires 1 week, 4 days ago
On Fri, 04 Sep 2026 14:52:58 +0200, Benjamin Tissoires wrote:
> While playing with hid_bpf_hw_output_report() on a device without report
> IDs, I realized I wasn't able to send proper reports to the USB
> endpoint.
> 
> This is because the __hid_bpf_hw_check_params() check wasn't taking into
> account the report ID reserved space, and it was trimming down one
> element in the report.
> 
> [...]

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git (for-7.3/upstream-fixes), thanks!

[1/3] selftests/hid: add define for commonly used buf size
      https://git.kernel.org/hid/hid/c/9d1e523b92d8
[2/3] HID: bpf: fix __hid_bpf_hw_check_params report length
      https://git.kernel.org/hid/hid/c/c4afa4862b87
[3/3] selftests/hid: add unnumbered variant to the hid_bpf tests
      https://git.kernel.org/hid/hid/c/b6f69097c827

Cheers,
-- 
Benjamin Tissoires <bentiss@kernel.org>