Repository navigation
qemu: ask for the hardening instead of inheriting it - #270
Merged
Merged
Conversation
QEMU_FLAGS now names what the build was given by meson's probes and Alpine's gcc: --enable-pie and --enable-stack-protector turn a failed probe into a configure error, and -z relro,now,noexecstack go to the linker. Two properties are new to QEMU's own code: stack-clash protection (gcc leaves it off; 502 -> 542 probes in qemu-system-x86_64) and _FORTIFY_SOURCE=3 through fortify-headers. -fcf-protection is left out: musl's libc.a carries no IBT/SHSTK marking, so the static-pie loses the property at link time. What a stripped ELF cannot show is asserted from the build: every compile command carries both flags (2288 kvm, 2814 tcg), and string.h with FORTIFY=3 sizes buffers with __builtin_dynamic_object_size. Size: qemu-system-x86_64 9297056 -> 9297120 bytes. Process start to a QMP quit, 60 runs each interleaved on a laptop: 38.7 -> 38.1 ms p50, noise. boot:firmware, boot:logind, boot:roms and boot:compat pass. kernel/README.md: where the bpf-restrict-fs line's fix lives (#261). Refs #264, #261 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
Author
|
Bench fleet, lab run 44531049945,
No step moves beyond noise: the hardening costs QEMU's start nothing that can be measured. |
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.
Closes #264.
What
QEMU_FLAGSasks for the hardening the build used to inherit from meson's probes and Alpine's gcc:--enable-pie,--enable-stack-protector: QEMU's own switches. A probe that fails is now a configure error instead of a binary without the property.-fstack-clash-protection: new to QEMU's own code. gcc leaves it off, and the 502 probes in the old binary came from Alpine's static libraries; there are 542 now.-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3: fortify-headers 3.0.1 (already inqemu/apk.lock). Level 2 was gcc's default. The-Ukeeps the redefinition warning out of meson's-Werrorprobes.-Wl,-z,relro,-z,now,-z,noexecstack.QEMU_CONFIG_REV7 → 8, so cached build directories are configured again.Answers to the issue's questions
__builtin_dynamic_object_size: 16 uses instring.hat level 3, none at level 2.-fcf-protection. A.ocompiled with it carries IBT+SHSTK, but the static-pie linked against musl'slibc.adoes not, because musl is unmarked. Linux would enforce nothing, and every function would pay for anendbr64. The Dockerfile records this.Asserted from the build
A stripped ELF cannot show stack-clash protection or FORTIFY, so the hardening step reads each build's
compile_commands.json. Both flags are on all 2288 compile commands of the KVM build and all 2814 of the TCG build. The same step checks thatstring.hwith FORTIFY=3 really selects fortify-headers' checks. The four ELF checks from before stay.Measured (laptop, not the goal's host)
qemu-system-x86_64quit, p50 / p95, 60 runs interleavedThese pass with this QEMU:
boot:firmware,boot:logind,boot:romsandboot:compat(a checkpoint of v20261114.02 resumes).boot:hotaddfails the same way with the old QEMU: the local image predates 9cb49ae.To come:
boot:ssh-firstinterleaved against the release on the bench fleet, vialab.yml, with this PR's QEMU run. The result goes here and indocs/log.md.🤖 Generated with Claude Code