Repository navigation
TCB: x86-64 functions return without secret residue, but those an allowlist names - #4741
Open
reaperhulk wants to merge 1 commit into
Open
reaperhulk wants to merge 1 commit into
reaperhulk wants to merge 1 commit into
Conversation
|
This pull request has conflicts with Posted by |
…owlist names Trust change. TCB/X86_64/Residue.lean defines NoResidue: two runs from states that agree on what the contract says is public and on everything outside the buffers end in states that agree on everything outside the buffers but the result (registers, flags, vector registers, MXCSR, and the stack below the caller's stack pointer). Target.noResidue (x86-64: NoResidue) says what a target means by it, and Artifact.residue and Registration.residue carry an optional proof. The emitter refuses a function of such a target without a proof unless ci/residue_allowlist.txt names it, and, in a full run, a listed function that has a proof or no longer exists (Rust.checkResidue); it documents the functions, and the dispatchers all of whose implementations, that prove it. Every x86-64 function is listed for now; the generated code is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ajQWxYnEynffr2A7QLPVa
reaperhulk
force-pushed
the
claude/residue-tcb
branch
from
November 8, 2026 21:26
639e533 to
85a5b51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Trust change (
lean/VerifiedGarbage/TCB/). It adds a property and a check, and weakens no model, contract orVerified. Nothing proves the property yet: every x86-64 function is on the allowlist, so the generated code does not change.The property
TCB/X86_64/Residue.leandefinesNoResidue c k retBits. LikeConstantTime, it is a property of two runs. Take any two runs ofcfrom states that:k.pre,k.pubsays is public,Outside 0).They end in states that agree on everything outside the buffers but the result (
Outside retBits). "Everything outside the buffers" means:ymm/zmmandzmm16–zmm31;So what the function leaves where its Rust caller cannot clear it depends only on what the caller left there and on public data. Clearing a location and leaving its entry value are equally fine; no choice can carry a secret.
What was there on entry is taken as given: a secret the caller left in a register is the caller's. So are the return addresses the code's calls push (
State.unknowns), which are code addresses.Not covered, because the model does not have them:
k1;The enforcement
Target.noResidue(TCB/Artifact.lean) is what a target means by the property:some NoResidueon x86-64,noneelsewhere.Artifact.residueandRegistration.residue(TCB/Registration.lean) carry an optional proof of it for the artifact's code, contract and result width. None is possible on a target that does not define the property.The emitter (
Rust.checkResidue, run byEmit.run) refuses:ci/residue_allowlist.txtlists it;--part, which has all of a target's artifacts), a listed function that has a proof or no longer exists.Converting a function therefore removes its line, and every problem is reported at once.
The generated documentation of a function that proves it, and of a dispatcher all of whose implementations do, says so (
Rust.residueDoc).A follow-up PR adds the framework that proves the property (a residue analysis, and a verified scrub of what it finds), the first conversions, and a CI check that the list only shrinks. Until then, a new x86-64 function gets a line, which the emitter requires.
Review
What to read:
TCB/X86_64/Residue.lean(60 lines):OutsideandNoResidue.TCB/Artifact.lean: the newTargetfield.Contractmoved aboveTarget, unchanged, since the field's type uses it.TCB/Registration.lean: the tworesiduefields andApi.artifactpassing it.TCB/Rust.lean:parseResidueAllowlist,checkResidueandresidueDoc.TCB/Emit.lean: the call inrun.Changing
Targetrebuilds every Lean module once.Checks
Locally, on the commit before its rebase onto #4678 (which touched only PPC64LE in
TCB/):lake build,Emit.lean(every x86-64 function listed; no generated file changes), the Static checks job,check_lean_public_imports.py: pass.cargo testwith Wycheproof: pass.The rebase dropped 10 lines for AES-GCM-SIV variants
mainremoved since.No benchmark: no generated code changes.
Generated by Claude Code