Skip to content

Commit

Permalink
HID: bpf: fix cfi stubs for hid_bpf_ops
Browse files Browse the repository at this point in the history
commit acd5f76 upstream.

With the introduction of commit e42ac14 ("bpf: Check unsupported ops
from the bpf_struct_ops's cfi_stubs"), a HID-BPF struct_ops containing
a .hid_hw_request() or a .hid_hw_output_report() was failing to load
as the cfi stubs were not defined.

Fix that by defining those simple static functions and restore HID-BPF
functionality.

This was detected with the HID selftests suddenly failing on Linus' tree.

Cc: stable@vger.kernel.org # v6.11+
Fixes: 9286675 ("HID: bpf: add HID-BPF hooks for hid_hw_output_report")
Fixes: 8bd0488 ("HID: bpf: add HID-BPF hooks for hid_hw_raw_requests")
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Benjamin Tissoires authored and gregkh committed Oct 10, 2024
1 parent a79fe32 commit fe80f7e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions drivers/hid/bpf/hid_bpf_struct_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,23 @@ static int __hid_bpf_rdesc_fixup(struct hid_bpf_ctx *ctx)
return 0;
}

static int __hid_bpf_hw_request(struct hid_bpf_ctx *ctx, unsigned char reportnum,
enum hid_report_type rtype, enum hid_class_request reqtype,
u64 source)
{
return 0;
}

static int __hid_bpf_hw_output_report(struct hid_bpf_ctx *ctx, u64 source)
{
return 0;
}

static struct hid_bpf_ops __bpf_hid_bpf_ops = {
.hid_device_event = __hid_bpf_device_event,
.hid_rdesc_fixup = __hid_bpf_rdesc_fixup,
.hid_hw_request = __hid_bpf_hw_request,
.hid_hw_output_report = __hid_bpf_hw_output_report,
};

static struct bpf_struct_ops bpf_hid_bpf_ops = {
Expand Down

0 comments on commit fe80f7e

Please sign in to comment.