• Benjamin Tissoires's avatar
    HID: bpf jmp table: simplify the logic of cleaning up programs · 0baef373
    Benjamin Tissoires authored
    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: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
    Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
    0baef373
hid_bpf_jmp_table.c 12.8 KB