Loader: validate TLS pointers and bounds in OwnTls #3367
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3367
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3367"
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?
@Arkenoz on GitHub · 2026-11-26 20:38 UTC · original
Arkenoz:fix/own-tls-validation→main· +161 −10 · 1 files · 1 commits · openTracked in #1633.
Problem
In
crates/victory-loader/src/threads.rs,OwnTls::save()dereferencedTEB.ThreadLocalStoragePointer(gs:[0x58]),(*dir).index, and*array.add(slot)without null checks, and computed the TLS block length with unchecked arithmetic ((*dir).end - (*dir).start + (*dir).zero_fill as usize).Changes
save_from(array, dir) -> Option<OwnTls>helper that validates non-nullarray,dir,(*dir).index, and resolvedblock, computes the block length withchecked_sub/checked_add, and returnsNonefor zero-length or invalid bounds.OwnTls::save()to delegate tosave_fromandon_threadto only restore whenSome(saved)is returned.OwnTls::restore()against nullblockor emptysaved.threads::testscovering null pointers, invalid bounds/overflow/zero length, and synthetic TLS save/restore round-trip.Verification
cargo test -p victory-loader(38 unit + 4 integration tests passed)cargo clippy -p victory-loader --all-targets(0 warnings)AI-assisted with Gemini.
@Dukestar69 on GitHub · 2026-11-26 20:49 UTC · original · approved these changes
LGTM — verified on Windows against
origin/main(63bcca4).array,dir,dir.index, andblockfor null and usingchecked_sub/checked_addfor the TLS block length cleanly guardsOwnTls::saveandOwnTls::restoreagainst invalid TLS pointers or overflowing bounds.cargo test -p victory-loader --lib threads:: -- --test-threads=1: 5 passed, 0 failed (includingown_tls_save_rejects_null_pointers,own_tls_save_rejects_invalid_bounds_and_lengths, andown_tls_save_and_restore_preserves_state).cargo clippy -p victory-loader --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.