Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSA Stack Inconsistencies #267

Open
l-kent opened this issue Oct 31, 2024 · 0 comments
Open

DSA Stack Inconsistencies #267

l-kent opened this issue Oct 31, 2024 · 0 comments
Assignees

Comments

@l-kent
Copy link
Contributor

l-kent commented Oct 31, 2024

StackLocations are only created in two places and there are inconsistencies with the semantics of their parameters.

Here, StackLocation's size parameter refers to the maximum access size, with the offset being part of the regionIdentifier:

node.allocationRegions.add(StackLocation(s"Stack_${proc}_$offset", proc, byteSize))

Here, StackLocation's size parameter refers to the negative of the offset from R31:

Map(d -> IdEdge(), Left(SymbolicAddress(variable, StackLocation(s"Stack_${procedure.name}", procedure, -size), 0)) -> ConstEdge(TwoElementTop))

There are also inconsistencies with the way indirect stack accesses and negative offsets are handled. For example, in indirect_calls/functionpointer/clang:BAP

000003cf: R31 := R31 - 0x30
000003d5: #4 := R31 + 0x20
000003db: mem := mem with [#4, el]:u64 <- R29
000003e1: mem := mem with [#4 + 8, el]:u64 <- R30
000003e7: R29 := R31 + 0x20
000003ee: mem := mem with [R29 - 4, el]:u32 <- 0
000003f6: mem := mem with [R29 - 8, el]:u32 <- 31:0[R0]
000003fd: R8 := pad:64[mem[R29 - 8, el]:u32]

The access at %000003ee is to R31 + 0x1C (28) and the access at %000003f6 is to R31 + 0x18 (24) but the DSA produces nodes containing StackLocations with ids Stack_main_18446744073709551640 and Stack_main_18446744073709551644, which are off from the correct offsets by 2^64. This seems to be caused by not treating the negative BitVecLiterals correctly when adding them - either overflow was not taken into account or they were not converted into negative values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants