Place Rosetta arenas around fixed ELF images

MO
13h ago
+273-209

Rosetta reserves the span between the lowest and highest load segments of a fixed-address executable. An image spanning the default stack or an mmap arena can therefore fail before its entry point, even when the overlapping range is a hole between two segments.

Place the heap, stack and mmap arenas around affected executables. The initial launch and exec use the same layout check, and a forked child inherits the chosen arena bounds. A caller that tries to exec an image too large for the guest address space can handle ENOEXEC. The fork protocol advances to account for the new layout fields.

Verification

On an Apple M5, a static BusyBox fixture launched, forked, waited and executed another copy with its last segment at 32 MiB, 128 MiB, 320 MiB, 5 GiB, 9 GiB and 13 GiB. Upstream passed the 32 MiB control and faulted at each larger placement. A conventional executable with a 320 MiB BSS also ran. An oversized exec returned ENOEXEC to its caller. All 80 Rosetta matrix checks passed, including the new fixed-image regression.

Rosetta now installs the same open file descriptor used to validate the layout in AT_EXECFD and the VZ_CAPS path. Tested fixed images within the default heap, the alignment and address limits, and fork restoration of the relocated arenas. The statics suite uses a private directory per invocation. When integrating with #555, BSS staging hands off the descriptor for the prepared copy. That combined build, including the five other open changes, passed all 89 Rosetta checks.


Summary by cubic

Fixes Rosetta startup for fixed-address executables whose reserved load span overlaps the default stack or an mmap arena. The heap, stack, and mmap arenas are now placed around the image so the program no longer faults before its entry point.

  • Launch and exec share one retained image descriptor and the same placement check, transferring the fd to the guest after validation.
  • VZ_CAPS always publishes a /proc/self/fd alias for the target, keeping the host path only for diagnostics.
  • Exec returns ENOEXEC when an image leaves no room for the guest layout.
  • The fork IPC protocol magic advances to reject peers built before the new arena fields, with bounds validated on restore.
  • Adds a statics-suite regression that forks, waits, and execs a fixed BusyBox image spanning both mmap arenas; baselines move from 71 to 72.