Skip to content

hash: log version and sha256 of /proc/self/exe at boot#161

Open
zvonkok wants to merge 4 commits into
NVIDIA:mainfrom
zvonkok:main
Open

hash: log version and sha256 of /proc/self/exe at boot#161
zvonkok wants to merge 4 commits into
NVIDIA:mainfrom
zvonkok:main

Conversation

@zvonkok
Copy link
Copy Markdown
Collaborator

@zvonkok zvonkok commented May 28, 2026

Enables operators to correlate dmesg output against the cosign/Rekor digest published in the release evidence bundle (ARCHITECTURE.md §"Provenance & Supply-Chain Security").

Also, an indicator for CI runs to verify we're indeed running the new binary.

Copilot AI review requested due to automatic review settings May 28, 2026 22:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a small module that hashes /proc/self/exe with SHA-256 at boot and logs version=… sha256=…, so operators / CI can correlate the running NVRC against the Rekor-published digest in the release evidence bundle.

Changes:

  • New hash module that reads /proc/self/exe, computes SHA-256, and logs it together with CARGO_PKG_VERSION.
  • Wires hash::exe() into main after kernlog/syslog setup; exposes module via lib.rs.
  • Adds sha2 (no_std, default-features off) as a dependency and updates Cargo.lock; documents a "self-describing code" guideline in CLAUDE.md.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/hash.rs New module: sha256() reads /proc/self/exe and exe() logs version + digest; includes hex-encode + sha256 tests.
src/main.rs Registers hash module and calls hash::exe() early in boot.
src/lib.rs Exposes pub mod hash for library/test consumers.
Cargo.toml Adds sha2 = "0.10" with default-features = false.
Cargo.lock Pulls in sha2 and transitive deps (digest, block-buffer, cpufeatures, etc.).
CLAUDE.md Adds guideline #7 on self-describing code vs. comments.

@zvonkok zvonkok added the ok-to-test Ok to test label May 28, 2026
@zvonkok zvonkok force-pushed the main branch 2 times, most recently from b38b233 to 3ccba21 Compare May 28, 2026 22:46
Copilot AI review requested due to automatic review settings May 28, 2026 22:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated no new comments.

@github-actions github-actions Bot removed the ok-to-test Ok to test label May 29, 2026
zvonkok added 2 commits May 29, 2026 21:23
Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Assisted-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Lets operators correlate dmesg output against the cosign/Rekor digest
published in the release evidence bundle (ARCHITECTURE.md
§"Provenance & Supply-Chain Security").

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Assisted-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 29, 2026 21:25
@zvonkok zvonkok added the ok-to-test Ok to test label May 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.

CARGO_PKG_VERSION alone cannot tell a clean release apart from a local
or CI build of uncommitted code. CI computes a short commit (plus -dirty
for an unclean tree) and exports it as GIT_REV on the cargo build command;
hash.rs reads it via option_env! and appends it as semver build metadata,
e.g. "version=0.1.4+g3ccba213b033". Release builds leave GIT_REV unset and
log the bare version.

NVRC is an init process: its mounts, module loads, daemon forks and the
poweroff panic hook would wreck a normal host. init::as_pid1() now gates
all of that on a raw SYS_getpid syscall (no /proc, which isn't mounted this
early): as PID 1 it returns and boot continues; anywhere else (CI smoke
test, dev shell) it prints the version+sha256 line to stdout and exits 0.
That makes the binary safe to execute directly and usable as a CI smoke
test of the build.

This stays a dev-convenience hint: a tampered binary can forge it, so
authoritative release identity remains the sha256 correlated against Rekor.
CARGO_PKG_VERSION cannot be overridden from the environment (cargo sets it
from Cargo.toml), hence a separate var rather than a build.rs, which would
make the otherwise hermetic build depend on git state.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Assisted-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 29, 2026 22:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Comment thread src/hash.rs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
Copilot AI review requested due to automatic review settings May 29, 2026 22:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.

@zvonkok zvonkok added the ok-to-test Ok to test label May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Ok to test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants