mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-18 03:23:53 -04:00
HID: bpf: allow to change the report descriptor
Add a new tracepoint hid_bpf_rdesc_fixup() so we can trigger a report descriptor fixup in the bpf world. Whenever the program gets attached/detached, the device is reconnected meaning that userspace will see it disappearing and reappearing with the new report descriptor. Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
This commit is contained in:
committed by
Jiri Kosina
parent
4f7153cf46
commit
ad190df11a
@@ -74,6 +74,7 @@ enum hid_bpf_attach_flags {
|
||||
|
||||
/* Following functions are tracepoints that BPF programs can attach to */
|
||||
int hid_bpf_device_event(struct hid_bpf_ctx *ctx);
|
||||
int hid_bpf_rdesc_fixup(struct hid_bpf_ctx *ctx);
|
||||
|
||||
/* Following functions are kfunc that we export to BPF programs */
|
||||
/* available everywhere in HID-BPF */
|
||||
@@ -100,6 +101,7 @@ int __hid_bpf_tail_call(struct hid_bpf_ctx *ctx);
|
||||
enum hid_bpf_prog_type {
|
||||
HID_BPF_PROG_TYPE_UNDEF = -1,
|
||||
HID_BPF_PROG_TYPE_DEVICE_EVENT, /* an event is emitted from the device */
|
||||
HID_BPF_PROG_TYPE_RDESC_FIXUP,
|
||||
HID_BPF_PROG_TYPE_MAX,
|
||||
};
|
||||
|
||||
@@ -143,6 +145,7 @@ int hid_bpf_connect_device(struct hid_device *hdev);
|
||||
void hid_bpf_disconnect_device(struct hid_device *hdev);
|
||||
void hid_bpf_destroy_device(struct hid_device *hid);
|
||||
void hid_bpf_device_init(struct hid_device *hid);
|
||||
u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *size);
|
||||
#else /* CONFIG_HID_BPF */
|
||||
static inline u8 *dispatch_hid_bpf_device_event(struct hid_device *hid, enum hid_report_type type,
|
||||
u8 *data, u32 *size, int interrupt) { return NULL; }
|
||||
@@ -150,6 +153,11 @@ static inline int hid_bpf_connect_device(struct hid_device *hdev) { return 0; }
|
||||
static inline void hid_bpf_disconnect_device(struct hid_device *hdev) {}
|
||||
static inline void hid_bpf_destroy_device(struct hid_device *hid) {}
|
||||
static inline void hid_bpf_device_init(struct hid_device *hid) {}
|
||||
static inline u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *size)
|
||||
{
|
||||
return kmemdup(rdesc, *size, GFP_KERNEL);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_HID_BPF */
|
||||
|
||||
#endif /* __HID_BPF_H */
|
||||
|
||||
Reference in New Issue
Block a user