Which Kernel Patches Actually Reach My Binary?

Which Kernel Patches Actually Reach My Binary?

Table of Contents

A stable kernel update ships tens to hundreds of commits; a merge window ships more than twelve thousand. For a product kernel the important question is not “what changed in Linux” but “what changed in my kernel”: the one built from my defconfig, for my board, with my compiler. With the Cyber Resilience Act and NIS2 asking for a documented assessment of every vulnerability fix, “we took the whole update” is no longer an answer you can defend, and “we read all 12,000 commits” is not one you can afford.

Patch Impact Tester (PIT) answers it mechanically. It builds the kernel once with a GCC plugin that records what actually gets compiled, then maps every commit between two versions onto that record.

Live results: pages.fynq.rocks/markus/patch-impact-tester

The idea

git diff knows which lines changed. The compiler knows which lines ended up in the binary. Bringing these two facts together is all you need, but a line-level intersection alone is too coarse. Things the plugin records per translation unit:

  • functions and their line ranges, only for functions that survive into GIMPLE (no #ifdef’d-out code, no unused static inlines)
  • struct layouts (PLUGIN_FINISH_TYPE): fields, offsets, sizes, and which fields each compiled function actually touches
  • macro expansions (PLUGIN_PRE_GENERICIZE): which macro, defined where, was expanded in which compiled function

The analysis then walks the commit range and classifies every hunk:

ClassMeaning
MODbody of a compiled function changed
ADD / RM / MOV / Rfunction added, removed, moved, renamed
STRUCTlayout of a struct changed; affected = functions using the changed fields
MACROdefinition of an expanded macro changed; affected = functions expanding it
BINmachine code changed (see below)

Everything else (other architectures, unselected drivers, documentation, tooling) is “not compiled” and drops out.

Do not trust the source alone

Source-level mapping can be wrong in both directions, so PIT checks itself against the object code. For every tag it collects the per-function objdump output, normalizes relocations, addresses, padding NOPs and the __pfx_ symbols, and hashes it. Each changed function is then:

  • confirmed — source and machine code changed
  • src_only — source changed, code identical (comments, dead branches, formatting)
  • bin_only — code changed, source of this function didn’t

The bin_only bucket turned out to be the interesting one, more on that below.

Context per commit

A changed function is only half the picture. For every compiled commit PIT also records:

  • CVEs, from the official vulns.git of the kernel CNA, matched on the fixing SHA1
  • subsystem and maintainers, via a MAINTAINERS glob parser
  • backport latency: time between the mainline commit and its stable backport
  • Fixes: chains: regressions introduced and fixed inside the same series

Validation

A synthetic kernel regression test applies one commit per case to v6.6 (tinyconfig): modified function, moved function, struct field change, macro change, a change in an unselected driver and so on. All 15 cases must be classified correctly, and the machine-code check must confirm exactly the expected functions. Nothing is shipped unless that test passes.

Setup

  • GitLab CI on a self-hosted EPYC runner, Debian trixie, GCC 14
  • two configurations in parallel: Raspberry Pi 5 (bcm2712_defconfig, arm64) and x86_64_defconfig
  • series:
    • cycle:v6.6: v6.5 → v6.6-rc1 … rc7 → v6.6 → every v6.6.y
    • mainline: v6.6 onwards, release by release
  • a daily release watch picks up new tags automatically
  • reports as HTML (also readable in lynx), JSON and CSV, published with GitLab Pages

First results (interim)

The first full run is still in progress, so treat these numbers as interim. Sums run over all steps of a series, and a CVE fixed in more than one step can be counted more than once. The ratios hold up better than the absolute values.

The merge window, v6.5 → v6.6-rc1. 12,330 commits:

ConfigurationCommits reaching compiled codeShare
bcm2712_defconfig2,40519.5 %
x86_64_defconfig1,58612.9 %

In the same window, 440 struct layout changes touched almost 11,000 compiled functions on the Pi build.

CVE fixes in the v6.6 cycle. About 49 % of the CVE fixes in the series hit compiled code for the Raspberry Pi configuration. For x86_64_defconfig it is about 18 %. A small defconfig rules out most of the noise, and a full board config does not. Both numbers show that a large part of the CVE list is irrelevant for any one product, and that you need to measure which part.

Backport latency. The median time from a mainline fix to the stable backport is about 24 days per step. The long tail runs past 500 days.

Struct changes are everywhere. Almost every stable release changes the layout of at least one struct used by compiled code. A one-line field addition can change hundreds of functions without touching their source.

Machine code changes beyond the source. On the Pi build, more than half of the functions whose machine code changed are bin_only: their own source did not change. Most of these come from inlining. A modified static inline helper in a header changes every caller in every file. Constants and __LINE__ in WARN-style macros account for the rest. A source-only review misses this, and it is the main reason PIT cross-checks against the object code.

Known rough edges

  • generated headers (include/generated/utsrelease.h) currently show up as a changed macro in every step; they will be excluded
  • bin_only needs an inline-propagation pass to attribute each change to its originating commit

Outlook

The next steps are exact attribution of inlined changes, filtering generated headers, and a per-release “what to review” list sorted by CVE, subsystem and blast radius. The goal is a report that tells you which patches your build actually contains and why, so you can look at those first.

Results, downloads and per-release reports: pages.fynq.rocks/markus/patch-impact-tester

Related Posts

Tracing Every Function Call with a GCC Plugin

Ever wanted to see every function call in a program — entry, exit, thread ID, and instruction pointer — without touching the source? This post builds exactly that: a GCC plugin that instruments functions at compile time and a libc-free runtime tracer that writes the log using raw syscalls.

Read More

Hello World on ZynqMP R5 with Zephyr OS

The ZynqMP SoC has two Cortex-R5F cores sitting alongside the quad-core Cortex-A53 APU. Most people leave them unused. Here’s how to bring them up with Zephyr RTOS and communicate with Linux over RPMsg — the entire workflow from a running Linux system, no JTAG required.

Read More

Tracing glibc Itself — From _dl_start to printf

The previous post built a GCC plugin that traces every function in a normal program. This post takes it to the logical extreme: instrumenting glibc itself, including ld.so — the dynamic linker that runs before main, before any libc function exists, before the process is even fully initialized.

Read More