Repository navigation
Fix/emulator rom offset validation - #402
Draft
networkfusion wants to merge 3 commits into
Draft
networkfusion wants to merge 3 commits into
networkfusion wants to merge 3 commits into
Conversation
rom_offset is parsed from an untrusted, user-editable INI file and cast directly to uint32_t. Flashcart loaders (sc64, 64drive, ed64 v/x-series) compute MiB(64) - rom_offset for a bounds check; if rom_offset exceeds MiB(64) this subtraction wraps to a huge value, making the check pass when it shouldn't and leading to an out-of-bounds SDRAM write via ROM_ADDRESS + rom_offset. Fix: reject any parsed rom_offset >= MiB(64) at the point of parsing, before it reaches the flashcart loaders.
load_file() (used for the rom_offset path) has no extended-addressing support in any flashcart implementation; it only ever writes within the primary 64MB SDRAM window. The 78MB ceiling only applies to full-ROM loading via load_rom(), a separate code path that doesn't use rom_offset.
Contributor
This branch has not been deployed
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.
Description
This PR just describes a potential fix. We need to actually fix the underlying issue!
rom_offset is parsed from an untrusted, user-editable INI file and cast
directly to uint32_t. Flashcart loaders (sc64, 64drive, ed64 v/x-series)
compute MiB(64) - rom_offset for a bounds check; if rom_offset exceeds
MiB(64) this subtraction wraps to a huge value, making the check pass
when it shouldn't and leading to an out-of-bounds SDRAM write via
ROM_ADDRESS + rom_offset.
Fix: reject any parsed rom_offset >= MiB(64) at the point of parsing,
before it reaches the flashcart loaders.
load_file() (used for the rom_offset path) has no extended-addressing
support in any flashcart implementation; it only ever writes within the
primary 64MB SDRAM window. The 78MB ceiling only applies to full-ROM
loading via load_rom(), a separate code path that doesn't use rom_offset.
Motivation and Context
How Has This Been Tested?
Screenshots
Types of changes
Checklist:
You agree with the license terms and that other license types may be granted with permission of the original
N64FlashcartMenuproject license holders.Signed-off-by: GITHUB_USER <GITHUB_USER_EMAIL>
Summary by CodeRabbit