Skip to content

Bus: validate serialized memory access timings - #194

Open
acts-1631 wants to merge 1 commit into
libretro:mainfrom
acts-1631:validate-bus-state-timings
Open

acts-1631 wants to merge 1 commit into
libretro:mainfrom
acts-1631:validate-bus-state-timings

Conversation

@acts-1631

Copy link
Copy Markdown
Contributor

Bus::DoState() restores the EXP1, EXP2, BIOS, CD-ROM, and SPU access timing arrays directly from save states. A crafted rollback state can set a negative timing value, which the recompiler later adds to CPU::g_state.pending_ticks in the unchecked memory access thunks. This can drive the tick counter backwards, trigger signed overflow, and prevent retro_run() from finishing, allowing a malicious netplay state to hang the frontend.

Read the timing arrays into temporary values, reject values outside the range produced by the emulated memory controller, and only commit them after validation. Staging the values also ensures a rejected rollback state cannot leave poisoned timing globals active while the system resets.

Save states restore memory access timing arrays without checking their
range. Crafted negative values can drive the CPU pending tick counter
backwards, causing signed overflow and preventing a frame from finishing.

Stage the arrays while reading and accept only values the emulated
memory controller can produce. Commit them after validation so a
rejected rollback state cannot leave poisoned timings active.
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.

1 participant