diff options
author | Benjamin Tissoires <benjamin.tissoires@redhat.com> | 2022-11-03 16:57:46 +0100 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2022-11-15 16:28:29 +0100 |
commit | 0baef37335dd4d5cffd00c9b8bbf2e0b71e4239f (patch) | |
tree | 725677ea14136fc403a1aeba36a5b0caa0dad86b /drivers/hid/bpf/hid_bpf_dispatch.c | |
parent | dbb60c8a26daf388f183f599e1e96de5bb9f96e1 (diff) |
HID: bpf jmp table: simplify the logic of cleaning up programs
Kind of a hack, but works for now:
Instead of listening for any close of eBPF program, we now
decrement the refcount when we insert it in our internal
map of fd progs.
This is safe to do because:
- we listen to any call of destructor of programs
- when a program is being destroyed, we disable it by removing
it from any RCU list used by any HID device (so it will never
be called)
- we then trigger a job to cleanup the prog fd map, but we overwrite
the removal of the elements to not do anything on the programs, just
remove the allocated space
This is better than previously because we can remove the map of known
programs and their usage count. We now rely on the refcount of
bpf, which has greater chances of being accurate.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/bpf/hid_bpf_dispatch.c')
-rw-r--r-- | drivers/hid/bpf/hid_bpf_dispatch.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hid/bpf/hid_bpf_dispatch.c b/drivers/hid/bpf/hid_bpf_dispatch.c index 600b00fdf6c1..0ef99caf937a 100644 --- a/drivers/hid/bpf/hid_bpf_dispatch.c +++ b/drivers/hid/bpf/hid_bpf_dispatch.c @@ -94,7 +94,7 @@ hid_bpf_get_data(struct hid_bpf_ctx *ctx, unsigned int offset, const size_t rdwr * can use. */ BTF_SET8_START(hid_bpf_kfunc_ids) -BTF_ID_FLAGS(func, call_hid_bpf_prog_release) +BTF_ID_FLAGS(func, call_hid_bpf_prog_put_deferred) BTF_ID_FLAGS(func, hid_bpf_get_data, KF_RET_NULL) BTF_SET8_END(hid_bpf_kfunc_ids) |