Giter Club home page Giter Club logo

staticafi / symbiotic Goto Github PK

View Code? Open in Web Editor NEW
300.0 12.0 55.0 2.14 MB

Symbiotic is a tool for finding bugs in computer programs based on instrumentation, program slicing and KLEE

Home Page: http://staticafi.github.io/symbiotic/

License: MIT License

Shell 9.56% Python 55.07% C 10.62% CMake 0.76% C++ 23.53% Makefile 0.01% SWIG 0.12% Dockerfile 0.11% Assembly 0.23%
verification verification-toolchain symbolic-execution program-slicing slicing klee llvm instrumentation slice llvm-ir program-verification software-verification

symbiotic's People

Contributors

acalabek avatar kdudka avatar lembergerth avatar lzaoral avatar mchalupa avatar michalhe avatar moroxus avatar msimacek avatar strejcek avatar tomsik68 avatar trtikm avatar xvitovs1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

symbiotic's Issues

metabug: incorrect answers

This bug is for gathering information about Symbiotic's incorrect answers

  • heap-manipulation/dll_of_dll_true-unreach-call.i #27
  • loop-invgen/heapsort_true-unreach-call.i #28

  • bug in floats #16

Reuse 32-bit lib.o

We have lib/ and lib32/ directories now, so we can create lib/lib.o lib32/lib.o and reuse it instead of re-compiling it for each benchmark again

lib.c: missing functions

strncmp
strcmp (??)
strchr (??)
strstr

mutexes && kfree (will be done by new instrumentation)

symbiotic: try slicing twice

slicing the code that has been already sliced does not remove anything (that's good), but if we optimize the code after slicing with opt and stuff like constant propagation and such, then the code can be sliced again with a positive number of nodes removed

try if that's worth it at all

symbiotic: check klee's return code

recently I discovered, that something like this is evaluated to TRUE:

RESULT: DBG: terminate called after throwing an instance of 'std::bad_alloc'
RESULT: DBG: what(): std::bad_alloc
RESULT: DBG: 0 klee 0x0000000000e5b945 llvm::sys::PrintStackTrace(_IO_FILE*) + 37
RESULT: DBG: 1 klee 0x0000000000e5bd93
RESULT: DBG: 2 libpthread.so.0 0x00007f3e2c7d0340
RESULT: DBG: 3 libc.so.6 0x00007f3e2b76bcc9 gsignal + 57
RESULT: DBG: 4 libc.so.6 0x00007f3e2b76f0d8 abort + 328
RESULT: DBG: 5 libstdc++.so.6 0x00007f3e2c0a678d __gnu_cxx::__verbose_terminate_handler() + 349
RESULT: DBG: 6 libstdc++.so.6 0x00007f3e2c0a47f6
RESULT: DBG: 7 libstdc++.so.6 0x00007f3e2c0a4841
RESULT: DBG: 8 libstdc++.so.6 0x00007f3e2c0a4a58
RESULT: DBG: 9 libstdc++.so.6 0x00007f3e2c0a4f5c
RESULT: DBG: 10 libstdc++.so.6 0x00007f3e2c0a4fb9 operator new[](unsigned long) + 9
RESULT: DBG: 11 klee 0x00000000005f05b7 klee::PathLocation::PathLocation(std::basic_ifstream >&) + 71
RESULT: DBG: 12 klee 0x00000000005f1181 klee::TreeStreamWriter::readStream(unsigned int, std::vector >&) + 1409
RESULT: DBG: 13 klee 0x000000000054e181
RESULT: DBG: 14 klee 0x0000000000555c56 klee::Executor::terminateStateOnExit(klee::ExecutionState&) + 38
RESULT: DBG: 15 klee 0x0000000000561fc6 klee::Executor::executeInstruction(klee::ExecutionState&, klee::KInstruction*) + 13654
RESULT: DBG: 16 klee 0x0000000000563966 klee::Executor::run(klee::ExecutionState&) + 1654
RESULT: DBG: 17 klee 0x0000000000564211 klee::Executor::runFunctionAsMain(llvm::Function*, int, char**, char**) + 1681
RESULT: DBG: 18 klee 0x0000000000537c51 main + 7921
RESULT: DBG: 19 libc.so.6 0x00007f3e2b756ec5 __libc_start_main + 245
RESULT: DBG: 20 klee 0x000000000054b9e1

instead of only matching patterns in klee's output, check even for the return code and say error when somthing like this happens

klee does not distinguish between out of memory and overlap

file as a bug for klee

  1 #include <assert.h>
  2 #define N 1000000000
  3 
  4 int main(void)
  5 {
  6   int a[N];
  7   int max = 0;
  8   int i = 0;
  9   while (i < N) {
 10     if (a[i] > max)
 11       max = a[i];
 12       ++i;
 13   }
 14 
 15   int x;
 16   for ( x = 0 ; x < N ; x++ )
 17     assert(a[x] <= max);
 18 
 19   return 0;
 20 }

This program makes klee to write out out of bound pointer, while it is perfectly ok. It is due to states overlap (Executor.cpp:3236). Klee does not distinguish between out of bound and overlap -> file it as a bug for klee

signals handling?

how is it with handling POSIX signals? ... it is more or less like threaded application, so nothing for symbiotic now...

O2 optimizations break this code

  1 int *getelem(int array[10], int idx)
  2 {
  3         __VERIFIER_assert(idx >= 0 && idx < 10);
  4         return &array[idx];
  5 }
  6 
  7 int main(void)
  8 {
  9         int array[10] = { 0 };
 10 
 11         for (int i = 0; i < 1000; ++i) {
 12                 int *p = getelem(array, rand() % 11);
 13                 *p = 1;
 14         }
 15 
 16         doit(array);
 17         return 0;
 18 }

with --optimizations=before-O2,after we get TRUE, without it we get FALSE (correct)

strdup can never fail

strdup can never fail - change libc such that there will be a macro 'MALLOC_NEVER_FAILS' and this macro will cause conditional compilation of lib.c
This way we'll have just one version of __VERIFIER_malloc() function

floats bugs [cz]

  • floats-cbmc-regression/float14_true-unreach-call.i prepare odstrani __isinff, bez prepare da klee spravny vysledek
  • floats-cbmc-regression/float4_true-unreach-call.i klee vola __isnan a __isinf s argumentem 0 (konkretizoval?)
  • floats-cbmc-regression/float4_true-unreach-call.i prepare odstrani volani __isinf - klee bez prepare spadne na nepodporovane instrukci
  • floats-cbmc-regression/float-rounding1_true-unreach-call.i prepare odstrani fesetround, ale klee da spatny vysledek jak s prepare tak bez prepare

bug with optimizations

This code should result in TRUE, but is FALSE with optimizations 'before' (without opts or without slicing it is fine)

#include <assert.h>

int a = 0;
int *p = ((void *) 0); 

void set(void)
{
        if (!a)
                p = &a; 
        else
                p = ((void *) 0); 
}

int main(void)
{
        int b = 2;
        if (a > b) {
                set();
                *p = 3;
        } else {
                set();
                *p = 4;
        }

        assert(a == 4); 
        return 0;
}

klee's bug (investigate and report to klee)

klee reports TRUE for this code (once we remove the loop, it reports FALSE). It reports TRUE without any optimizations, so there should be no problem with n being unspecified (with opts it gets correct)

#include <assert.h>

int main()
{
        int a;
        int n;

        if( n < 0 ) 
                return 0;

        for(; n < 100; n++) {
        }

        ++n;
        a = 2;
        assert(a == 3); 

        return 0;
}

lib.c correctness?

there are some hard-coded data types, like:
typedef unsigned int size_t

this could break something, fix it! (conditional compilation)

TODO

  • add verifier missing types (mainly __VERIFIER_nondet_bool)
  • slicer sigsegv removing undef - fix the undef!
  • when slicer do not find slicing criterion, say TRUE
  • add klee_assume() to all malloc + calloc calls (that the pointer is not null)
  • make EGENERAL bound to KLEE: ERROR: not to 'now ignoring error on this loca'
  • fix truncateToNBits bug in klee

merge svc15 to symbiotic

There are just few files and the scripts are going to be rewritten into python later, so svc15 will be almost empty

runme: remove wrong while

when parsing klee we do while read LINE, but then we dont use the line. I'm surprised it works... Just remove it and let the input go to grep

catch broken modules

if slicer breaks the module, say error or unknown (when slicer required) or use the original (when slicer is not required)

RESULT: DBG: = ptrtoint to label
RESULT: DBG: br i1 %26, label , label %30
RESULT: DBG: Broken module found, verification continues.
RESULT: DBG: Instruction does not dominate all uses!

create new symbiotic build script

rename the old to blah-blah-external or something like that and make the new use submodules as it will be easier to fetch and compile them

add regression tests

add tests to symbiotic project that will test regressions, like:

__VERIFIER_assert(isdigit('1'))

and similar (this code was not working before)

prepare failed

These two benchmarks has 'Prepare phase failed'

ntdrivers/cdaudio_true-unreach-call.i.cil.c
ntdrivers/cdaudio_false-unreach-call.i.cil.c

Fix initializing globals

Undefined globals should be made symbolic, why isn't it working?

KLEE: ERROR: unable to load symbol(xen_xenbus_fops) while initializing globals.
KLEE: ERROR: unable to load symbol(BATERY_GAIN) while initializing globals.

remove invalid aborts

if somebody checks for returned value from malloc we say unknown just for that (because we hit abort failure)

if ((mem = malloc(...)) == NULL)
   abort();

we can replace abort with klee_assume()

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.