PoC: Add experimental masm-lint CI and fix core MASM findings#3052
PoC: Add experimental masm-lint CI and fix core MASM findings#3052huitseeker wants to merge 5 commits intonextfrom
Conversation
39618fc to
c2734f5
Compare
|
What is needed to use our own You mentioned that it is inferring type signatures? Static analysis can obviously check signatures to a limited extent, but inferring signatures would be all but useless due to over-approximation of types. I suspect that it's just computing stack effects (i.e. the number of felts that must have been on the operand stack on entry to be able to even do abstract interpretation at all, and how many remain on exit, and in both cases the values can be constrained to Anyway, that doesn't really have any bearing on this PR per se - but I do want this functionality to be provided via our own tooling that we're already working on, rather than splitting our efforts. I'll spend some time today integrating the TOB decompiler (or leveraging the analysis we already have in |
|
@bitwalker I was too coarse in the description. The interesting part I meant to describe is that
I have plans for how we can move this code somewhere maintained, better discussed elsewhere. |
757d29c to
32c4c0d
Compare
This adds a proof-of-concept masm-lint job for the core MASM library. This is not ready for merge: CI checks out the current main commits of trailofbits/masm-lsp and trailofbits/masm-decompiler, then applies the local masm-lsp patch until the upstream fixes land (trailofbits/masm-decompiler#5 and trailofbits/masm-lsp#3).
The decompiler matters because MASM is a stack machine, while the linter needs a value-based view of the code.
masm-decompilerlifts stack code into a structured SSA-like IR, infers procedure signatures, and builds type summaries.masm-lintuses that output throughmasm-analysis. Its advice pass runs a small fixpoint loop: it applies a transfer step, joins the new state into the current one, and repeats until the state stops changing or hits a hard cutoff.The findings in this PR were small but real (see prior #3021 for issues found using the same tools, but fixed before this PR):
u256::eqzhad the wrong declared signature.word::testzandword::test_eqnow delegate to the canonical word equality helpers.sys::drop_stack_topnow declares the full stack shape it consumes.fri::preprocessnow asserts that the query and remainder counters areu32values, and the new tests cover those failures.sorted_arraynow proves its memory pointers and pointer arithmetic areu32before they reach memory and alignment-sensitive ops.