Systematic Comparison of Patch Development with HID-BPF and In-Kernel Patches
- Typ der Arbeit: Bachelorarbeit
- Status der Arbeit: reserviert
- Projekte: AHA
- Betreuer: Daniel Lohmann, Nils Fuhler

Image from David Revoy's blog post How a kernel developer made my styluses work again on newer kernels! - CC BY 4.0
Context
The USB HID (Human Interface Device) standard is the standard virtually all input devices use today. This also includes touch and stylus devices. However, there is no strict specification for the behavior of stylus devices. Instead, Microsoft has released a guideline for the states a stylus device should report to the operating system. These guidelines are also implemented in the generic UBS HID driver in the Linux kernel.
A problem arises when a device does not adhere to Microsoft's guidelines. While manufacturers generally make sure their device will work with Windows, it often is up to the community to make sure the device works with Linux, possibly implementing a patch for the divergent behavior.
In the past, there have been two ways to introduce a patch for a HID device. A developer could either implement a whole custom driver for the device or they could introduce a so called quirk into the generic driver that changes the behavior for a specific edge case. Both of these options include submitting a patch to the Linux kernel itself, which comes with some drawbacks. If a new driver is added, the maintainers of the subsystem have to maintain an additional driver. If a quirk is added to the generic driver, it becomes more convoluted as more and more quirks are added for more and more non-compliant devices.
Because of this, HID-BPF has been developed. It allows to change the behavior of a HID device using the eBPF framework. This has the advantage that a device can be patched using a small, self-contained BPF program that does not have to be a part of the Linux kernel.
Problem
Currently, there is no systematic investigation of the differences between patching devices with kernel patches and patching devices with HID-BPF.
Goal
Your task is to systematically compare the generic HID driver and HID-BPF in this context. A TV in our seminar room that currently does not work correctly with the generic HID driver will serve as an example for developing a real-world patch.
Your thesis could follow these key steps:
-
Getting Started: Familiarize yourself with HID, the associated tools and kernel development. Set up a development environment where you can develop kernel patches as well as HID-BPF programs.
-
Analyze hid-generic and HID-BPF: Analyze and compare the workings and possibilities of both the generic HID driver and HID-BPF. The metrics could include function range, development and submission process, rollout process, general applicability, prior knowledge needed, and performance.
-
Fix the device: Debug the behavior of the TV and implement the fixes for it.
-
Evaluate the implementation effort: Now that you have implemented a real patch, correlate your experiences with your findings of step 2.
-
(optional) Upstream your fix: If you want, you can submit one of the two fixes upstream to the Linux kernel. This way, other people can also benefit from your work.
