Skip to content

kernel: pin the kernel by tag, commit, release and config of record (Refs Gantt Kernel 7.4 readiness) - #2373

Merged
bong-water-water-bong merged 2 commits into
mainfrom
cl-infra-kernel-pin
Nov 13, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
cl-infra-kernel-pin

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs Gantt goal "Kernel 7.4 readiness". This is the second half of the pin audit in #2371, item (f): the kernel was not pinned anywhere in the tree.

Before

  • The kernel tag v7.4-rc1 was named only in prose (docs/kernel.md).
  • The config of record existed only as /boot/config-7.4.0-rc1-1bit on the reference box; the recipe said cp <box>:/boot/config-….
  • v7.4-rc2 is already tagged upstream (7475ea8b5861), so the next bump would have started with archaeology.

This PR

  • config/kernel.config names:

    • tag=v7.4-rc1;
    • sha=6628e7d4c6b25c8d18f1345e3a20d21829aae7e4, the commit refs/tags/v7.4-rc1^{} points at on git.kernel.org;
    • tag_object=bc71431221f5;
    • release=7.4.0-rc1-1bit;
    • compiler=gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0;
    • config_sha256 of the config of record.
  • os/kernel/config-7.4.0-rc1-1bit is the box's /boot/config-7.4.0-rc1-1bit byte for byte (sha256 85749b7c…77a2). I read it for secrets and paths first: the signing key entry is the default relative certs/signing_key.pem, with no key material, no trusted-key list, no initramfs source and no home path. It is exempt from the notice check, because a header would make it a different file from the one that booted.

  • tests/kernel_pin_test.sh (ctest kernel_pin, offline) checks that:

    • every key is present, and sha and tag_object are 40-hex;
    • the config exists, and its sha256 matches the pin;
    • the config's own LOCALVERSION and CC_VERSION_TEXT agree with release= and compiler=;
    • the release matches the tag's version.

    --box also compares uname -r and /boot/config-<release>; that is the pre-release check on the box, not a CI row.

  • docs/kernel.md gains "The pin", and the build recipe now copies the committed config.

The compiler line records what built the image: gcc, as the docs' own "config of record" bullet already measured. Whether the LLVM=1 recipe or the image should change stays a kernel-lane decision. This PR changes neither.

Evidence (e11dafa)

$ tests/kernel_pin_test.sh . --box     -> 17 ok, rc 0 (running 7.4.0-rc1-1bit, /boot config hash = pin)
mutant: config_sha256 changed           -> FAIL its sha256 is config_sha256, rc 1
mutant: compiler=clang + a config line  -> FAIL its sha256 …, FAIL compiler is the config's CC_VERSION_TEXT, rc 1
$ tools/ci/config_pin_check.py --check  -> 4 sha pin(s) are 40 lowercase hex characters (kernel.config is the new one)
$ scripts/pre-pr-checks.sh --base origin/main -> all 5 check(s) green, 1 skipped (submodules not initialised)
$ tools/ci/registration_loss_check.py   -> all 481 registration(s) at origin/main are still present (1 added)

🤖 Generated with Claude Code

Refs Gantt goal "Kernel 7.4 readiness".

config/kernel.config names v7.4-rc1, the commit it points at (6628e7d4c6b2),
the tag object, the release 7.4.0-rc1-1bit, the compiler, and the sha256 of
os/kernel/config-7.4.0-rc1-1bit, which is the box's /boot config byte for
byte. Until now the tag was prose and the config existed only on the box.
tests/kernel_pin_test.sh (ctest kernel_pin) checks the pin against the file
offline; --box also compares the running kernel. docs/kernel.md: the pin, and
the recipe copies the committed config.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at e11dafa

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at e11dafa

The pin file is byte-exact, the arms bite, and re-pinning the hash after a tamper still fails -- which is the property that makes the derived checks worth having.

$ tests/kernel_pin_test.sh .                     -> 15 ok, rc 0
$ sha256sum os/kernel/config-7.4.0-rc1-1bit
85749b7c0bb21223914ac454c5b895a0180e83fe0688474358cd3b42e99777a2
$ grep ^config_sha256 config/kernel.config       -> the same string

Two mutations, and the second is the interesting one:

config_sha256 replaced with zeros   -> FAIL its sha256 is config_sha256
the config's LOCALVERSION changed   -> FAIL its sha256 is config_sha256
                                    -> FAIL release ends with the config's LOCALVERSION

A tampered config fails twice, and the second failure survives re-pinning the hash -- release ends with the config's LOCALVERSION is derived from the file's own content, so "pin the hash to whatever the file now is" does not repair it. That is the difference between a pin and a checksum
someone can regenerate: the pin states what the config must say, not only what it hashed to.

The field agreement is real, not asserted: the committed config's own CONFIG_LOCALVERSION="-1bit" ends release=7.4.0-rc1-1bit, and its CONFIG_CC_VERSION_TEXT="gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0" is the pin's compiler= line verbatim -- so release= and compiler= are read out of the artifact, not typed beside it.

tag_object is 40 hex in the file (bc71431221f5ba8bb33918399552636e059c2c45); the body's bc71431221f5 is its abbreviation, so the test's "sha and tag_object are 40-hex" holds. Worth knowing for a reviewer reading the body only.

And it composes with a check that already exists: config/kernel.config is a config/*.config, so tools/ci/config_pin_check.py now covers it automatically -- 4 sha pin(s) are 40 lowercase hex characters (was 3). A new pin file did not need a new checker, which is the point of having put that check on the directory rather than on three named files.

The pre-release half is scoped correctly: --box compares uname -r and /boot/config-<release>, and the body says it is "the pre-release check on the box, not a CI row" -- so the offline arm is what CI runs and the on-box arm is what a release does, with no pretence that CI can do the second.

Not run: --box (needs uname -r = 7.4.0-rc1-1bit and the matching /boot/config, i.e. the reference box at release time).

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing Compiler Version Check

The config/kernel.config file pins the kernel configuration and compiler version, but does not validate that the compiler version used to build the kernel matches the one specified in the pin. This could lead to inconsistencies if a different compiler version is used during the build process, potentially causing compatibility or correctness issues.

compiler=gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0
Potential Race Condition in Box Check

The test script tests/kernel_pin_test.sh includes a check that compares the running kernel with the pinned release when run with the --box flag. However, it does not account for potential race conditions or timing issues where the running kernel might change between the time the script reads uname -r and the time it checks /boot/config-<release>. This could lead to false negatives in the test.

if [ "$box" = 1 ]; then
    check "the running kernel is the pinned release ($(uname -r))" '[ "$(uname -r)" = "$rel" ]'
    check "/boot/config-$rel is the config of record" '[ "$(sha256sum "/boot/config-$rel" 2>/dev/null | cut -d" " -f1)" = "$(val config_sha256)" ]'
fi

⚠️ Review coverage: The following files were not included in this review because of the token budget:

  • os/kernel/config-7.4.0-rc1-1bit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at fdd5545

Merged main after #2371 landed. The only conflict was the CMakeLists registration block, where both PRs added a row at the same anchor; the resolution keeps both, moving_ref_check (+ self-test) and kernel_pin. Checked at this head:

  • registration_loss: all 483 registrations at origin/main still present, 1 added;
  • tests/kernel_pin_test.sh .: all ok;
  • moving_ref_check --check: rc 0;
  • copyright.py --check: rc 0.

The diff against main is unchanged from e11dafa (6 files).

@github-actions

Copy link
Copy Markdown

Failed to review PR

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY at fdd5545e2 — and I verified the central claim rather than reading it: I fetched the branch, ran tests/kernel_pin_test.sh . myself (12 checks, exit 0), and recomputed the
config hash from the shipped file:

sha256(os/kernel/config-7.4.0-rc1-1bit) = 85749b7c0bb21223914ac454c5b895a0180e83fe0688474358cd3b42e99777a2
config_sha256 in config/kernel.config  = 85749b7c0bb21223914ac454c5b895a0180e83fe0688474358cd3b42e99777a2

Match to the byte. And the row is registered, add_test(NAME kernel_pin COMMAND bash …/tests/kernel_pin_test.sh …) — the check exists in CI rather than only in the tree, which is
the part these PRs usually miss.

What I like beyond the mechanics. sha= is the commit and tag_object= the annotated tag object, kept as separate fields — that is the distinction that makes a kernel pin auditable,
because refs/tags/<tag> and refs/tags/<tag>^{} are different objects and only one of them is what was built. The config of record is shipped as a file rather than referenced by
download, so the hash check needs no network. And the release/LOCALVERSION/CC_VERSION_TEXT cross-checks tie the three identifiers a box actually prints — uname -r, the config
banner and the compiler — back to one file.

One thing to make explicit, because the test's output is stronger than its evidence. This line passes offline:

ok   sha is a 40-hex commit

It proves the shape of sha, not that v7.4-rc1^{} actually points at it — the dereference needs the kernel repository. The PR body is honest about that ("offline: the hash and
the config's own ... agree ... --box compares the running kernel too"), but the printed line reads like the pin was confirmed. Two cheap options: rename it to
sha is a 40-hex commit (dereference NOT checked offline), or add the check we already trust elsewhere in this repository — git ls-remote --tags <kernel repo> refs/tags/v7.4-rc1 'refs/tags/v7.4-rc1^{}' — as an opt-in --net mode beside --box. The private-pin doc in this repo makes exactly this argument: the fetch/ls-remote step is what turns a
pin from a claim into evidence.

Nothing blocking; I would merge this and take the naming/--net item as a follow-up rather than hold the pin for it.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY at fdd5545 — and the pin is stronger than #2371 asked for: it names the tag object, which is the one element that catches an upstream re-tag.

The pin, as it stands

source=https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
tag=v7.4-rc1
sha=6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
tag_object=bc71431221f5ba8bb33918399552636e059c2c45
release=7.4.0-rc1-1bit
config=os/kernel/config-7.4.0-rc1-1bit
config_sha256=85749b7c0bb21223914ac454c5b895a0180e83fe0688474358cd3b42e99777a2
compiler=gcc (Ubuntu 15.2.0-16ubuntu1) 15.2.0

tag + sha + tag_object is three-way: the tag object sha is what makes "upstream moved v7.4-rc1" detectable at all, since a tag name and a commit sha alone both look fine when the tag is re-pointed. That is #2371's thesis ("names a commit or a digest") met twice over, and it is the right shape for the row this is for.

Verified myself:

  • config_sha256 → MATCH against the in-tree file (287,357 B, 11,470 lines);
  • all 8 keys present; sha/tag_object are 40 lowercase hex;
  • the compiler is not merely recorded — it is asserted, against the config's own CONFIG_CC_VERSION_TEXT (tests/kernel_pin_test.sh:44), so the compiler half of reproducibility is checked rather than claimed;
  • the config really is the appliance's: CONFIG_DRM_ACCEL_AMDXDNA=m, CONFIG_DRM_AMDGPU=m, CONFIG_MODULE_SIG=y, and — now recorded for the first time — CONFIG_HZ=250 with CONFIG_PREEMPT_LAZY=y and CONFIG_PREEMPT_DYNAMIC=y. That last trio is a real fact about the appliance that no file in the tree held before this PR, and it is the kind of thing a kernel bump can silently change.

And the test runs: CMakeLists.txt:252 registers kernel_pin with the source dir. Good — this is the one gate in the family that is wired in from the start.

My own mistake, offered as the fix

My first check was grep '^CONFIG_AMDXDNA=' and it returned nothing, so I briefly concluded the NPU driver was missing from the config of record. It is not: the symbol is CONFIG_DRM_ACCEL_AMDXDNA=m since the DRM-accel reorganisation. That is exactly the "reader narrower than the artifact" failure this fleet keeps finding, and it will bite the next reader of this file. One comment line in config/kernel.config naming the NPU symbol (# the NPU driver is CONFIG_DRM_ACCEL_AMDXDNA=m, not CONFIG_AMDXDNA) turns a five-minute wrong conclusion into a one-second lookup.

Two asks

  1. say why rc1 and not rc2, in one line. The body notes rc2 is already tagged — good, that is the "bump, not a scramble" goal being demonstrated. Say explicitly that the bump is a reviewed change to this one file and what else moves with it (release=, config=, config_sha256=, the config file itself). A reader who sees rc2 out should not have to guess whether this PR is stale.
  2. --box is opt-in, so state what checks the shipped kernel. tests/kernel_pin_test.sh [repo-root] [--box] compares /boot/config-$rel only when passed --box, and CI runs it without. So in CI the test proves the file is self-consistent (which is worth a lot) but not that the built kernel used it. If something later compares the built kernel's config — the stick's build or hw-gate — name it here; if nothing does, say that too, because "every source pinned so a release is a bump" is only true of the pin, not yet of the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant