hid.c (4f7153cf461ed0f78d8da8c9fd02d38728a76b90) | hid.c (e8445737c0264cf4ddac682c278e0ef5b8a61a3d) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (c) 2022 Red hat */ 3#include "vmlinux.h" 4#include <bpf/bpf_helpers.h> 5#include <bpf/bpf_tracing.h> 6#include "hid_bpf_helpers.h" 7 8char _license[] SEC("license") = "GPL"; --- 74 unchanged lines hidden (view full) --- 83 args->type, 84 args->request_type); 85 args->retval = ret; 86 87 hid_bpf_release_context(ctx); 88 89 return 0; 90} | 1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (c) 2022 Red hat */ 3#include "vmlinux.h" 4#include <bpf/bpf_helpers.h> 5#include <bpf/bpf_tracing.h> 6#include "hid_bpf_helpers.h" 7 8char _license[] SEC("license") = "GPL"; --- 74 unchanged lines hidden (view full) --- 83 args->type, 84 args->request_type); 85 args->retval = ret; 86 87 hid_bpf_release_context(ctx); 88 89 return 0; 90} |
91 92static const __u8 rdesc[] = { 93 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ 94 0x09, 0x32, /* USAGE (Z) */ 95 0x95, 0x01, /* REPORT_COUNT (1) */ 96 0x81, 0x06, /* INPUT (Data,Var,Rel) */ 97 98 0x06, 0x00, 0xff, /* Usage Page (Vendor Defined Page 1) */ 99 0x19, 0x01, /* USAGE_MINIMUM (1) */ 100 0x29, 0x03, /* USAGE_MAXIMUM (3) */ 101 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 102 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 103 0x95, 0x03, /* REPORT_COUNT (3) */ 104 0x75, 0x01, /* REPORT_SIZE (1) */ 105 0x91, 0x02, /* Output (Data,Var,Abs) */ 106 0x95, 0x01, /* REPORT_COUNT (1) */ 107 0x75, 0x05, /* REPORT_SIZE (5) */ 108 0x91, 0x01, /* Output (Cnst,Var,Abs) */ 109 110 0x06, 0x00, 0xff, /* Usage Page (Vendor Defined Page 1) */ 111 0x19, 0x06, /* USAGE_MINIMUM (6) */ 112 0x29, 0x08, /* USAGE_MAXIMUM (8) */ 113 0x15, 0x00, /* LOGICAL_MINIMUM (0) */ 114 0x25, 0x01, /* LOGICAL_MAXIMUM (1) */ 115 0x95, 0x03, /* REPORT_COUNT (3) */ 116 0x75, 0x01, /* REPORT_SIZE (1) */ 117 0xb1, 0x02, /* Feature (Data,Var,Abs) */ 118 0x95, 0x01, /* REPORT_COUNT (1) */ 119 0x75, 0x05, /* REPORT_SIZE (5) */ 120 0x91, 0x01, /* Output (Cnst,Var,Abs) */ 121 122 0xc0, /* END_COLLECTION */ 123 0xc0, /* END_COLLECTION */ 124}; 125 126SEC("?fmod_ret/hid_bpf_rdesc_fixup") 127int BPF_PROG(hid_rdesc_fixup, struct hid_bpf_ctx *hid_ctx) 128{ 129 __u8 *data = hid_bpf_get_data(hid_ctx, 0 /* offset */, 4096 /* size */); 130 131 if (!data) 132 return 0; /* EPERM check */ 133 134 callback2_check = data[4]; 135 136 /* insert rdesc at offset 73 */ 137 __builtin_memcpy(&data[73], rdesc, sizeof(rdesc)); 138 139 /* Change Usage Vendor globally */ 140 data[4] = 0x42; 141 142 return sizeof(rdesc) + 73; 143} |
|