]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
HID: bpf: do not rely on ALLOW_ERROR_INJECTION
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Tue, 6 Dec 2022 14:59:33 +0000 (15:59 +0100)
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>
Wed, 7 Dec 2022 14:41:36 +0000 (15:41 +0100)
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
drivers/hid/bpf/hid_bpf_dispatch.c
drivers/hid/bpf/hid_bpf_jmp_table.c

index c3920c7964dc981f21f58bce983d5c7f8ba5f856..58e608ebf0fa27e8d184d97af2644b21fd3d81af 100644 (file)
@@ -44,7 +44,6 @@ __weak noinline int hid_bpf_device_event(struct hid_bpf_ctx *ctx)
 {
        return 0;
 }
-ALLOW_ERROR_INJECTION(hid_bpf_device_event, ERRNO);
 
 u8 *
 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)
 {
        return 0;
 }
-ALLOW_ERROR_INJECTION(hid_bpf_rdesc_fixup, ERRNO);
 
 u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *size)
 {
@@ -429,6 +427,18 @@ hid_bpf_hw_request(struct hid_bpf_ctx *ctx, __u8 *buf, size_t buf__sz,
        return ret;
 }
 
+/* our HID-BPF entrypoints */
+BTF_SET8_START(hid_bpf_fmodret_ids)
+BTF_ID_FLAGS(func, hid_bpf_device_event)
+BTF_ID_FLAGS(func, hid_bpf_rdesc_fixup)
+BTF_ID_FLAGS(func, __hid_bpf_tail_call)
+BTF_SET8_END(hid_bpf_fmodret_ids)
+
+static const struct btf_kfunc_id_set hid_bpf_fmodret_set = {
+       .owner = THIS_MODULE,
+       .set   = &hid_bpf_fmodret_ids,
+};
+
 /* for syscall HID-BPF */
 BTF_SET8_START(hid_bpf_syscall_kfunc_ids)
 BTF_ID_FLAGS(func, hid_bpf_attach_prog)
@@ -495,6 +505,12 @@ static int __init hid_bpf_init(void)
         * will not be available, so nobody will be able to use the functionality.
         */
 
+       err = register_btf_fmodret_id_set(&hid_bpf_fmodret_set);
+       if (err) {
+               pr_warn("error while registering fmodret entrypoints: %d", err);
+               return 0;
+       }
+
        err = register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &hid_bpf_kfunc_set);
        if (err) {
                pr_warn("error while setting HID BPF tracing kfuncs: %d", err);
index 579a6c06906e1abd0176aab242edc45c59352cfa..207972b028d9c4abccc3bc756f33e4b013ea1d31 100644 (file)
@@ -103,7 +103,6 @@ __weak noinline int __hid_bpf_tail_call(struct hid_bpf_ctx *ctx)
 {
        return 0;
 }
-ALLOW_ERROR_INJECTION(__hid_bpf_tail_call, ERRNO);
 
 int hid_bpf_prog_run(struct hid_device *hdev, enum hid_bpf_prog_type type,
                     struct hid_bpf_ctx_kern *ctx_kern)