Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

fix(arch): reject a testcase size above 1 GiB at the start harness - #508

Open
Wenzel wants to merge 2 commits into
intel:mainfrom
Wenzel:fix/start-size-upper-bound-488
Open

Wenzel wants to merge 2 commits into
intel:mainfrom
Wenzel:fix/start-size-upper-bound-488

Conversation

@Wenzel

@Wenzel Wenzel commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Summary

The size read from the guest at the start harness was used without an upper bound. With an uninitialized size variable, TSFFS read guest memory byte by byte until a read failed, then reported that address instead of the bad size.

 start_info(buffer, size)                   (src/arch/mod.rs)
+  if size > 1 GiB
+    error: names the size and the register or pointer it came from
   translate the buffer, read its contents

The check is in the helper shared by the three magic start variants and the manual start.

One integration test, x86_64_magic_size_unbounded_latest, with a new target tests/rsrc/x86_64-uefi/test-size-uninit.c.

Stacked on #507: the first commit is that PR, as the check lives in the helper it introduces. Only the last commit is new here.

Fixes #488

Evidence

The target passes size = 0x7ffe12345678 to HARNESS_START(buffer, &size). Linux, QSP x86-64:

main (ed67e1c) this branch
Simics 7.70.0 Failed to read byte at 0xf1000004: SimExc_General: Exception 1031 from qsp.mb.cpu0.mem[0][0], test takes 80 s (test FAILED) Testcase size 0x7ffe12345678 from the size variable at 0xdf2c1280 (register rdx) is larger than the maximum 0x40000000, is the size initialized?, test takes 31 s (test ok)
Simics 6.0.185 Failed to read byte error Testcase size 0x7ffe12345678 ... error

On this QSP the unbounded read did not hang: it ran into a device region after about 300 MB. How far it gets depends on the memory map of the target.

On Simics 7 the test runs through cargo test. On Simics 6 the same test script was run by hand in a project with the module built with SIMICS_BASE=simics-6.0.185, as the test harness here only knows the Simics 7 install. x86_64_magic_page_cross_latest from the parent PR also passes on this branch on Simics 6.

On this branch: lib unit tests 48 passed, 1 ignored. cargo clippy -r is clean.

Not run: the manual start path, the magic start variants that take the size in a register, the rest of the integration suite.

Merge Danger

Door: two-way

Blast Radius: contained

A harness that asks for a testcase buffer above 1 GiB is now refused. The limit is the constant MAXIMUM_TESTCASE_SIZE.

🤖 Generated with Claude Code

Only the first byte of the buffer was translated and the rest was
accessed at physical + i. A buffer crossing a page boundary is not
physically contiguous unless the guest is identity-mapped, so its tail
was written into an unrelated physical page.

StartInfo now holds (physical address, length) pieces. A size variable
that crosses into a non-contiguous page is rejected at start.

Fixes intel#487
The size read from the guest was used without an upper bound. With an
uninitialized size variable TSFFS read guest memory byte by byte until
a read failed, then reported that address instead of the bad size.

The error now names the size and the register or pointer it came from.

Fixes intel#488
@Wenzel
Wenzel force-pushed the fix/start-size-upper-bound-488 branch from d4e9b68 to f04665f Compare November 24, 2026 21:38

This branch has not been deployed

No deployments
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.

Start harness: a size read from the guest is used without an upper bound

1 participant