Repository navigation
[AUTOMATED] find_subpiece_shadow: read a truncation past bit 63 of a constant as 0 instead of overflowing - #1683
Merged
Conversation
…r more bytes Funcdata::find_subpiece_shadow shifted a constant's 64-bit offset right by least_byte * 8. For a 16-byte constant tested at byte offset 8 that is a shift by 64: a panic in a build with overflow checks, a wrapped shift count otherwise. _dl_relocate_object in the mcount_x86_64 fixture failed to decompile in a dev build because of it. A constant wider than 8 bytes holds zero above bit 63, so the truncation now reads 0 there. Shifts below 64 are unchanged. Fixes Noelo-Lab#1674
…d profile The gh1674 stage test only fails without the fix in a build with overflow checks: a release build wraps the shift count, and for the constant 0 the wrapped shift reads the same 0. The unit test calls varnode_partial_copy_shadow on 16-byte constants directly, so it fails on the unfixed code under the test profile (the overflow panic) and also with a wrapping shift (an 8-byte piece at offset 8 of the 16-byte constant 0x1234 is not 0x1234). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
Contributor
|
[AUTOMATED] Pushed 7a8d712 on top of your branch: it adds the unit test |
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h # Conflicts: # decompiler/crates/kuna-base/src/xml.rs # docs/baseline-stages.json
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.
[AUTOMATED]
The problem
In a build with integer-overflow checks (the dev and test profiles),
_dl_relocate_objectfrom the in-repomcount_x86_64fixture comes back as an empty body. It is the only one of the fixture's 1074 functions that fails.The function zeroes a 16-byte stack slot (
pxor xmm0,xmm0; movaps [rbp-0x70],xmm0) and later writes the slot's high quadword fromrsi, which is0on one path. The merge intersection test then asks whether the 8-byte constant0is a partial copy shadow of the 16-byte constant0at byte offset 8.The fix
Funcdata::find_subpiece_shadowshifted the constant's 64-bit offset right byleast_byte * 8, which is 64 or more for a truncation of 8 or more bytes. The C++ original (Varnode::findSubpieceShadow) has the same shift, undefined there.With the fix
_dl_relocate_objectdecompiles to a 980-line body in about 1.6 s (dev build). On this function and on the new test, a build that wraps the shift count prints the same text as the fixed one, so builds without overflow checks show no output change here.The tests
tests/stages/gh1674-subpiece-shadow-wide-const.xml: a 28-instruction reduction of the same shape. Without the fix all 4 assertions fail in a dev build; with it all pass.Fixes #1674