Upstream Kernel Hardening: Progress on Enabling -Wflex-array-member-not-at-end
summary
GCC 14 -Wflex-array-member-not-at-end surfaces ~60,000 warnings in the kernel but only ~650 are unique; work under KSPP audits and fixes those cases and cuts uniques to ~200 so far. Practical fixes include converting fake zero/one-element arrays to C99 flex arrays, enabling strict-flex-arrays, annotating with the counted_by attribute, and adding helpers (st_group, container_of usage, DECLARE_FLEX/DECLARE_RO_FLEX and a new trailing_overlap helper) which preserve memory layout and remove false positives.
AI-written summary · about
chapters (21)
- 0:00Introduction
- 2:06Flexible array members
- 5:44-Wflex-array-member-not-at-end explained
- 7:54Flexible arrays in middle
- 8:15Kernel hardening history
- 11:49Strict flex arrays discovery
- 15:45Warnings and unique issues
- 16:31Four warning categories
- 16:51Case 1: Unused flexible arrays
- 17:34Case 2: Non-composite access
- 20:00Fixing header issues with __group
- 22:57Case 3: Heap unions with flex arrays
- 26:27Flexible array access with container_of
- 27:13Case 4: Stack unions with flex arrays
- 28:59declare_flex and declare_row_flex helpers
- 31:03declare_row_flex challenges
- 32:48Introducing trailing_overlap
- 36:42Memory layout with trailing_overlap
- 38:07Solutions evolution
- 39:10Current strategies and work
- 40:13Progress and outlook
related talks
40mUpstream Kernel Hardening: Progress on Enabling -Wflex-array-member-not-at-end
35mUpstream Kernel Hardening: Recent Progress and Challenges
01h 12mEnhancing Spatial Safety: Better Array-bounds Checking in C (and Linux)
46mProgress On Bounds Checking in C and the Linux Kernel
47mChallenges and Innovations Towards Spatial Safety in the Linux Kernel
54mSecurity Features status update
44mWhere are we on security features?
52mWelcome & Opening Remarks & Meaningful Bounds Checking in the Linux Kernel
