diff options
author | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2022-11-03 18:57:44 +0300 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2022-11-15 18:28:28 +0300 |
commit | f5c27da4e3c8a2e42fb4f41a0c685debcb9af294 (patch) | |
tree | dca477e34c80d61362ddd2ebbfbe2a4f9dc6bc22 /drivers/hid/Makefile | |
parent | 25621bcc89762fe1329ae9c9dab75bc70ef1aee0 (diff) | |
download | linux-f5c27da4e3c8a2e42fb4f41a0c685debcb9af294.tar.xz |
HID: initial BPF implementation
Declare an entry point that can use fmod_ret BPF programs, and
also an API to access and change the incoming data.
A simpler implementation would consist in just calling
hid_bpf_device_event() for any incoming event and let users deal
with the fact that they will be called for any event of any device.
The goal of HID-BPF is to partially replace drivers, so this situation
can be problematic because we might have programs which will step on
each other toes.
For that, we add a new API hid_bpf_attach_prog() that can be called
from a syscall and we manually deal with a jump table in hid-bpf.
Whenever we add a program to the jump table (in other words, when we
attach a program to a HID device), we keep the number of time we added
this program in the jump table so we can release it whenever there are
no other users.
HID devices have an RCU protected list of available programs in the
jump table, and those programs are called one after the other thanks
to bpf_tail_call().
To achieve the detection of users losing their fds on the programs we
attached, we add 2 tracing facilities on bpf_prog_release() (for when
a fd is closed) and bpf_free_inode() (for when a pinned program gets
unpinned).
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/Makefile')
-rw-r--r-- | drivers/hid/Makefile | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index e8014c1a2f8b..c45b516eb767 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile @@ -5,6 +5,8 @@ hid-y := hid-core.o hid-input.o hid-quirks.o hid-$(CONFIG_DEBUG_FS) += hid-debug.o +obj-$(CONFIG_HID_BPF) += bpf/ + obj-$(CONFIG_HID) += hid.o obj-$(CONFIG_UHID) += uhid.o |