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

Symbolic fuzzing #189

Merged
merged 5 commits into from
Apr 24, 2024
Merged

Symbolic fuzzing #189

merged 5 commits into from
Apr 24, 2024

Conversation

epatrizio
Copy link
Collaborator

Symbolic execution fuzzing first step : concrete context
Wasm modules have only concrete values and fuzzing checks that symbolic execution has the same behavior as concrete execution

test/fuzz/basic.ml Outdated Show resolved Hide resolved
test/fuzz/basic.ml Outdated Show resolved Hide resolved
test/fuzz/cond.ml Outdated Show resolved Hide resolved
@zapashcanon
Copy link
Member

IIUC, all the complexity with the new weird operators is here to allow ignoring some instructions in the symbolic case ? I guess it is because they have not been implemented yet ?

If that is the case, I'd prefer them to be actually implemented (even in an inefficient way) rather than adding all this complex machinery..

test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
@zapashcanon
Copy link
Member

zapashcanon commented Feb 23, 2024

OK so, before merging, I'd like some things to be fixed:

  • let's implement all basics instructions (either waiting for them to be in encoding or adding them in Owi when possible) like rotl, rotr etc. (https://github.com/formalsec/encoding/pull/80 has been merged so it should be easy :-))
  • once this is done, I believe most of the complexity added in the PR from cond.ml can be removed (even without supporting tables in symbolic mode);
  • let's try to see if completing the table support is hard or not (complete symbolic table implementation #190), I expect it to be quite straightforward, but if it's not, I'm fine about merging without it.

@filipeom
Copy link
Collaborator

filipeom commented Feb 23, 2024

let's implement all basics instructions (either waiting for them to be in encoding or adding them in Owi when possible) like rotl, rotr etc.

I fixed rotl, rotr, and trunc here: https://github.com/formalsec/encoding/pull/80.

ctz and popcnt are still missing in owi and in the encoding, so I suggest that for the time being we just concretely evaluate them in symbolic_value.ml.

@krtab
Copy link
Collaborator

krtab commented Feb 23, 2024

ctz and popcnt are still missing in owi and in the encoding, so I suggest that for the time being we just concretely evaluate them in symbolic_value.ml.

There may even be clever tricks where we make a decision tree based on Choice.choose to compute those.

@filipeom
Copy link
Collaborator

filipeom commented Feb 23, 2024

ctz and popcnt are still missing in owi and in the encoding, so I suggest that for the time being we just concretely evaluate them in symbolic_value.ml.

There may even be clever tricks where we make a decision tree based on Choice.choose to compute those.

Yes, this can be an efficient way to solve this. I'm worried it could cause too much branching? I can think of one unclever way to implement it without branching; we'd create massive if-then-else expressions:

 ; ctz summary for I32
 (ite (n = 0) 
   32
   (ite (not (n & 1 = 0))
     31
     (ite (not (n & 2 = 0)) 
       30
       ... 
         0))))

But this would probably grind z3 to a halt 😅

test/fuzz/basic.ml Outdated Show resolved Hide resolved
test/fuzz/basic.ml Outdated Show resolved Hide resolved
test/fuzz/basic.ml Outdated Show resolved Hide resolved
test/fuzz/basic.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
@krtab
Copy link
Collaborator

krtab commented Feb 26, 2024

Before merging, could you rebase it as one single commit ?

test/fuzz/basic.ml Outdated Show resolved Hide resolved
test/fuzz/basic.ml Outdated Show resolved Hide resolved
test/fuzz/basic.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
test/fuzz/gen.ml Outdated Show resolved Hide resolved
@zapashcanon
Copy link
Member

Thanks!

@zapashcanon zapashcanon merged commit f2bb374 into OCamlPro:main Apr 24, 2024
2 of 3 checks passed
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

Successfully merging this pull request may close these issues.

4 participants