Use checked addition in console_insn and write_sites bounds checks #435
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
needs-logs
old-names
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/TaynanGT--Vice-Tay!435
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-435"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ahmetbagci8 on GitHub · 2026-11-29 10:48 UTC · original
ahmetbagci8:fix/loader-checked-bounds-overflow→main· +60053 −5432 · 206 files · 660 commits · closed without mergingSummary
Two unchecked
usizeadditions invictory-loadercan overflow on edge-case inputs:crates/victory-loader/src/console_insn.rs(readable/writable): called from theextern "system"VEH (emulate), where aclzerowithRaxin0xFFFF_FFFF_FFFF_FFC0..=u64::MAXoverflowsva + 64(panicking inside the VEH in debug builds, or wrapping in release).crates/victory-loader/src/write_sites.rs(apply): an entry inVICTORY_WRITE_SITESwith a hex offset inusize::MAX - 15..=usize::MAXoverflowsoffset + 16(panicking in debug, or wrapping past the> sizecheck and reading out of bounds in release).Changes
checked_addinconsole_insn::readable,console_insn::writable, andwrite_sites::apply.overflowing_ranges_do_not_panic_in_vehandoverflowing_offsets_are_ignored.Tested
cargo test -p victory-loader:73 passed; 0 failed; 0 ignoredcargo clippy -p victory-loader --tests: clean (0 warnings)@Kal0s-design on GitHub · 2026-11-29 11:20 UTC · original · reviewed
Ran this on Windows.
cargo test -p victory-loadergives 73 passed (70 lib + 3 in the other targets), both new tests included, andcargo clippy -p victory-loader --all-targets -D warningsis clean.The checks look right. In
apply,base + offsetafter the new check can't wrap any more sinceoffset + 16 <= size. Inreadable, the region end is now checked too, which the old code also added unchecked. The new VEH test goes through the wholeemulatepath withRax = u64::MAXand returns 0 instead of panicking in debug.AI-assisted: yes
@TaynanGT on GitHub · 2026-11-29 11:35 UTC · original
Thanks for the native Windows verification, especially the full VEH path with Rax at u64::MAX. The overflow cases need to fail safely rather than panic or access an invalid range. I'll keep this separate from unrelated loader changes.
@TaynanGT on GitHub · 2026-11-30 17:07 UTC · original
mainhas moved to a new line of the code and everything is now named Vice-Tay, so this PR no longer applies as it is (details in #468). If you'd like this change in, please rebuild it on the currentmainand open a new PR; I'll review it there.Pull request closed