mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-04-23 05:56:14 -04:00
HID: add source argument to HID low level functions
This allows to know who actually sent what when we process the request to the device. This will be useful for a BPF firewall program to allow or not requests coming from a dedicated hidraw node client. Link: https://patch.msgid.link/20240626-hid_hw_req_bpf-v2-2-cfd60fb6c79f@kernel.org Acked-by: Jiri Kosina <jkosina@suse.com> Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
This commit is contained in:
@@ -66,10 +66,12 @@ struct hid_ops {
|
||||
int (*hid_hw_raw_request)(struct hid_device *hdev,
|
||||
unsigned char reportnum, __u8 *buf,
|
||||
size_t len, enum hid_report_type rtype,
|
||||
enum hid_class_request reqtype);
|
||||
int (*hid_hw_output_report)(struct hid_device *hdev, __u8 *buf, size_t len);
|
||||
enum hid_class_request reqtype,
|
||||
__u64 source);
|
||||
int (*hid_hw_output_report)(struct hid_device *hdev, __u8 *buf, size_t len,
|
||||
__u64 source);
|
||||
int (*hid_input_report)(struct hid_device *hid, enum hid_report_type type,
|
||||
u8 *data, u32 size, int interrupt);
|
||||
u8 *data, u32 size, int interrupt, u64 source);
|
||||
struct module *owner;
|
||||
const struct bus_type *bus_type;
|
||||
};
|
||||
@@ -110,7 +112,8 @@ struct hid_bpf_ops {
|
||||
*
|
||||
* Context: Interrupt context.
|
||||
*/
|
||||
int (*hid_device_event)(struct hid_bpf_ctx *ctx, enum hid_report_type report_type);
|
||||
int (*hid_device_event)(struct hid_bpf_ctx *ctx, enum hid_report_type report_type,
|
||||
__u64 source);
|
||||
|
||||
/**
|
||||
* @hid_rdesc_fixup: called when the probe function parses the report descriptor
|
||||
@@ -146,7 +149,7 @@ struct hid_bpf {
|
||||
|
||||
#ifdef CONFIG_HID_BPF
|
||||
u8 *dispatch_hid_bpf_device_event(struct hid_device *hid, enum hid_report_type type, u8 *data,
|
||||
u32 *size, int interrupt);
|
||||
u32 *size, int interrupt, u64 source);
|
||||
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);
|
||||
@@ -154,7 +157,8 @@ 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 data; }
|
||||
u8 *data, u32 *size, int interrupt,
|
||||
u64 source) { return data; }
|
||||
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) {}
|
||||
|
||||
Reference in New Issue
Block a user