Pioneer Voices

Kees Cook details workflow for verifying Linux kernel binary changes

Key Takeaway

Kernel developers can use diffoscope and objdump to ensure source code refactoring does not introduce unintended executable changes.

Summary

Linux kernel security engineer Kees Cook describes a methodology for verifying that source code changes, specifically when replacing 1-element arrays with flexible array members, do not alter the resulting binary code. The process involves using diffoscope to compare builds and objdump to isolate executable differences. This approach helps identify subtle bugs where structure size calculations might be incorrectly updated during refactoring.

Verifying refactoring with binary diffing

  • Uses diffoscope to compare object files between a 'before' and 'after' build.
  • Employs specific KBUILD flags (e.g., fixed timestamps and user/host info) to ensure reproducible build conditions.
  • Utilizes objdump with flags like --disassemble, --demangle, and --no-show-raw-insn to inspect the .text section without line number noise.
  • Identifies potential bugs in size calculations, such as failing to adjust kmalloc arguments when moving from data[1] to data[].
  • Recommends using kernel helpers like struct_size() to prevent arithmetic overflows.

Why it matters

This workflow provides a rigorous way for kernel maintainers to ensure that large-scale code cleanups do not introduce regressions or subtle memory calculation bugs.

Original reference: outflux.net →