]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
HID: bpf: add HID-BPF hooks for hid_hw_raw_requests
authorBenjamin Tissoires <bentiss@kernel.org>
Wed, 26 Jun 2024 13:46:25 +0000 (15:46 +0200)
committerBenjamin Tissoires <bentiss@kernel.org>
Thu, 27 Jun 2024 09:00:07 +0000 (11:00 +0200)
commit8bd0488b5ea58655ad6fdcbe0408ef49b16882b1
tree490b7e0108d826a9711f6796881ac1ce5d350748
parent6cd735f0e57a6c8510ad92f5b63837a8d0cff3a7
HID: bpf: add HID-BPF hooks for hid_hw_raw_requests

This allows to intercept and prevent or change the behavior of
hid_hw_raw_request() from a bpf program.

The intent is to solve a couple of use case:
- firewalling a HID device: a firewall can monitor who opens the hidraw
  nodes and then prevent or allow access to write operations on that
  hidraw node.
- change the behavior of a device and emulate a new HID feature request

The hook is allowed to be run as sleepable so it can itself call
hid_bpf_hw_request(), which allows to "convert" one feature request into
another or even call the feature request on a different HID device on the
same physical device.

Link: https://patch.msgid.link/20240626-hid_hw_req_bpf-v2-4-cfd60fb6c79f@kernel.org
Acked-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
drivers/hid/bpf/hid_bpf_dispatch.c
drivers/hid/bpf/hid_bpf_struct_ops.c
drivers/hid/hid-core.c
include/linux/hid_bpf.h