Giter Club home page Giter Club logo

Comments (2)

Hhro avatar Hhro commented on July 17, 2024 1

Abstraction doesn't happen during the Alive2.
Here are the detailed steps to TV the example. Hope it could help:

[Get final-state of src]

  1. foo (int x):
    Alive2 assumes that function arguments can be arbitrary values, so they can be undef, poison, or well-defined value.
    It can be encoded into:
    (= %x ((ite isundef(%x) undef %x), ispoison(%x)))
    FYI, x is an SMT bitvector

  2. y=(x+0):
    By the defined semantics of add, following holds:
    a) x = poison -> y = poison
    b) x = {n} -> y = {n + 0} = {n}
    c) x = undef -> y = {n + 0 | -2^31 <= n <= 2^31}
    It can be encoded into:
    (= %y ((ite isundef(%x) undef %x) + 0, ispoison(%x)))

    Note that, in alive2, the value could be a poison, set of integer/floating-point numbers or pointers. And the set of values is not a singleton if the value is undef.

  3. return y:
    End the execution and emit the final-state <y, empty, false>. Note that the definition of the final-state is ValueNoRet x Memory x bool, in which each of them represents return value, memory, and whether the undefined behavior has occurred or not.

[Get final-state of tgt]
Same above, the final-state of the target is <y, empty, false>

[Check the refinement]
Since no operation manipulates the memory or triggers the UB, this example can be validated by only checking the refinement between the return values.

Let's rename the return value to avoid confusion.

  • y_src: return value of src
  • y_tgt: return value of tgt

Then we can say that, for all valid input, if y_tgt is a refinement of the y_src, then the target function is a refinement of the source.

Therefore if the following condition is true, the target function is a refinement of the source function(=, <= are symbols of set):

ispoison(y_tgt)
\/ (isdefined(y_src) /\ isdefined(y_tgt) /\ y_src = y_tgt)
\/ (isundef(y_src) /\ (y_tgt <= y_src))

And it could be checked by the off-the-shelf SMT solver like Z3.

from is661-advanced-software-security.

AnHaechan avatar AnHaechan commented on July 17, 2024

Thanks for the detailed response!

from is661-advanced-software-security.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.