Skip to content

Commit 8602015

Browse files
committed
HID: bpf: do not rely on ALLOW_ERROR_INJECTION
Now that we have aproper non debug API to declare which function is fmodret, we can rely on it. Link: https://lore.kernel.org/all/[email protected]/ Suggested-by: Alexei Starovoitov <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 55b5643 commit 8602015

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

drivers/hid/bpf/hid_bpf_dispatch.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ __weak noinline int hid_bpf_device_event(struct hid_bpf_ctx *ctx)
4444
{
4545
return 0;
4646
}
47-
ALLOW_ERROR_INJECTION(hid_bpf_device_event, ERRNO);
4847

4948
u8 *
5049
dispatch_hid_bpf_device_event(struct hid_device *hdev, enum hid_report_type type, u8 *data,
@@ -105,7 +104,6 @@ __weak noinline int hid_bpf_rdesc_fixup(struct hid_bpf_ctx *ctx)
105104
{
106105
return 0;
107106
}
108-
ALLOW_ERROR_INJECTION(hid_bpf_rdesc_fixup, ERRNO);
109107

110108
u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *size)
111109
{
@@ -429,6 +427,18 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
429427
return ret;
430428
}
431429

430+
/* our HID-BPF entrypoints */
431+
BTF_SET8_START(hid_bpf_fmodret_ids)
432+
BTF_ID_FLAGS(func, hid_bpf_device_event)
433+
BTF_ID_FLAGS(func, hid_bpf_rdesc_fixup)
434+
BTF_ID_FLAGS(func, __hid_bpf_tail_call)
435+
BTF_SET8_END(hid_bpf_fmodret_ids)
436+
437+
static const struct btf_kfunc_id_set hid_bpf_fmodret_set = {
438+
.owner = THIS_MODULE,
439+
.set = &hid_bpf_fmodret_ids,
440+
};
441+
432442
/* for syscall HID-BPF */
433443
BTF_SET8_START(hid_bpf_syscall_kfunc_ids)
434444
BTF_ID_FLAGS(func, hid_bpf_attach_prog)
@@ -495,6 +505,12 @@ static int __init hid_bpf_init(void)
495505
* will not be available, so nobody will be able to use the functionality.
496506
*/
497507

508+
err = register_btf_fmodret_id_set(&hid_bpf_fmodret_set);
509+
if (err) {
510+
pr_warn("error while registering fmodret entrypoints: %d", err);
511+
return 0;
512+
}
513+
498514
err = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &hid_bpf_kfunc_set);
499515
if (err) {
500516
pr_warn("error while setting HID BPF tracing kfuncs: %d", err);

drivers/hid/bpf/hid_bpf_jmp_table.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ __weak noinline int __hid_bpf_tail_call(struct hid_bpf_ctx *ctx)
103103
{
104104
return 0;
105105
}
106-
ALLOW_ERROR_INJECTION(__hid_bpf_tail_call, ERRNO);
107106

108107
int hid_bpf_prog_run(struct hid_device *hdev, enum hid_bpf_prog_type type,
109108
struct hid_bpf_ctx_kern *ctx_kern)

0 commit comments

Comments
 (0)