Repository navigation
Conversation
…verflow carrier_template_size_for computed `(n + 15) & !15` before clamping, overflowing u64 when `total_len > u64::MAX - 15` (and its upper bound `u32::MAX - 0x10000` was not 16-byte aligned). build_carrier_dll_with only clamped at the lower bound `max(16)`, so large `template_size` values overflowed u32 in `OFF_TEMPLATE + template_size`, `DATA_RVA + data_vsize + 0xFFF`, and `va(OFF_TEMPLATE + template_size)`. Define `MAX_CARRIER_TEMPLATE = (u32::MAX - 0x10000) & !15` and clamp to `[16, MAX_CARRIER_TEMPLATE]` in both functions, with a unit test. Assisted-by: OpenCode (Gemini 4 Neon)
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Test report for Tested
Regression run (retail title, main: this PR: Not tested
AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request. |
…v#1403) Live head ce99e53 still OPEN (merge-base --is-ancestor vs upstream/main exit 1). tls.rs is cfg(windows)-only: const MAX_CARRIER_TEMPLATE + clamp in carrier_template_size_for + build_carrier_dll_with + upstream test land verbatim - tree-vs-head diff on the file is zero (pre-change tree matched the PR parent byte-for-byte). tls_linux.rs has no carrier DLL (blocks come straight from alloc_zeroed; install already rejects oversize via usize::try_from + Layout::from_size_align) so the overflow class cannot occur there - pin test only: huge total_len is a clean Err, no panic, no allocation, no slot consumed. Failing-first: old formula grafted to a standalone harness panics in debug (attempt to add with overflow at (n+15)); new formula clamps to 0xFFFEFFF0 (16-aligned, OFF_TEMPLATE+MAX fits u32). Gates: both cargo checks 0 errors; lib 746/0/1 threads=4 (+1 pin test); title e2e 12 unique FAILs all D3D12.X GPU-only 0 non-GPU; retail fresh-root exit 139 SIGSEGV game_scarlett_master.exe+0x2237320, stubs 20, xgr 3 apis, unmapped [] - HOLDS, M1-RE TERMINAL. Lock audit: 0 new lock() lines.
…cl-dev#1431) Port upstream xcl-dev#1431 (live head 8052b9c, still OPEN): carrier template sizing with alignment + 0xFFFE_0000 cap, Characteristics align encode/decode 1..8192, .data offset fix for align>256, null and NO_INDEX guards, register-after-load with uninstall on failure, and plumbing t.characteristics into tls_install. tls.rs + loader.rs land verbatim (Windows-only); the xcl-dev#1403 build-clamp pin test is retained (still passes under the stricter cap). Linux twin: ImageSpec/PendingTls carry characteristics, blocks allocate with the decoded alignment (floor 16), index writes use write_unaligned, alloc guards null templates, uninstall() drops the registry entry and detaches blocks; init_dll/load_game_dll uninstall on failure. The template-exceeds-block check stays fail-closed (strictly stronger than upstream max()).
|
Nothing has happened on this PR for 3 days, so it is marked |
|
merge-check claim |
|
merge-check |
|
merge-check
|
|
#196 contains the same clamp in tls.rs::carrier_template_size_for / build_carrier_dll_with (total_len.clamp(16, MAX_CARRIER_TEMPLATE)) as part of a 500-line TLS alignment and locking rework, and #1431 caps the size through a new carrier_template_size_aligned helper. This PR is the overflow fix on its own, with a test. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
carrier_template_size_forcomputed(n + 15) & !15before clamping, overflowingu64whentotal_len > u64::MAX - 15(and its upper boundu32::MAX - 0x10000was not 16-byte aligned).build_carrier_dll_withonly clamped at the lower bound (template_size.max(16)), so largetemplate_sizevalues overflowedu32inOFF_TEMPLATE + template_size,DATA_RVA + data_vsize + 0xFFF, andva(OFF_TEMPLATE + template_size).This defines
MAX_CARRIER_TEMPLATE = (u32::MAX - 0x10000) & !15and clamps to[16, MAX_CARRIER_TEMPLATE]in both functions.What is in it
crates/xcl/src/tls.rs: clamp to[16, MAX_CARRIER_TEMPLATE]incarrier_template_size_forandbuild_carrier_dll_with; add unit testcarrier_size_and_build_clamp_without_overflow(verified panicking onu64addition overflow before the fix).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib tls::tests: 5 passed, 0 failed, 1 ignored (carrier_size_and_build_clamp_without_overflowpanicked before the fix)Regression run
main:
PR:
Not tested
AI use
tls.rs, wrote the fix and unit test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.