Repository navigation
Conversation
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.
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.
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.