Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/20221121104403.1545f9b5@gandalf.local.home/
Suggested-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20221206145936.922196-3-benjamin.tissoires@redhat.com

+18 -3
+18 -2
drivers/hid/bpf/hid_bpf_dispatch.c
··· 44 44 { 45 45 return 0; 46 46 } 47 - ALLOW_ERROR_INJECTION(hid_bpf_device_event, ERRNO); 48 47 49 48 u8 * 50 49 dispatch_hid_bpf_device_event(struct hid_device *hdev, enum hid_report_type type, u8 *data, ··· 104 105 { 105 106 return 0; 106 107 } 107 - ALLOW_ERROR_INJECTION(hid_bpf_rdesc_fixup, ERRNO); 108 108 109 109 u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *size) 110 110 { ··· 427 429 return ret; 428 430 } 429 431 432 + /* our HID-BPF entrypoints */ 433 + BTF_SET8_START(hid_bpf_fmodret_ids) 434 + BTF_ID_FLAGS(func, hid_bpf_device_event) 435 + BTF_ID_FLAGS(func, hid_bpf_rdesc_fixup) 436 + BTF_ID_FLAGS(func, __hid_bpf_tail_call) 437 + BTF_SET8_END(hid_bpf_fmodret_ids) 438 + 439 + static const struct btf_kfunc_id_set hid_bpf_fmodret_set = { 440 + .owner = THIS_MODULE, 441 + .set = &hid_bpf_fmodret_ids, 442 + }; 443 + 430 444 /* for syscall HID-BPF */ 431 445 BTF_SET8_START(hid_bpf_syscall_kfunc_ids) 432 446 BTF_ID_FLAGS(func, hid_bpf_attach_prog) ··· 504 494 * This is not a big deal: the syscall allowing to attach a BPF program to a HID device 505 495 * will not be available, so nobody will be able to use the functionality. 506 496 */ 497 + 498 + err = register_btf_fmodret_id_set(&hid_bpf_fmodret_set); 499 + if (err) { 500 + pr_warn("error while registering fmodret entrypoints: %d", err); 501 + return 0; 502 + } 507 503 508 504 err = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &hid_bpf_kfunc_set); 509 505 if (err) {
-1
drivers/hid/bpf/hid_bpf_jmp_table.c
··· 103 103 { 104 104 return 0; 105 105 } 106 - ALLOW_ERROR_INJECTION(__hid_bpf_tail_call, ERRNO); 107 106 108 107 int hid_bpf_prog_run(struct hid_device *hdev, enum hid_bpf_prog_type type, 109 108 struct hid_bpf_ctx_kern *ctx_kern)