Extending the Linux kernel with built-in kernel headers

Linux kernel headers are the unstable, constantly-changing, internal API of the kernel. This includes internal kernel structures (for example, task_struct) as well as helper macros and functions. Unlike the UAPI headers used to build userspace programs that are stable and backward-compatible, the internal kernel headers can change at any time and any release. While this allows the kernel unlimited flexibility to evolve and change, it presents some difficulties for code that needs to be loaded into the kernel at runtime and executed in kernel context.

[…]

My solution to the problem is to embed the kernel headers within the kernel image itself and make it available through the sysfs virtual filesystem (usually mounted at /sys) as a compressed archive file (/sys/kernel/kheaders.tar.xz). This archive can be uncompressed as needed to a temporary directory. This simple change guarantees that the headers are always shipped with the running kernel.

This change has been added to version 5.2 of the Linux kernel.

8 Comments

  1. 2019-07-25 5:42 am
  2. 2019-07-25 6:37 am
    • 2019-07-25 7:10 am
      • 2019-07-25 7:26 am
        • 2019-07-25 10:00 am
          • 2019-07-25 11:41 am
  3. 2019-07-26 2:49 am
    • 2019-07-26 8:58 am