Skip to content

Commit 33c0fb8

Browse files
author
Benjamin Tissoires
committed
HID: bpf: make part of struct hid_device writable
It is useful to change the name, the phys and/or the uniq of a struct hid_device during .rdesc_fixup(). For example, hid-uclogic.ko changes the uniq to store the firmware version to differentiate between 2 devices sharing the same PID. In the same way, changing the device name is useful when the device export 3 nodes, all with the same name. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Benjamin Tissoires <[email protected]>
1 parent f1a5fb6 commit 33c0fb8

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

drivers/hid/bpf/hid_bpf_struct_ops.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ static int hid_bpf_ops_btf_struct_access(struct bpf_verifier_log *log,
7474

7575
const struct hid_bpf_offset_write_range write_ranges[] = {
7676
WRITE_RANGE(hid_bpf_ctx, retval, false),
77+
WRITE_RANGE(hid_device, name, true),
78+
WRITE_RANGE(hid_device, uniq, true),
79+
WRITE_RANGE(hid_device, phys, true),
7780
};
7881
#undef WRITE_RANGE
7982
const struct btf_type *state = NULL;

include/linux/hid_bpf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct hid_device;
4343
* ``hid`` and ``allocated_size`` are read-only, ``size`` and ``retval`` are read-write.
4444
*/
4545
struct hid_bpf_ctx {
46-
const struct hid_device *hid;
46+
struct hid_device *hid;
4747
__u32 allocated_size;
4848
union {
4949
__s32 retval;

0 commit comments

Comments
 (0)