• Benjamin Tissoires's avatar
    HID: initial BPF implementation · f5c27da4
    Benjamin Tissoires authored
    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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
    Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
    f5c27da4
README 184 Bytes