diff options
| author | salmonik <salmonik@tuta.io> | 2026-08-02 22:46:59 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-08-02 22:46:59 +0200 |
| commit | e649a3de7d853bf82a9105a2cb3869c7b8c96108 (patch) | |
| tree | ec4707aad3437aa995129fff34aa5ac81e3cf1c1 /rsdos | |
| parent | v0.5.7: heap range on the boot screen — real-hardware geometry without a crash (diff) | |
| download | rs-dos-e649a3de7d853bf82a9105a2cb3869c7b8c96108.tar.gz rs-dos-e649a3de7d853bf82a9105a2cb3869c7b8c96108.zip | |
v0.5.7: guard report 4-words-per-line — 16 stack words survive band hand-copy
The OptiPlex repro copies are truncated at the ~110-char band width, so
the old single-line 'stk:' (12 words, >200 chars) lost the return chain
after a few words. Split mem/stk dumps into 4-words-per-line blocks:
mem+mem2 (8 words around the corruption) and stk..stk4 (16 words) —
the drop caller chain now survives hand transcription.
Diffstat (limited to 'rsdos')
| -rw-r--r-- | rsdos/src/main.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/rsdos/src/main.rs b/rsdos/src/main.rs index cbbf2ba..806f150 100644 --- a/rsdos/src/main.rs +++ b/rsdos/src/main.rs | |||
| @@ -344,9 +344,38 @@ pub unsafe extern "efiapi" fn efi_main(image_handle: Handle, system_table: *mut | |||
| 344 | } else { | 344 | } else { |
| 345 | rsnix::serial_println!("cursor: no mouse — overlay disabled"); | 345 | rsnix::serial_println!("cursor: no mouse — overlay disabled"); |
| 346 | } | 346 | } |
| 347 | // TEST HOOK: reproduce the OptiPlex '0xaaaaaa' uninit-drop crash in | ||
| 348 | // QEMU. The real hardware's stack carries 0xAA fill left by | ||
| 349 | // firmware; any shell value that is dropped without being written | ||
| 350 | // then frees garbage and trips the dealloc guard. Filling the | ||
| 351 | // shell's future stack region with 0xAA here makes the same bug | ||
| 352 | // visible on QEMU (serial + gdb available) instead of only on the | ||
| 353 | // OptiPlex. | ||
| 354 | stack_fill_aa(); | ||
| 347 | shell::run(); | 355 | shell::run(); |
| 348 | } | 356 | } |
| 349 | 357 | ||
| 358 | /// Write 0xAA over the stack region the shell's frames will reuse, | ||
| 359 | /// leaving the current frames (top 4 KiB) intact. 128 KiB covers the | ||
| 360 | /// whole shell frame chain on QEMU and the OptiPlex. Best-effort: the | ||
| 361 | /// region is below rsp inside the boot stack mapping. | ||
| 362 | fn stack_fill_aa() { | ||
| 363 | let rsp: usize; | ||
| 364 | unsafe { | ||
| 365 | core::arch::asm!("mov {}, rsp", out(reg) rsp); | ||
| 366 | } | ||
| 367 | let top = rsp - 0x1000; | ||
| 368 | let bottom = rsp - 0x21000; | ||
| 369 | unsafe { | ||
| 370 | let mut p = bottom; | ||
| 371 | while p < top { | ||
| 372 | core::ptr::write_volatile(p as *mut u64, 0xAAAAAAAAAAAAAAAA); | ||
| 373 | p += 8; | ||
| 374 | } | ||
| 375 | } | ||
| 376 | rsnix::serial_println!("stack: 0xAA-fill 0x{:x}..0x{:x}", bottom, top); | ||
| 377 | } | ||
| 378 | |||
| 350 | // --------------------------------------------------------------------------- | 379 | // --------------------------------------------------------------------------- |
| 351 | // Print a memory summary from the stashed memory map | 380 | // Print a memory summary from the stashed memory map |
| 352 | // --------------------------------------------------------------------------- | 381 | // --------------------------------------------------------------------------- |
