Università degli Studi di Modena e Reggio Emilia
Dipartimento di Scienze Fisiche, Informatiche e Matematiche
Corso di Laurea Magistrale in Informatica (A.A. 2023/24)

Efficient, safe and stable channeling of Linux kernel drivers to user space

https://tesi24.rossilorenzo.dev/

Candidato: Lorenzo Rossi
Relatore: Paolo Valente
Correlatore: Andrea Righi

Problem

Operating Systems are a fundamental part of our infrastructure.

Linux alone, through Android, upholds at least 2.5 billion devices
(according to Google).

Unfortunately, those foundations are not as solid as they should be.

:(

Your PC ran into a problem and needs to restart as soon as we're finished collecting some error info.

00% complete

This screen represents an unrecoverable failure of your Operating System.

Why is it so common?

Linux, being a monolithic kernel, executes all drivers in the kernel. Thus if a driver crashes it might compromise the whole system

State of the Art

Microkernels: run drivers in user space
UIO: similar solution in Linux

high overhead 🡒 low performance

How can we improve robustness
without hurting performance?

  • Robustness 🡒 isolation
  • Performance 🡒 remain in kernel
    • In the literature there are solutions but their isolation techniques yield inefficient code

Use BPF

BPF is an in-kernel isolation technique being in development for more than 30 years

Run drivers in BPF!

Drivers can also run parts in user space, being able to access a wider ecosystem.

  • Robustness 🡒 isolated drivers
  • Performance 🡒 hot paths in kernel
  • Overhead 🡒 efficient isolation
  • Maintenance 🡒 Stable interface, lower maintenance

In Linux there is no singular "driver interface".
There is an interface for each BUS type.
A driver connects to all BUSes it needs.

drv_ext is a collection of interfaces that enable the creation of BPF drivers.

we have implemented hid_ext and usb_ext
with a proof-of-concept keyboard driver.
The webcam driver is still in development

Code path

Demo!

hid_ext + keyboard driver

Measurements?

We intended to have measurements, but the project is more complex than what we initially envisioned:

  • We reimplemented linked-list iteration
  • We worked around missing asynchronous callbacks support
  • We discovered bugs in the current BPF toolchain regarding endianness
When the UVC driver will be available, measurements will be the first order of business.

Future work

  • Bus Support: We plan to add BPF interfaces to support other BUS types
  • Upstreaming: We are presenting our work to the Linux Kernel Mailing List (LKML)
  • Portability: BPF is also supported by Windows, it might be possible to use the same driver for multiple operating systems

Thank you!

Any questions?