Skip to content

codeql: prove the patched files were read, trace the kernel and QEMU, analyse our Go and workflows (#653) - #659

Merged
aledbf merged 7 commits into
mainfrom
codeql-extraction-653
Nov 23, 2026
Merged

aledbf merged 7 commits into
mainfrom
codeql-extraction-653

Conversation

@aledbf

@aledbf aledbf commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Why

The goal is a cold first login under 100 ms with every carried patch safe to ship. #657 analyses the files the C patches touch, and every part reported 0 results. Nothing showed those files had been read. CodeQL's own diagnostics in the SARIF say they mostly had not. In build-mode none, every compilation of a touched kernel file failed, and so did three of QEMU's (throwaway run 45214602230). arch/x86/kernel/early-quirks.c, unwind_orc.c, arch/x86/pci/common.c, kernel/bpf/btf.c, hw/i386/x86-common.c, target/i386/cpu.c and target/i386/kvm/kvm.c were never analysed. Our own Go and workflows were not analysed at all (#653).

What

  • patched scope fails on a file not read. It reads cpp/diagnostics/successfully-extracted-files and, without a build, the failed compilations in cpp/bmn/extraction-information. It exits 2 naming each touched C file that is missing or failed. It bit in CI: run 45216274329 named 10 kernel files, and run 45218725523 named the same 10 after a first fix that was not enough.
  • The kernel and QEMU are compiled under the tracer (build-mode manual) by a new verb, patched compile. It builds only the touched objects: the kernel from kernel/config-*-x86_64 after prepare, QEMU for x86_64-softmmu. Their trees keep every file. qboot, systemd and OpenSSH stay buildless, since every touched file of theirs was extracted.
  • The kernel is analysed without CC_HAS_NAMED_AS. CodeQL's front end cannot parse __seg_gs, so every file that reached a per-CPU accessor failed to extract. The analysis tree turns the symbol off, which takes the upstream path for compilers without named address spaces. The build refuses a Kconfig that turns it on another way, and a .config that kept it.
  • Only the patches' own results go to code scanning. A result on a line the patches added or changed still fails the job and is uploaded. Upstream's results in touched files go to an upstream-results-<part> artifact. Alert One layout, one name for the image, and a fingerprint that cannot be shifted #1 (system/vl.c's -dump-vmstate fopen, which qemu 0001 does not change) was this kind of noise, and it would block a merge once a ruleset requires CodeQL.
  • Our own code. Two new jobs: own (go) (autobuild) and own (actions), both security-extended, on every PR, on main and on the weekly schedule. A new verb, patched severe, fails the Go job on any result of medium security severity (4.0) or above unless a codeql[<rule>] comment suppresses it. The suppression query is added to the run so that the SARIF marks those results. Why medium: the first Go run gave one result at medium or above, so the threshold costs nothing today, and every new one gets fixed or explained in the source. That one result was go/insecure-hostkeycallback in internal/lab/login.go (high). It is suppressed with its reason: vsock reaches only this host's own guest, whose keys its boot made. Lower severities go to code scanning only.
  • The patched matrix now runs behind spin-machine-dev changed (patches, their pins, the kernel config, this workflow, internal/patched), because the workflow itself now runs on every PR.

Results

Run 45220409814 is green. Every touched C file in all five parts was extracted, and no result lands on a line the patches added. Upstream's results kept as artifacts: kernel 6 (cpp/suspicious-pointer-scaling-void in unwind_orc.c and btf.c), qemu 2 (alert #1's fopen, and a pointer-scaling result in kvm.c).

Open

Code scanning's own CodeQL check is red because of alert #5, the suppressed go/insecure-hostkeycallback. Code scanning opens an alert for a result even when the SARIF marks it suppressed in source. It needs a person to dismiss it as won't fix, for the reason in the source comment. Every later in-source suppression needs the same dismissal. The workflow jobs are all green, including patched severe.

CI time

Measured in run 45220409814. own (go) takes 1.6 min and own (actions) 0.7 min, in parallel, on every PR. When a patched tree can change, the kernel analysis takes 5.7 min and QEMU's 4.7 min, against about 2.5 and 2 buildless in #657. The others are unchanged at about 2 min, and changed adds about 1 min before them.

Refs #653.

🤖 Generated with Claude Code

Comment thread internal/lab/login.go Dismissed
aledbf and others added 7 commits November 23, 2026 13:59
… kernel's and QEMU's; analyse our Go and workflows (#653)

CodeQL's own diagnostics in the SARIF say which files it extracted and, without
a build, which compilations failed. Run 45214602230 shows every touched kernel
compilation and three of QEMU's failed in build-mode none while each analysis
reported 0 results: arch/x86/kernel/early-quirks.c, unwind_orc.c,
arch/x86/pci/common.c, kernel/bpf/btf.c, hw/i386/x86-common.c,
target/i386/cpu.c and target/i386/kvm/kvm.c were never analysed.

patched scope now fails naming each touched C file the SARIF does not report
extracted, or reports a failed compilation of. The kernel and QEMU are compiled
under the tracer (patched compile: the kernel from its configuration, QEMU for
x86_64-softmmu, only the touched objects). The repository's Go and workflows
get their own jobs, security-extended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t failed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dium severity

patched scope now sends code scanning only the results on lines the patches
added or changed, the ones that fail the job. Upstream's results in the
touched files are kept as the job's artifact (upstream.txt): alert #1,
system/vl.c's -dump-vmstate fopen, which qemu 0001 does not change, was noise
and would block a merge once a ruleset requires CodeQL.

patched severe fails the Go analysis on a result of medium security severity
or above that no codeql[<rule>] comment suppresses. The first run gave one:
go/insecure-hostkeycallback in internal/lab/login.go, a vsock login to the
host's own fresh guest, suppressed in the source with its reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CodeQL's C front end cannot parse __seg_gs. Every touched kernel file that
reached a per-CPU accessor failed to extract (ten of fourteen, run
45216274329), which the new check named. The analysis tree turns
USE_X86_SEG_SUPPORT off, the path a compiler without named address spaces
builds, and refuses a Kconfig that turns it on some other way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… access

USE_X86_SEG_SUPPORT off left percpu_types.h's __percpu_seg_override on
__seg_gs whenever the compiler has named address spaces, and the same ten
files failed to extract (run 45218725523).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es and verbs

attestgate refused the SARIF and upstream-results uploads as unattested
publications: they are for a person to read. The traced compiles and the
severe and compile verbs get tests that run them against fake tools, which
holds coverage over its floor and refuses every mutation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aledbf
aledbf force-pushed the codeql-extraction-653 branch from 50a12c2 to 2718b87 Compare November 23, 2026 17:04
@aledbf
aledbf marked this pull request as ready for review November 23, 2026 17:24
@aledbf
aledbf merged commit f273377 into main Nov 23, 2026
17 of 18 checks passed
@aledbf
aledbf deleted the codeql-extraction-653 branch November 23, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants