diff --git a/.gitignore b/.gitignore index 0972a0f..5664b31 100644 --- a/.gitignore +++ b/.gitignore @@ -58,16 +58,10 @@ core # will have compiled files and executables /target/ -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - # These are backup files generated by rustfmt **/*.rs.bk - # Systrace specific things - bin/reverie tests/clock-nanosleep tests/forkExec @@ -95,18 +89,5 @@ tests/threads6 tests/threads7 tests/write-many tests/x64-save-return-address -examples/counter/src/ffi.rs -examples/counter/src/consts.rs -examples/echo/src/ffi.rs -examples/echo/src/consts.rs -examples/det/src/ffi.rs -examples/det/src/consts.rs -examples/none/src/ffi.rs -examples/none/src/consts.rs src/nr.rs syscalls/src/nr.rs -tools_helper/src/consts.rs -tools_helper/src/profiling.rs -tools_helper/src/state.rs -tools_helper/src/local_state.rs -preloader/src/consts.rs diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..9a66264 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,768 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "adler32" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "approx" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "atty" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "autocfg" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bitflags" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "c2-chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "cc" +version = "1.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cfg-if" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cgmath" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "approx 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "chrono" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "clap" +version = "2.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "colored" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winconsole 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "counter" +version = "0.1.0" +dependencies = [ + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "reverie-helper 0.1.0", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "det" +version = "0.1.0" +dependencies = [ + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "reverie-helper 0.1.0", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "echo" +version = "0.1.0" +dependencies = [ + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "reverie-helper 0.1.0", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fern" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-cprng" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "getrandom" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "wasi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "goblin" +version = "0.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "itoa" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libc" +version = "0.2.62" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "libflate" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rle-decode-fast 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "log" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nix" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nix" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "none" +version = "0.1.0" +dependencies = [ + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "reverie-helper 0.1.0", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-integer" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "num-traits" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ppv-lite86" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "proc-macro2" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "procfs" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "libflate 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "quote" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_chacha" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rand_core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rdrand" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.56" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "remove_dir_all" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "reverie" +version = "0.1.0" +dependencies = [ + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", + "colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fern 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", + "goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "procfs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "reverie-common 0.1.0", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "syscalls 0.1.0", + "sysnum 0.1.0", +] + +[[package]] +name = "reverie-common" +version = "0.1.0" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "reverie-helper" +version = "0.1.0" +dependencies = [ + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)", + "reverie-common 0.1.0", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", + "syscalls 0.1.0", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "reverie-preloader" +version = "0.1.0" +dependencies = [ + "cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)", + "procfs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "reverie-common 0.1.0", + "syscalls 0.1.0", +] + +[[package]] +name = "rgb" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rle-decode-fast" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ryu" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "scroll" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "scroll_derive" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "serde" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "serde_derive 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_derive" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "serde_json" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syn" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "syscalls" +version = "0.1.0" +dependencies = [ + "sysnum 0.1.0", +] + +[[package]] +name = "sysnum" +version = "0.1.0" +dependencies = [ + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "take_mut" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "time" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-width" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicode-xid" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "vec_map" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "wasi" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winconsole" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cgmath 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rgb 0.8.14 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[metadata] +"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum approx 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08abcc3b4e9339e33a3d0a5ed15d84a687350c05689d825e0f6655eef9e76a94" +"checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" +"checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875" +"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum c2-chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7d64d04786e0f528460fc884753cf8dddcc466be308f6026f8e355c41a0e4101" +"checksum cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff" +"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" +"checksum cgmath 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "64a4b57c8f4e3a2e9ac07e0f6abc9c24b6fc9e1b54c3478cfb598f3d0023e51c" +"checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe" +"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +"checksum colored 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6cdb90b60f2927f8d76139c72dbde7e10c3a2bc47c8594c9c7a66529f2687c03" +"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" +"checksum fern 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "29d26fa0f4d433d1956746e66ec10d6bf4d6c8b93cd39965cceea7f7cc78c7dd" +"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "fc344b02d3868feb131e8b5fe2b9b0a1cc42942679af493061fc13b853243872" +"checksum goblin 0.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "e3fa261d919c1ae9d1e4533c4a2f99e10938603c4208d56c05bec7a872b661b0" +"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" +"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" +"checksum libflate 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "d9135df43b1f5d0e333385cb6e7897ecd1a43d7d11b91ac003f4d2c2d2401fdd" +"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" +"checksum nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4dbdc256eaac2e3bd236d93ad999d3479ef775c863dbda3068c4006a92eec51b" +"checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce" +"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" +"checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" +"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" +"checksum plain 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b" +"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +"checksum proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c5c2380ae88876faae57698be9e9775e3544decad214599c3a6266cca6ac802" +"checksum procfs 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7fedbab4f73bb05650bf3a74a925f6f0351f6978303e0b9570d3b677cbbde4c7" +"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" +"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +"checksum rand 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d47eab0e83d9693d40f825f86948aa16eff6750ead4bdffc4ab95b8b3a7f052c" +"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" +"checksum rand_core 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" +"checksum rand_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "615e683324e75af5d43d8f7a39ffe3ee4a9dc42c5c701167a71dc59c3a493aca" +"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +"checksum rgb 0.8.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2089e4031214d129e201f8c3c8c2fe97cd7322478a0d1cdf78e7029b0042efdb" +"checksum rle-decode-fast 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cabe4fa914dec5870285fa7f71f602645da47c486e68486d2b4ceb4a343e90ac" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" +"checksum scroll 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2f84d114ef17fd144153d608fba7c446b0145d038985e7a8cc5d08bb0ce20383" +"checksum scroll_derive 0.9.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1aa96c45e7f5a91cb7fabe7b279f02fea7126239fc40b732316e8b6a2d0fcb" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +"checksum serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "fec2851eb56d010dc9a21b89ca53ee75e6528bab60c11e89d38390904982da9f" +"checksum serde_derive 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "cb4dc18c61206b08dc98216c98faa0232f4337e1e1b8574551d5bad29ea1b425" +"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704" +"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf" +"checksum take_mut 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f764005d11ee5f36500a149ace24e00e3da98b0158b3e2d53a7495660d3f4d60" +"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +"checksum unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20" +"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" +"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum wasi 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fd5442abcac6525a045cc8c795aedb60da7a2e5e89c7bf18a0d5357849bb23c7" +"checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum winconsole 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ef84b96d10db72dd980056666d7f1e7663ce93d82fa33b63e71c966f4cf5032" diff --git a/Cargo.toml b/Cargo.toml index ee9cc29..e2137ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,36 +1,3 @@ -[package] -name = "reverie" -version = "0.1.0" -authors = ["Baojun Wang "] -edition = "2018" - [workspace] -members= [".", "syscalls", "tools_helper", "preloader", "examples/none", "examples/echo", "examples/counter", "examples/det" ] -default-members = [".", "syscalls", "preloader", "tools_helper" ] - -[lib] -name = "reverie" -path = "src/lib.rs" - -[[bin]] -name = "reverie" -path = "src/main.rs" - -[dependencies] -libc = { version = "0.2", default-features = false } -syscalls = { path = "syscalls" } -nix = "0.13" -goblin = "0.0" -procfs = "0.5" -clap = "2.32" -lazy_static = "1.3" -colored = "1.7" -chrono = "0.4" -log = "0.4" -fern = "0.5" -serde = { version = "1.0", features = [ "derive" ] } -serde_json = "1.0" - -[build-dependencies] -cc = "1.0" -sysnum = { path = "sysnum" } +members= ["reverie", "syscalls", "reverie-helper", "reverie-common", "reverie-preloader", "examples/none", "examples/echo", "examples/counter", "examples/det" ] +default-members = ["reverie", "syscalls", "reverie-common", "reverie-preloader" ] diff --git a/Makefile b/Makefile index 164ac6c..85eab15 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ all: $(MAKE) -C tests all @cargo build $(WAY) --all @cargo build --manifest-path examples/echo/Cargo.toml --target-dir=target - @cp -v target/$(TARGETDIR)/libpreloader.so lib/ + @cp -v target/$(TARGETDIR)/libreverie_preloader.so lib/ @cp -v target/$(TARGETDIR)/libecho.so lib/ @cp -v target/$(TARGETDIR)/libnone.so lib/ @cp -v target/$(TARGETDIR)/libcounter.so lib/ diff --git a/examples/counter/Cargo.toml b/examples/counter/Cargo.toml index 15af72e..aaaf350 100644 --- a/examples/counter/Cargo.toml +++ b/examples/counter/Cargo.toml @@ -10,8 +10,7 @@ crate-type = ["cdylib"] path = "src/lib.rs" [dependencies] -syscalls = { path = "../../syscalls" } -tools_helper = { path = "../../tools_helper" } +reverie-helper = { path = "../../reverie-helper" } log = { version = "0.4", default-features = false } [build-dependencies] diff --git a/examples/counter/build.rs b/examples/counter/build.rs deleted file mode 100644 index 8af2661..0000000 --- a/examples/counter/build.rs +++ /dev/null @@ -1,37 +0,0 @@ -use cc; -use std::fs::File; -use std::io::{Result, Write}; -use std::path::Path; - -fn main() -> Result<()> { - cc::Build::new() - .define("_POSIX_C_SOURCE", "20180920") - .define("_GNU_SOURCE", "1") - .define("USE_SAVE", "1") - .flag("-fPIC") - .include("../../include") - .include("../../trampoline") - .file("../../trampoline/trampoline.S") - .file("../../trampoline/raw_syscall.S") - .file("../../trampoline/remote_call.S") - .compile("my-trampoline"); - - let cwd = std::env::current_dir()?; - let src_files: Vec<_> = vec![ std::fs::canonicalize("../../trampoline/ffi.rs").unwrap(), - std::fs::canonicalize("../../src/consts.rs").unwrap()]; - let dst_dir = std::fs::canonicalize(cwd.join("src"))?; - - src_files.iter().for_each(|f| { - let do_copy: Box Result<()>> = Box::new(|| { - let p = Path::new(&f).file_name().unwrap(); - let mut src = File::open(f)?; - let mut dst = File::create(dst_dir.join(p))?; - let header = format!("// AUTOMATICALLY GENERATED by build.rs by copying {:?}. DO NOT EDIT.\n\n", dst_dir.join(p)); - dst.write_all(header.as_bytes())?; - std::io::copy(&mut src, &mut dst)?; - Ok(()) - }); - do_copy().expect("failed to copy files"); - }); - Ok(()) -} diff --git a/examples/counter/src/lib.rs b/examples/counter/src/lib.rs index 9fb47df..2f71ed2 100644 --- a/examples/counter/src/lib.rs +++ b/examples/counter/src/lib.rs @@ -6,10 +6,7 @@ #[allow(unused_imports)] use std::ffi::CStr; -use tools_helper::*; -use syscalls::*; - -pub mod ffi; +use reverie_helper::{ syscalls::*, counter::*, common::local_state::ProcessState, logger }; #[cfg_attr(target_os = "linux", link_section = ".ctors")] #[used] diff --git a/examples/det/Cargo.toml b/examples/det/Cargo.toml index d247333..9cb43fb 100644 --- a/examples/det/Cargo.toml +++ b/examples/det/Cargo.toml @@ -10,8 +10,7 @@ crate-type = ["cdylib"] path = "src/lib.rs" [dependencies] -syscalls = { path = "../../syscalls" } -tools_helper = { path = "../../tools_helper" } +reverie-helper = { path = "../../reverie-helper" } log = { version = "0.4", default-features = false } libc = { version = "0.2", default-features = false } diff --git a/examples/det/build.rs b/examples/det/build.rs deleted file mode 100644 index 8af2661..0000000 --- a/examples/det/build.rs +++ /dev/null @@ -1,37 +0,0 @@ -use cc; -use std::fs::File; -use std::io::{Result, Write}; -use std::path::Path; - -fn main() -> Result<()> { - cc::Build::new() - .define("_POSIX_C_SOURCE", "20180920") - .define("_GNU_SOURCE", "1") - .define("USE_SAVE", "1") - .flag("-fPIC") - .include("../../include") - .include("../../trampoline") - .file("../../trampoline/trampoline.S") - .file("../../trampoline/raw_syscall.S") - .file("../../trampoline/remote_call.S") - .compile("my-trampoline"); - - let cwd = std::env::current_dir()?; - let src_files: Vec<_> = vec![ std::fs::canonicalize("../../trampoline/ffi.rs").unwrap(), - std::fs::canonicalize("../../src/consts.rs").unwrap()]; - let dst_dir = std::fs::canonicalize(cwd.join("src"))?; - - src_files.iter().for_each(|f| { - let do_copy: Box Result<()>> = Box::new(|| { - let p = Path::new(&f).file_name().unwrap(); - let mut src = File::open(f)?; - let mut dst = File::create(dst_dir.join(p))?; - let header = format!("// AUTOMATICALLY GENERATED by build.rs by copying {:?}. DO NOT EDIT.\n\n", dst_dir.join(p)); - dst.write_all(header.as_bytes())?; - std::io::copy(&mut src, &mut dst)?; - Ok(()) - }); - do_copy().expect("failed to copy files"); - }); - Ok(()) -} diff --git a/examples/det/src/lib.rs b/examples/det/src/lib.rs index 6805079..082096c 100644 --- a/examples/det/src/lib.rs +++ b/examples/det/src/lib.rs @@ -2,8 +2,7 @@ #![allow(unused_imports)] #![allow(unused_attributes)] -use tools_helper::*; -use syscalls::*; +use reverie_helper::{syscalls::*, counter::*, common::local_state::ProcessState, logger}; use log::*; #[allow(unused_imports)] @@ -15,8 +14,6 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use libc; -pub mod ffi; - #[link_section = ".init_array"] #[used] static ECHO_DSO_CTORS: extern fn() = { @@ -40,10 +37,10 @@ pub extern "C" fn captured_syscall( a5: i64, ) -> i64 { note_syscall(p, no, NoteInfo::SyscallEntry); - let sc = syscalls::SyscallNo::from(no); + let sc = SyscallNo::from(no); #[allow(unused_assignments)] let mut res = -38; // ENOSYS - + match sc { SYS_gettimeofday => { let tick = LOGICAL_TIME.fetch_add(1, Ordering::SeqCst) as i64; diff --git a/examples/echo/Cargo.toml b/examples/echo/Cargo.toml index c93007e..9a2b56a 100644 --- a/examples/echo/Cargo.toml +++ b/examples/echo/Cargo.toml @@ -10,8 +10,7 @@ crate-type = ["cdylib"] path = "src/lib.rs" [dependencies] -syscalls = { path = "../../syscalls" } -tools_helper = { path = "../../tools_helper" } +reverie-helper = { path = "../../reverie-helper" } log = { version = "0.4", default-features = false } serde = { version = "1.0", default-features = false, features = [ "derive" ] } libc = { version = "0.2", default-features = false, features = [] } diff --git a/examples/echo/build.rs b/examples/echo/build.rs deleted file mode 100644 index 8af2661..0000000 --- a/examples/echo/build.rs +++ /dev/null @@ -1,37 +0,0 @@ -use cc; -use std::fs::File; -use std::io::{Result, Write}; -use std::path::Path; - -fn main() -> Result<()> { - cc::Build::new() - .define("_POSIX_C_SOURCE", "20180920") - .define("_GNU_SOURCE", "1") - .define("USE_SAVE", "1") - .flag("-fPIC") - .include("../../include") - .include("../../trampoline") - .file("../../trampoline/trampoline.S") - .file("../../trampoline/raw_syscall.S") - .file("../../trampoline/remote_call.S") - .compile("my-trampoline"); - - let cwd = std::env::current_dir()?; - let src_files: Vec<_> = vec![ std::fs::canonicalize("../../trampoline/ffi.rs").unwrap(), - std::fs::canonicalize("../../src/consts.rs").unwrap()]; - let dst_dir = std::fs::canonicalize(cwd.join("src"))?; - - src_files.iter().for_each(|f| { - let do_copy: Box Result<()>> = Box::new(|| { - let p = Path::new(&f).file_name().unwrap(); - let mut src = File::open(f)?; - let mut dst = File::create(dst_dir.join(p))?; - let header = format!("// AUTOMATICALLY GENERATED by build.rs by copying {:?}. DO NOT EDIT.\n\n", dst_dir.join(p)); - dst.write_all(header.as_bytes())?; - std::io::copy(&mut src, &mut dst)?; - Ok(()) - }); - do_copy().expect("failed to copy files"); - }); - Ok(()) -} diff --git a/examples/echo/src/dpc.rs b/examples/echo/src/dpc.rs index 0b62a53..cb943db 100644 --- a/examples/echo/src/dpc.rs +++ b/examples/echo/src/dpc.rs @@ -1,12 +1,9 @@ //! deferred precedure calls //! -use syscalls::syscall; +use reverie_helper::{ common::consts, syscalls::syscall, logger} ; use log::debug; -use crate::consts; -use crate::logger; - const DPC_PREFIX: &'static str = "/tmp/dpc-task."; const PF_UNIX: i32 = 1; diff --git a/examples/echo/src/entry.rs b/examples/echo/src/entry.rs index d6d8df0..ea92f19 100644 --- a/examples/echo/src/entry.rs +++ b/examples/echo/src/entry.rs @@ -1,11 +1,13 @@ //! echo entrypoint who defines `captured_syscall` //! -use syscalls::*; -use tools_helper::*; use crate::show::*; -use crate::counter::{note_syscall, NoteInfo}; -use crate::local_state::{ProcessState, ThreadState}; +use reverie_helper::syscalls::*; +use reverie_helper::counter::{note_syscall, NoteInfo}; +use reverie_helper::common::local_state::{ProcessState, ThreadState}; + +use reverie_helper::logger::*; +use reverie_helper::*; #[macro_export(smsg)] macro_rules! smsg { @@ -32,7 +34,7 @@ pub extern "C" fn captured_syscall( a4: i64, a5: i64, ) -> i64 { - let sc = syscalls::SyscallNo::from(no); + let sc = SyscallNo::from(no); note_syscall(p, no, NoteInfo::SyscallEntry); let tid = syscall!(SYS_gettid).unwrap(); diff --git a/examples/echo/src/lib.rs b/examples/echo/src/lib.rs index ff7a2da..943db2c 100644 --- a/examples/echo/src/lib.rs +++ b/examples/echo/src/lib.rs @@ -1,18 +1,16 @@ #![feature(format_args_nl, slice_internals)] #![allow(unused_attributes)] -use tools_helper::*; +use reverie_helper::{counter, common, logger}; #[macro_use] pub mod macros; -pub mod ffi; -pub mod consts; pub mod entry; pub mod dpc; pub mod show; pub use counter::{NoteInfo, note_syscall}; -pub use local_state::{ProcessState, ThreadState}; +pub use common::local_state::{ProcessState, ThreadState}; use entry::captured_syscall; diff --git a/examples/echo/src/show/args.rs b/examples/echo/src/show/args.rs index b5ac059..f7a33ab 100644 --- a/examples/echo/src/show/args.rs +++ b/examples/echo/src/show/args.rs @@ -1,5 +1,5 @@ //! pretty print syscalls -use syscalls::*; +use reverie_helper::syscalls::*; use core::fmt; use core::fmt::Display; use core::ptr::NonNull; @@ -891,7 +891,7 @@ impl Display for kernel_sigaction { self.sa_mask, { let flags = self.sa_flags as i32; - let mut v: Vec<_> = + let mut v: Vec<_> = [ libc_bit_field!(flags, SA_NOCLDSTOP), libc_bit_field!(flags, SA_NOCLDWAIT), libc_bit_field!(flags, SA_SIGINFO), diff --git a/examples/echo/src/show/types.rs b/examples/echo/src/show/types.rs index 9c8a7e5..509e60c 100644 --- a/examples/echo/src/show/types.rs +++ b/examples/echo/src/show/types.rs @@ -1,7 +1,7 @@ use core::ptr::NonNull; use core::ffi::c_void as void; -use syscalls::SyscallNo; +use reverie_helper::syscalls::SyscallNo; /// syscall return vaules for formatting purpose #[derive(Clone, Copy)] diff --git a/examples/none/Cargo.toml b/examples/none/Cargo.toml index e3d7cf0..ef7fdbe 100644 --- a/examples/none/Cargo.toml +++ b/examples/none/Cargo.toml @@ -10,8 +10,7 @@ crate-type = ["cdylib"] path = "src/lib.rs" [dependencies] -syscalls = { path = "../../syscalls" } -tools_helper = { path = "../../tools_helper" } +reverie-helper = { path = "../../reverie-helper" } serde = { version = "1.0", default-features = false, features = [ "derive" ] } [build-dependencies] diff --git a/examples/none/build.rs b/examples/none/build.rs deleted file mode 100644 index 8af2661..0000000 --- a/examples/none/build.rs +++ /dev/null @@ -1,37 +0,0 @@ -use cc; -use std::fs::File; -use std::io::{Result, Write}; -use std::path::Path; - -fn main() -> Result<()> { - cc::Build::new() - .define("_POSIX_C_SOURCE", "20180920") - .define("_GNU_SOURCE", "1") - .define("USE_SAVE", "1") - .flag("-fPIC") - .include("../../include") - .include("../../trampoline") - .file("../../trampoline/trampoline.S") - .file("../../trampoline/raw_syscall.S") - .file("../../trampoline/remote_call.S") - .compile("my-trampoline"); - - let cwd = std::env::current_dir()?; - let src_files: Vec<_> = vec![ std::fs::canonicalize("../../trampoline/ffi.rs").unwrap(), - std::fs::canonicalize("../../src/consts.rs").unwrap()]; - let dst_dir = std::fs::canonicalize(cwd.join("src"))?; - - src_files.iter().for_each(|f| { - let do_copy: Box Result<()>> = Box::new(|| { - let p = Path::new(&f).file_name().unwrap(); - let mut src = File::open(f)?; - let mut dst = File::create(dst_dir.join(p))?; - let header = format!("// AUTOMATICALLY GENERATED by build.rs by copying {:?}. DO NOT EDIT.\n\n", dst_dir.join(p)); - dst.write_all(header.as_bytes())?; - std::io::copy(&mut src, &mut dst)?; - Ok(()) - }); - do_copy().expect("failed to copy files"); - }); - Ok(()) -} diff --git a/examples/none/src/lib.rs b/examples/none/src/lib.rs index 2e68026..bdac610 100644 --- a/examples/none/src/lib.rs +++ b/examples/none/src/lib.rs @@ -1,10 +1,7 @@ #![allow(unused_imports)] #![allow(unused_attributes)] -use syscalls::*; -use tools_helper::*; - -pub mod ffi; +use reverie_helper::{ syscalls::*, common::local_state::ProcessState }; #[no_mangle] pub extern "C" fn captured_syscall( diff --git a/include/systrace.h b/include/systrace.h deleted file mode 100644 index 1ddbbfa..0000000 --- a/include/systrace.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef _MY_SYSTRACE_H -#define _MY_SYSTRACE_H - -#include "scinfo.h" - -/* syscall dispatcher, weak symbol, so that others can overrides */ -extern long captured_syscall(int syscallno, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5); - -/* initiate a syscall, traced by seccomp-bpf */ -extern long traced_syscall(int syscallno, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5); -/* initiate a syscall, untraced/allowed by seccomp-bpf */ - -extern long untraced_syscall(int syscallno, long arg0, long arg1, long arg2, long arg3, long arg4, long arg5); - -#endif diff --git a/reverie-common/Cargo.toml b/reverie-common/Cargo.toml new file mode 100644 index 0000000..47fa90e --- /dev/null +++ b/reverie-common/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "reverie-common" +version = "0.1.0" +authors = ["Logan Wendholt "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[lib] +name = "reverie_common" +path = "src/lib.rs" + +[dependencies] +nix = "0.13" +lazy_static = "1.3" diff --git a/src/consts.rs b/reverie-common/src/consts.rs similarity index 100% rename from src/consts.rs rename to reverie-common/src/consts.rs diff --git a/reverie-common/src/lib.rs b/reverie-common/src/lib.rs new file mode 100644 index 0000000..b14e520 --- /dev/null +++ b/reverie-common/src/lib.rs @@ -0,0 +1,12 @@ +//! reverie common +//! + +#![feature(format_args_nl, slice_internals)] + +#[macro_use] +extern crate lazy_static; + +pub mod consts; +pub mod state; +pub mod local_state; +pub mod profiling; diff --git a/src/local_state.rs b/reverie-common/src/local_state.rs similarity index 99% rename from src/local_state.rs rename to reverie-common/src/local_state.rs index 2c64ed0..25ebae1 100644 --- a/src/local_state.rs +++ b/reverie-common/src/local_state.rs @@ -21,7 +21,6 @@ use std::collections::{HashMap, HashSet}; use nix::unistd::Pid; -use crate::consts; use crate::profiling::*; /// resources belongs to threads diff --git a/src/profiling.rs b/reverie-common/src/profiling.rs similarity index 100% rename from src/profiling.rs rename to reverie-common/src/profiling.rs diff --git a/src/state.rs b/reverie-common/src/state.rs similarity index 97% rename from src/state.rs rename to reverie-common/src/state.rs index 9c02d8b..6d44ab6 100644 --- a/src/state.rs +++ b/reverie-common/src/state.rs @@ -1,6 +1,7 @@ //! reverie global state use std::sync::Mutex; +use lazy_static; use crate::profiling::*; diff --git a/tools_helper/Cargo.toml b/reverie-helper/Cargo.toml similarity index 74% rename from tools_helper/Cargo.toml rename to reverie-helper/Cargo.toml index b8d7abd..003da01 100644 --- a/tools_helper/Cargo.toml +++ b/reverie-helper/Cargo.toml @@ -1,14 +1,19 @@ [package] -name = "tools_helper" +name = "reverie-helper" version = "0.1.0" authors = ["Baojun Wang "] edition = "2018" +[lib] +name = "reverie_helper" +crate-type = ["lib"] + [features] std = [] [dependencies] syscalls = { path = "../syscalls" } +reverie-common = { path = "../reverie-common" } log = { version = "0.4", default-features = false } serde = { version = "1.0", default-features = false, features = [ "derive" ] } nix = "0.13" diff --git a/reverie-helper/build.rs b/reverie-helper/build.rs new file mode 100644 index 0000000..c465aa0 --- /dev/null +++ b/reverie-helper/build.rs @@ -0,0 +1,17 @@ +use std::io::Result; + +fn main() -> Result<()> { + cc::Build::new() + .define("_POSIX_C_SOURCE", "20180920") + .define("_GNU_SOURCE", "1") + .define("USE_SAVE", "1") + .flag("-fPIC") + .include("../include") + .include("./src") + .file("./src/trampoline.S") + .file("./src/raw_syscall.S") + .file("./src/remote_call.S") + .compile("my-trampoline"); + + Ok(()) +} diff --git a/tools_helper/src/counter.rs b/reverie-helper/src/counter.rs similarity index 92% rename from tools_helper/src/counter.rs rename to reverie-helper/src/counter.rs index d8f5941..35c06f4 100644 --- a/tools_helper/src/counter.rs +++ b/reverie-helper/src/counter.rs @@ -2,7 +2,7 @@ use std::sync::atomic::Ordering; -use crate::local_state::*; +use reverie_common::local_state::*; /// syscall events pub enum NoteInfo { diff --git a/trampoline/ffi.rs b/reverie-helper/src/ffi.rs similarity index 93% rename from trampoline/ffi.rs rename to reverie-helper/src/ffi.rs index 6db46fa..98f46ab 100644 --- a/trampoline/ffi.rs +++ b/reverie-helper/src/ffi.rs @@ -8,10 +8,9 @@ /// cdylib is built correctly. use core::ffi::c_void; -use crate::consts; -use crate::captured_syscall; +use reverie_common::consts; +use reverie_common::local_state::*; -use tools_helper::local_state::*; use syscalls::*; static SYSCALL_UNTRACED: u64 = 0x7000_0000; @@ -42,6 +41,15 @@ extern "C" { fn _syscall_hook_trampoline_85_c0_0f_94_c2(); fn _remote_syscall_helper(); fn _remote_funccall_helper(); + fn captured_syscall( + _p: &mut ProcessState, + no: i32, + a0: i64, + a1: i64, + a2: i64, + a3: i64, + a4: i64, + a5: i64) -> i64; } #[no_mangle] @@ -145,8 +153,8 @@ unsafe extern "C" fn syscall_hook(info: *const syscall_info) -> i64 { if let Some(cell) = &PSTATE { let mut pstate = cell.get().as_mut().unwrap(); let sc = info.as_ref().unwrap(); - let no = SyscallNo::from(sc.no as i32); - let tid = syscall!(SYS_gettid).unwrap() as i32; + let _no = SyscallNo::from(sc.no as i32); + let _tid = syscall!(SYS_gettid).unwrap() as i32; let res = captured_syscall(&mut pstate, sc.no as i32, sc.args[0] as i64, sc.args[1] as i64, sc.args[2] as i64, sc.args[3] as i64, diff --git a/reverie-helper/src/lib.rs b/reverie-helper/src/lib.rs new file mode 100644 index 0000000..9f2ca7f --- /dev/null +++ b/reverie-helper/src/lib.rs @@ -0,0 +1,13 @@ +//! reverie tools helper +//! + +#![feature(format_args_nl, slice_internals)] + +#[macro_use] +pub mod logger; +pub mod spinlock; +pub mod counter; +pub mod ffi; + +pub use reverie_common as common; +pub use syscalls; diff --git a/tools_helper/src/logger.rs b/reverie-helper/src/logger.rs similarity index 100% rename from tools_helper/src/logger.rs rename to reverie-helper/src/logger.rs diff --git a/trampoline/raw_syscall.S b/reverie-helper/src/raw_syscall.S similarity index 100% rename from trampoline/raw_syscall.S rename to reverie-helper/src/raw_syscall.S diff --git a/trampoline/remote_call.S b/reverie-helper/src/remote_call.S similarity index 100% rename from trampoline/remote_call.S rename to reverie-helper/src/remote_call.S diff --git a/trampoline/scinfo.h b/reverie-helper/src/scinfo.h similarity index 100% rename from trampoline/scinfo.h rename to reverie-helper/src/scinfo.h diff --git a/tools_helper/src/spinlock.rs b/reverie-helper/src/spinlock.rs similarity index 100% rename from tools_helper/src/spinlock.rs rename to reverie-helper/src/spinlock.rs diff --git a/trampoline/trampoline.S b/reverie-helper/src/trampoline.S similarity index 100% rename from trampoline/trampoline.S rename to reverie-helper/src/trampoline.S diff --git a/preloader/Cargo.toml b/reverie-preloader/Cargo.toml similarity index 78% rename from preloader/Cargo.toml rename to reverie-preloader/Cargo.toml index be20bef..6f8204a 100644 --- a/preloader/Cargo.toml +++ b/reverie-preloader/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "preloader" +name = "reverie-preloader" version = "0.1.0" authors = ["Baojun Wang "] edition = "2018" @@ -7,12 +7,13 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] -name = "preloader" +name = "reverie_preloader" crate-type = ["cdylib"] path = "src/lib.rs" [dependencies] syscalls = { path = "../syscalls" } +reverie-common = { path = "../reverie-common" } procfs = "0.5" nix = "0.14" libc = "0.2" diff --git a/preloader/build.rs b/reverie-preloader/build.rs similarity index 63% rename from preloader/build.rs rename to reverie-preloader/build.rs index e7b4ce4..6195b4e 100644 --- a/preloader/build.rs +++ b/reverie-preloader/build.rs @@ -1,6 +1,4 @@ -use std::fs::File; -use std::io::{Result, Write}; -use std::path::PathBuf; +use std::io::{Result}; use cc; @@ -11,6 +9,5 @@ fn main() -> Result<()> { .file("src/bpf-helper.c") .file("src/dl_ns.c") .compile("my-asm-lib"); - std::fs::copy("../src/consts.rs", "src/consts.rs")?; Ok(()) } diff --git a/preloader/src/bpf-helper.c b/reverie-preloader/src/bpf-helper.c similarity index 100% rename from preloader/src/bpf-helper.c rename to reverie-preloader/src/bpf-helper.c diff --git a/preloader/src/bpf-helper.h b/reverie-preloader/src/bpf-helper.h similarity index 100% rename from preloader/src/bpf-helper.h rename to reverie-preloader/src/bpf-helper.h diff --git a/preloader/src/bpf_ll.c b/reverie-preloader/src/bpf_ll.c similarity index 100% rename from preloader/src/bpf_ll.c rename to reverie-preloader/src/bpf_ll.c diff --git a/preloader/src/bpf_ll.h b/reverie-preloader/src/bpf_ll.h similarity index 100% rename from preloader/src/bpf_ll.h rename to reverie-preloader/src/bpf_ll.h diff --git a/preloader/src/dl_ns.c b/reverie-preloader/src/dl_ns.c similarity index 100% rename from preloader/src/dl_ns.c rename to reverie-preloader/src/dl_ns.c diff --git a/preloader/src/lib.rs b/reverie-preloader/src/lib.rs similarity index 99% rename from preloader/src/lib.rs rename to reverie-preloader/src/lib.rs index 64003e8..d7e7f75 100644 --- a/preloader/src/lib.rs +++ b/reverie-preloader/src/lib.rs @@ -2,11 +2,11 @@ use std::io::Result; -pub mod consts; pub mod relink; pub mod seccomp_bpf; use syscalls::*; +use reverie_common::consts; #[link_section = ".init_array"] #[used] diff --git a/preloader/src/relink.rs b/reverie-preloader/src/relink.rs similarity index 100% rename from preloader/src/relink.rs rename to reverie-preloader/src/relink.rs diff --git a/preloader/src/seccomp_bpf.rs b/reverie-preloader/src/seccomp_bpf.rs similarity index 100% rename from preloader/src/seccomp_bpf.rs rename to reverie-preloader/src/seccomp_bpf.rs diff --git a/reverie/Cargo.toml b/reverie/Cargo.toml new file mode 100644 index 0000000..71af41b --- /dev/null +++ b/reverie/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "reverie" +version = "0.1.0" +authors = ["Baojun Wang "] +edition = "2018" + +[lib] +name = "reverie" +path = "src/lib.rs" + +[[bin]] +name = "reverie" +path = "src/main.rs" + +[dependencies] +libc = { version = "0.2", default-features = false } +syscalls = { path = "../syscalls" } +reverie-common = { path = "../reverie-common" } +nix = "0.13" +goblin = "0.0" +procfs = "0.5" +clap = "2.32" +lazy_static = "1.3" +colored = "1.7" +chrono = "0.4" +log = "0.4" +fern = "0.5" +serde = { version = "1.0", features = [ "derive" ] } +serde_json = "1.0" + +[build-dependencies] +cc = "1.0" +sysnum = { path = "../sysnum" } diff --git a/build.rs b/reverie/build.rs similarity index 99% rename from build.rs rename to reverie/build.rs index 091e204..4538c49 100644 --- a/build.rs +++ b/reverie/build.rs @@ -3,8 +3,6 @@ use std::io::{Result, Write}; use std::path::PathBuf; use sysnum::gen_syscalls; -use cc; - fn gen_syscall_nrs(dest: PathBuf) -> Result<()> { let mut f = File::create(dest)?; writeln!(f, "// AUTOMATICALLY GENERATED BY reverie/build.rs. DO NOT EDIT.\n")?; diff --git a/src/aux.rs b/reverie/src/aux.rs similarity index 100% rename from src/aux.rs rename to reverie/src/aux.rs diff --git a/src/auxv.rs b/reverie/src/auxv.rs similarity index 100% rename from src/auxv.rs rename to reverie/src/auxv.rs diff --git a/src/block_events.rs b/reverie/src/block_events.rs similarity index 100% rename from src/block_events.rs rename to reverie/src/block_events.rs diff --git a/src/config.rs b/reverie/src/config.rs similarity index 93% rename from src/config.rs rename to reverie/src/config.rs index 8d00b6f..b0d90e3 100644 --- a/src/config.rs +++ b/reverie/src/config.rs @@ -3,47 +3,47 @@ use syscalls::*; /// How should the intrumentor do its job? pub enum InstrumentMode { - /// Fully centralized tool execution inside a tracer process. - /// + /// Fully centralized tool execution inside a tracer process. + /// /// This uses ptrace to handle all events, and for all guest access/modification. FullPtrace, - /// Execute event handlers inside guest process when possible. - /// - /// In this default setting, local handlers communicate with the - /// global state object using ________, the default RPC + /// Execute event handlers inside guest process when possible. + /// + /// In this default setting, local handlers communicate with the + /// global state object using ________, the default RPC /// implementation. Global state methods run centrally in a tracer /// and they read and modify (inject) the guest processes using ptrace. InGuestDefault, - // TODO: in the future we may offer a mode for executing global methods - // in a decentralized fashion, assuming threadsafe implementations and all - // global state managed in shared pages. We're setting aside this option + // TODO: in the future we may offer a mode for executing global methods + // in a decentralized fashion, assuming threadsafe implementations and all + // global state managed in shared pages. We're setting aside this option // for the near and medium term. // // GlobalSharedState } -/// Setting to optionally interupt the guest (fire a timer) causing an event to be +/// Setting to optionally interupt the guest (fire a timer) causing an event to be /// created and handled by the tool. pub enum Heartbeat { - /// No heartbeat. Guests will only yield when they trigger a relevant event, + /// No heartbeat. Guests will only yield when they trigger a relevant event, /// not merely due to the passage of time. NoBeat, - /// Future/TODO: A maximum guest compute quantum, specified in units of - /// retired branch conditionals. This heartbeat can be used to construct + /// Future/TODO: A maximum guest compute quantum, specified in units of + /// retired branch conditionals. This heartbeat can be used to construct /// a deterministic logical clock (DLC), but it is expensive, because current /// (2019) Intel hardware does not support exact interrupts on this perf counter /// so some single-stepping is required (see RR ATC'17 paper). - /// + /// /// The boolean indicates whether other handled events "count" as heartbeats. /// If true, then the heartbeat only triggers if and when the guest exceeds /// its time slice before yielding with a syscall or some other event. ExactRBCs(u64, bool), /// Future/TODO: a nondeterministic heartbeat that is less expensive to implement. - /// This can be useful for updating ones own clock, for example (i.e. in a scenario + /// This can be useful for updating ones own clock, for example (i.e. in a scenario /// where we do not yield on heartbeats, but do publish state). ApproxCyclesRBCs(u64, bool), diff --git a/src/debug.rs b/reverie/src/debug.rs similarity index 100% rename from src/debug.rs rename to reverie/src/debug.rs diff --git a/src/hooks.rs b/reverie/src/hooks.rs similarity index 100% rename from src/hooks.rs rename to reverie/src/hooks.rs diff --git a/src/lib.rs b/reverie/src/lib.rs similarity index 91% rename from src/lib.rs rename to reverie/src/lib.rs index 3f42cb5..3a96061 100644 --- a/src/lib.rs +++ b/reverie/src/lib.rs @@ -10,7 +10,9 @@ #[macro_use] extern crate lazy_static; -pub mod consts; +pub use syscalls; +pub use reverie_common; + pub mod hooks; pub mod nr; pub mod ns; @@ -22,12 +24,9 @@ pub mod stubs; pub mod vdso; pub mod task; pub mod traced_task; -pub mod state; -pub mod local_state; pub mod block_events; pub mod rpc_ptrace; pub mod auxv; pub mod aux; pub mod config; pub mod debug; -pub mod profiling; diff --git a/src/macros.rs b/reverie/src/macros.rs similarity index 100% rename from src/macros.rs rename to reverie/src/macros.rs diff --git a/src/main.rs b/reverie/src/main.rs similarity index 98% rename from src/main.rs rename to reverie/src/main.rs index 53fa80f..bc8514b 100644 --- a/src/main.rs +++ b/reverie/src/main.rs @@ -21,15 +21,15 @@ use std::path::PathBuf; use std::sync::atomic::{Ordering, AtomicUsize}; use std::env; -use reverie::{ns, consts, task, hooks}; +use reverie::{ns, task, hooks}; use reverie::sched::Scheduler; use reverie::sched_wait::SchedWait; use reverie::task::{RunTask, Task}; -use reverie::state::*; +use reverie::reverie_common::{state::*, consts}; #[test] fn can_resolve_syscall_hooks() -> Result<()> { - let so = PathBuf::from("lib").join("libecho.so").canonicalize()?; + let so = PathBuf::from("../lib").join("libecho.so").canonicalize()?; let parsed = hooks::resolve_syscall_hooks_from(so)?; assert_ne!(parsed.len(), 0); Ok(()) diff --git a/reverie/src/nr.rs b/reverie/src/nr.rs new file mode 100644 index 0000000..f9f37a0 --- /dev/null +++ b/reverie/src/nr.rs @@ -0,0 +1,1067 @@ +// AUTOMATICALLY GENERATED BY reverie/build.rs. DO NOT EDIT. + +pub use self::SyscallNo::*; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub enum SyscallNo { + SYS_read = 0, + SYS_write = 1, + SYS_open = 2, + SYS_close = 3, + SYS_stat = 4, + SYS_fstat = 5, + SYS_lstat = 6, + SYS_poll = 7, + SYS_lseek = 8, + SYS_mmap = 9, + SYS_mprotect = 10, + SYS_munmap = 11, + SYS_brk = 12, + SYS_rt_sigaction = 13, + SYS_rt_sigprocmask = 14, + SYS_rt_sigreturn = 15, + SYS_ioctl = 16, + SYS_pread64 = 17, + SYS_pwrite64 = 18, + SYS_readv = 19, + SYS_writev = 20, + SYS_access = 21, + SYS_pipe = 22, + SYS_select = 23, + SYS_sched_yield = 24, + SYS_mremap = 25, + SYS_msync = 26, + SYS_mincore = 27, + SYS_madvise = 28, + SYS_shmget = 29, + SYS_shmat = 30, + SYS_shmctl = 31, + SYS_dup = 32, + SYS_dup2 = 33, + SYS_pause = 34, + SYS_nanosleep = 35, + SYS_getitimer = 36, + SYS_alarm = 37, + SYS_setitimer = 38, + SYS_getpid = 39, + SYS_sendfile = 40, + SYS_socket = 41, + SYS_connect = 42, + SYS_accept = 43, + SYS_sendto = 44, + SYS_recvfrom = 45, + SYS_sendmsg = 46, + SYS_recvmsg = 47, + SYS_shutdown = 48, + SYS_bind = 49, + SYS_listen = 50, + SYS_getsockname = 51, + SYS_getpeername = 52, + SYS_socketpair = 53, + SYS_setsockopt = 54, + SYS_getsockopt = 55, + SYS_clone = 56, + SYS_fork = 57, + SYS_vfork = 58, + SYS_execve = 59, + SYS_exit = 60, + SYS_wait4 = 61, + SYS_kill = 62, + SYS_uname = 63, + SYS_semget = 64, + SYS_semop = 65, + SYS_semctl = 66, + SYS_shmdt = 67, + SYS_msgget = 68, + SYS_msgsnd = 69, + SYS_msgrcv = 70, + SYS_msgctl = 71, + SYS_fcntl = 72, + SYS_flock = 73, + SYS_fsync = 74, + SYS_fdatasync = 75, + SYS_truncate = 76, + SYS_ftruncate = 77, + SYS_getdents = 78, + SYS_getcwd = 79, + SYS_chdir = 80, + SYS_fchdir = 81, + SYS_rename = 82, + SYS_mkdir = 83, + SYS_rmdir = 84, + SYS_creat = 85, + SYS_link = 86, + SYS_unlink = 87, + SYS_symlink = 88, + SYS_readlink = 89, + SYS_chmod = 90, + SYS_fchmod = 91, + SYS_chown = 92, + SYS_fchown = 93, + SYS_lchown = 94, + SYS_umask = 95, + SYS_gettimeofday = 96, + SYS_getrlimit = 97, + SYS_getrusage = 98, + SYS_sysinfo = 99, + SYS_times = 100, + SYS_ptrace = 101, + SYS_getuid = 102, + SYS_syslog = 103, + SYS_getgid = 104, + SYS_setuid = 105, + SYS_setgid = 106, + SYS_geteuid = 107, + SYS_getegid = 108, + SYS_setpgid = 109, + SYS_getppid = 110, + SYS_getpgrp = 111, + SYS_setsid = 112, + SYS_setreuid = 113, + SYS_setregid = 114, + SYS_getgroups = 115, + SYS_setgroups = 116, + SYS_setresuid = 117, + SYS_getresuid = 118, + SYS_setresgid = 119, + SYS_getresgid = 120, + SYS_getpgid = 121, + SYS_setfsuid = 122, + SYS_setfsgid = 123, + SYS_getsid = 124, + SYS_capget = 125, + SYS_capset = 126, + SYS_rt_sigpending = 127, + SYS_rt_sigtimedwait = 128, + SYS_rt_sigqueueinfo = 129, + SYS_rt_sigsuspend = 130, + SYS_sigaltstack = 131, + SYS_utime = 132, + SYS_mknod = 133, + SYS_uselib = 134, + SYS_personality = 135, + SYS_ustat = 136, + SYS_statfs = 137, + SYS_fstatfs = 138, + SYS_sysfs = 139, + SYS_getpriority = 140, + SYS_setpriority = 141, + SYS_sched_setparam = 142, + SYS_sched_getparam = 143, + SYS_sched_setscheduler = 144, + SYS_sched_getscheduler = 145, + SYS_sched_get_priority_max = 146, + SYS_sched_get_priority_min = 147, + SYS_sched_rr_get_interval = 148, + SYS_mlock = 149, + SYS_munlock = 150, + SYS_mlockall = 151, + SYS_munlockall = 152, + SYS_vhangup = 153, + SYS_modify_ldt = 154, + SYS_pivot_root = 155, + SYS__sysctl = 156, + SYS_prctl = 157, + SYS_arch_prctl = 158, + SYS_adjtimex = 159, + SYS_setrlimit = 160, + SYS_chroot = 161, + SYS_sync = 162, + SYS_acct = 163, + SYS_settimeofday = 164, + SYS_mount = 165, + SYS_umount2 = 166, + SYS_swapon = 167, + SYS_swapoff = 168, + SYS_reboot = 169, + SYS_sethostname = 170, + SYS_setdomainname = 171, + SYS_iopl = 172, + SYS_ioperm = 173, + SYS_create_module = 174, + SYS_init_module = 175, + SYS_delete_module = 176, + SYS_get_kernel_syms = 177, + SYS_query_module = 178, + SYS_quotactl = 179, + SYS_nfsservctl = 180, + SYS_getpmsg = 181, + SYS_putpmsg = 182, + SYS_afs_syscall = 183, + SYS_tuxcall = 184, + SYS_security = 185, + SYS_gettid = 186, + SYS_readahead = 187, + SYS_setxattr = 188, + SYS_lsetxattr = 189, + SYS_fsetxattr = 190, + SYS_getxattr = 191, + SYS_lgetxattr = 192, + SYS_fgetxattr = 193, + SYS_listxattr = 194, + SYS_llistxattr = 195, + SYS_flistxattr = 196, + SYS_removexattr = 197, + SYS_lremovexattr = 198, + SYS_fremovexattr = 199, + SYS_tkill = 200, + SYS_time = 201, + SYS_futex = 202, + SYS_sched_setaffinity = 203, + SYS_sched_getaffinity = 204, + SYS_set_thread_area = 205, + SYS_io_setup = 206, + SYS_io_destroy = 207, + SYS_io_getevents = 208, + SYS_io_submit = 209, + SYS_io_cancel = 210, + SYS_get_thread_area = 211, + SYS_lookup_dcookie = 212, + SYS_epoll_create = 213, + SYS_epoll_ctl_old = 214, + SYS_epoll_wait_old = 215, + SYS_remap_file_pages = 216, + SYS_getdents64 = 217, + SYS_set_tid_address = 218, + SYS_restart_syscall = 219, + SYS_semtimedop = 220, + SYS_fadvise64 = 221, + SYS_timer_create = 222, + SYS_timer_settime = 223, + SYS_timer_gettime = 224, + SYS_timer_getoverrun = 225, + SYS_timer_delete = 226, + SYS_clock_settime = 227, + SYS_clock_gettime = 228, + SYS_clock_getres = 229, + SYS_clock_nanosleep = 230, + SYS_exit_group = 231, + SYS_epoll_wait = 232, + SYS_epoll_ctl = 233, + SYS_tgkill = 234, + SYS_utimes = 235, + SYS_vserver = 236, + SYS_mbind = 237, + SYS_set_mempolicy = 238, + SYS_get_mempolicy = 239, + SYS_mq_open = 240, + SYS_mq_unlink = 241, + SYS_mq_timedsend = 242, + SYS_mq_timedreceive = 243, + SYS_mq_notify = 244, + SYS_mq_getsetattr = 245, + SYS_kexec_load = 246, + SYS_waitid = 247, + SYS_add_key = 248, + SYS_request_key = 249, + SYS_keyctl = 250, + SYS_ioprio_set = 251, + SYS_ioprio_get = 252, + SYS_inotify_init = 253, + SYS_inotify_add_watch = 254, + SYS_inotify_rm_watch = 255, + SYS_migrate_pages = 256, + SYS_openat = 257, + SYS_mkdirat = 258, + SYS_mknodat = 259, + SYS_fchownat = 260, + SYS_futimesat = 261, + SYS_newfstatat = 262, + SYS_unlinkat = 263, + SYS_renameat = 264, + SYS_linkat = 265, + SYS_symlinkat = 266, + SYS_readlinkat = 267, + SYS_fchmodat = 268, + SYS_faccessat = 269, + SYS_pselect6 = 270, + SYS_ppoll = 271, + SYS_unshare = 272, + SYS_set_robust_list = 273, + SYS_get_robust_list = 274, + SYS_splice = 275, + SYS_tee = 276, + SYS_sync_file_range = 277, + SYS_vmsplice = 278, + SYS_move_pages = 279, + SYS_utimensat = 280, + SYS_epoll_pwait = 281, + SYS_signalfd = 282, + SYS_timerfd_create = 283, + SYS_eventfd = 284, + SYS_fallocate = 285, + SYS_timerfd_settime = 286, + SYS_timerfd_gettime = 287, + SYS_accept4 = 288, + SYS_signalfd4 = 289, + SYS_eventfd2 = 290, + SYS_epoll_create1 = 291, + SYS_dup3 = 292, + SYS_pipe2 = 293, + SYS_inotify_init1 = 294, + SYS_preadv = 295, + SYS_pwritev = 296, + SYS_rt_tgsigqueueinfo = 297, + SYS_perf_event_open = 298, + SYS_recvmmsg = 299, + SYS_fanotify_init = 300, + SYS_fanotify_mark = 301, + SYS_prlimit64 = 302, + SYS_name_to_handle_at = 303, + SYS_open_by_handle_at = 304, + SYS_clock_adjtime = 305, + SYS_syncfs = 306, + SYS_sendmmsg = 307, + SYS_setns = 308, + SYS_getcpu = 309, + SYS_process_vm_readv = 310, + SYS_process_vm_writev = 311, + SYS_kcmp = 312, + SYS_finit_module = 313, + SYS_sched_setattr = 314, + SYS_sched_getattr = 315, + SYS_renameat2 = 316, + SYS_seccomp = 317, + SYS_getrandom = 318, + SYS_memfd_create = 319, + SYS_kexec_file_load = 320, + SYS_bpf = 321, + SYS_execveat = 322, + SYS_userfaultfd = 323, + SYS_membarrier = 324, + SYS_mlock2 = 325, + SYS_copy_file_range = 326, + SYS_preadv2 = 327, + SYS_pwritev2 = 328, + SYS_pkey_mprotect = 329, + SYS_pkey_alloc = 330, + SYS_pkey_free = 331, + SYS_statx = 332, + SYS_io_pgetevents = 333, + SYS_rseq = 334, + SYS_pidfd_send_signal = 424, + SYS_io_uring_setup = 425, + SYS_io_uring_enter = 426, + SYS_io_uring_register = 427, + SYS_open_tree = 428, + SYS_move_mount = 429, + SYS_fsopen = 430, + SYS_fsconfig = 431, + SYS_fsmount = 432, + SYS_fspick = 433, + SYS_pidfd_open = 434, + SYS_clone3 = 435, +} +static SYSCALL_NAMES: [&str; 347] = [ + "read", + "write", + "open", + "close", + "stat", + "fstat", + "lstat", + "poll", + "lseek", + "mmap", + "mprotect", + "munmap", + "brk", + "rt_sigaction", + "rt_sigprocmask", + "rt_sigreturn", + "ioctl", + "pread64", + "pwrite64", + "readv", + "writev", + "access", + "pipe", + "select", + "sched_yield", + "mremap", + "msync", + "mincore", + "madvise", + "shmget", + "shmat", + "shmctl", + "dup", + "dup2", + "pause", + "nanosleep", + "getitimer", + "alarm", + "setitimer", + "getpid", + "sendfile", + "socket", + "connect", + "accept", + "sendto", + "recvfrom", + "sendmsg", + "recvmsg", + "shutdown", + "bind", + "listen", + "getsockname", + "getpeername", + "socketpair", + "setsockopt", + "getsockopt", + "clone", + "fork", + "vfork", + "execve", + "exit", + "wait4", + "kill", + "uname", + "semget", + "semop", + "semctl", + "shmdt", + "msgget", + "msgsnd", + "msgrcv", + "msgctl", + "fcntl", + "flock", + "fsync", + "fdatasync", + "truncate", + "ftruncate", + "getdents", + "getcwd", + "chdir", + "fchdir", + "rename", + "mkdir", + "rmdir", + "creat", + "link", + "unlink", + "symlink", + "readlink", + "chmod", + "fchmod", + "chown", + "fchown", + "lchown", + "umask", + "gettimeofday", + "getrlimit", + "getrusage", + "sysinfo", + "times", + "ptrace", + "getuid", + "syslog", + "getgid", + "setuid", + "setgid", + "geteuid", + "getegid", + "setpgid", + "getppid", + "getpgrp", + "setsid", + "setreuid", + "setregid", + "getgroups", + "setgroups", + "setresuid", + "getresuid", + "setresgid", + "getresgid", + "getpgid", + "setfsuid", + "setfsgid", + "getsid", + "capget", + "capset", + "rt_sigpending", + "rt_sigtimedwait", + "rt_sigqueueinfo", + "rt_sigsuspend", + "sigaltstack", + "utime", + "mknod", + "uselib", + "personality", + "ustat", + "statfs", + "fstatfs", + "sysfs", + "getpriority", + "setpriority", + "sched_setparam", + "sched_getparam", + "sched_setscheduler", + "sched_getscheduler", + "sched_get_priority_max", + "sched_get_priority_min", + "sched_rr_get_interval", + "mlock", + "munlock", + "mlockall", + "munlockall", + "vhangup", + "modify_ldt", + "pivot_root", + "_sysctl", + "prctl", + "arch_prctl", + "adjtimex", + "setrlimit", + "chroot", + "sync", + "acct", + "settimeofday", + "mount", + "umount2", + "swapon", + "swapoff", + "reboot", + "sethostname", + "setdomainname", + "iopl", + "ioperm", + "create_module", + "init_module", + "delete_module", + "get_kernel_syms", + "query_module", + "quotactl", + "nfsservctl", + "getpmsg", + "putpmsg", + "afs_syscall", + "tuxcall", + "security", + "gettid", + "readahead", + "setxattr", + "lsetxattr", + "fsetxattr", + "getxattr", + "lgetxattr", + "fgetxattr", + "listxattr", + "llistxattr", + "flistxattr", + "removexattr", + "lremovexattr", + "fremovexattr", + "tkill", + "time", + "futex", + "sched_setaffinity", + "sched_getaffinity", + "set_thread_area", + "io_setup", + "io_destroy", + "io_getevents", + "io_submit", + "io_cancel", + "get_thread_area", + "lookup_dcookie", + "epoll_create", + "epoll_ctl_old", + "epoll_wait_old", + "remap_file_pages", + "getdents64", + "set_tid_address", + "restart_syscall", + "semtimedop", + "fadvise64", + "timer_create", + "timer_settime", + "timer_gettime", + "timer_getoverrun", + "timer_delete", + "clock_settime", + "clock_gettime", + "clock_getres", + "clock_nanosleep", + "exit_group", + "epoll_wait", + "epoll_ctl", + "tgkill", + "utimes", + "vserver", + "mbind", + "set_mempolicy", + "get_mempolicy", + "mq_open", + "mq_unlink", + "mq_timedsend", + "mq_timedreceive", + "mq_notify", + "mq_getsetattr", + "kexec_load", + "waitid", + "add_key", + "request_key", + "keyctl", + "ioprio_set", + "ioprio_get", + "inotify_init", + "inotify_add_watch", + "inotify_rm_watch", + "migrate_pages", + "openat", + "mkdirat", + "mknodat", + "fchownat", + "futimesat", + "newfstatat", + "unlinkat", + "renameat", + "linkat", + "symlinkat", + "readlinkat", + "fchmodat", + "faccessat", + "pselect6", + "ppoll", + "unshare", + "set_robust_list", + "get_robust_list", + "splice", + "tee", + "sync_file_range", + "vmsplice", + "move_pages", + "utimensat", + "epoll_pwait", + "signalfd", + "timerfd_create", + "eventfd", + "fallocate", + "timerfd_settime", + "timerfd_gettime", + "accept4", + "signalfd4", + "eventfd2", + "epoll_create1", + "dup3", + "pipe2", + "inotify_init1", + "preadv", + "pwritev", + "rt_tgsigqueueinfo", + "perf_event_open", + "recvmmsg", + "fanotify_init", + "fanotify_mark", + "prlimit64", + "name_to_handle_at", + "open_by_handle_at", + "clock_adjtime", + "syncfs", + "sendmmsg", + "setns", + "getcpu", + "process_vm_readv", + "process_vm_writev", + "kcmp", + "finit_module", + "sched_setattr", + "sched_getattr", + "renameat2", + "seccomp", + "getrandom", + "memfd_create", + "kexec_file_load", + "bpf", + "execveat", + "userfaultfd", + "membarrier", + "mlock2", + "copy_file_range", + "preadv2", + "pwritev2", + "pkey_mprotect", + "pkey_alloc", + "pkey_free", + "statx", + "io_pgetevents", + "rseq", + "pidfd_send_signal", + "io_uring_setup", + "io_uring_enter", + "io_uring_register", + "open_tree", + "move_mount", + "fsopen", + "fsconfig", + "fsmount", + "fspick", + "pidfd_open", + "clone3", +]; +impl ToString for SyscallNo { + fn to_string(&self) -> String { + SYSCALL_NAMES[*self as usize].to_string() + } +} +static SYSCALL_IDS: [SyscallNo; 347] = [ + SYS_read, + SYS_write, + SYS_open, + SYS_close, + SYS_stat, + SYS_fstat, + SYS_lstat, + SYS_poll, + SYS_lseek, + SYS_mmap, + SYS_mprotect, + SYS_munmap, + SYS_brk, + SYS_rt_sigaction, + SYS_rt_sigprocmask, + SYS_rt_sigreturn, + SYS_ioctl, + SYS_pread64, + SYS_pwrite64, + SYS_readv, + SYS_writev, + SYS_access, + SYS_pipe, + SYS_select, + SYS_sched_yield, + SYS_mremap, + SYS_msync, + SYS_mincore, + SYS_madvise, + SYS_shmget, + SYS_shmat, + SYS_shmctl, + SYS_dup, + SYS_dup2, + SYS_pause, + SYS_nanosleep, + SYS_getitimer, + SYS_alarm, + SYS_setitimer, + SYS_getpid, + SYS_sendfile, + SYS_socket, + SYS_connect, + SYS_accept, + SYS_sendto, + SYS_recvfrom, + SYS_sendmsg, + SYS_recvmsg, + SYS_shutdown, + SYS_bind, + SYS_listen, + SYS_getsockname, + SYS_getpeername, + SYS_socketpair, + SYS_setsockopt, + SYS_getsockopt, + SYS_clone, + SYS_fork, + SYS_vfork, + SYS_execve, + SYS_exit, + SYS_wait4, + SYS_kill, + SYS_uname, + SYS_semget, + SYS_semop, + SYS_semctl, + SYS_shmdt, + SYS_msgget, + SYS_msgsnd, + SYS_msgrcv, + SYS_msgctl, + SYS_fcntl, + SYS_flock, + SYS_fsync, + SYS_fdatasync, + SYS_truncate, + SYS_ftruncate, + SYS_getdents, + SYS_getcwd, + SYS_chdir, + SYS_fchdir, + SYS_rename, + SYS_mkdir, + SYS_rmdir, + SYS_creat, + SYS_link, + SYS_unlink, + SYS_symlink, + SYS_readlink, + SYS_chmod, + SYS_fchmod, + SYS_chown, + SYS_fchown, + SYS_lchown, + SYS_umask, + SYS_gettimeofday, + SYS_getrlimit, + SYS_getrusage, + SYS_sysinfo, + SYS_times, + SYS_ptrace, + SYS_getuid, + SYS_syslog, + SYS_getgid, + SYS_setuid, + SYS_setgid, + SYS_geteuid, + SYS_getegid, + SYS_setpgid, + SYS_getppid, + SYS_getpgrp, + SYS_setsid, + SYS_setreuid, + SYS_setregid, + SYS_getgroups, + SYS_setgroups, + SYS_setresuid, + SYS_getresuid, + SYS_setresgid, + SYS_getresgid, + SYS_getpgid, + SYS_setfsuid, + SYS_setfsgid, + SYS_getsid, + SYS_capget, + SYS_capset, + SYS_rt_sigpending, + SYS_rt_sigtimedwait, + SYS_rt_sigqueueinfo, + SYS_rt_sigsuspend, + SYS_sigaltstack, + SYS_utime, + SYS_mknod, + SYS_uselib, + SYS_personality, + SYS_ustat, + SYS_statfs, + SYS_fstatfs, + SYS_sysfs, + SYS_getpriority, + SYS_setpriority, + SYS_sched_setparam, + SYS_sched_getparam, + SYS_sched_setscheduler, + SYS_sched_getscheduler, + SYS_sched_get_priority_max, + SYS_sched_get_priority_min, + SYS_sched_rr_get_interval, + SYS_mlock, + SYS_munlock, + SYS_mlockall, + SYS_munlockall, + SYS_vhangup, + SYS_modify_ldt, + SYS_pivot_root, + SYS__sysctl, + SYS_prctl, + SYS_arch_prctl, + SYS_adjtimex, + SYS_setrlimit, + SYS_chroot, + SYS_sync, + SYS_acct, + SYS_settimeofday, + SYS_mount, + SYS_umount2, + SYS_swapon, + SYS_swapoff, + SYS_reboot, + SYS_sethostname, + SYS_setdomainname, + SYS_iopl, + SYS_ioperm, + SYS_create_module, + SYS_init_module, + SYS_delete_module, + SYS_get_kernel_syms, + SYS_query_module, + SYS_quotactl, + SYS_nfsservctl, + SYS_getpmsg, + SYS_putpmsg, + SYS_afs_syscall, + SYS_tuxcall, + SYS_security, + SYS_gettid, + SYS_readahead, + SYS_setxattr, + SYS_lsetxattr, + SYS_fsetxattr, + SYS_getxattr, + SYS_lgetxattr, + SYS_fgetxattr, + SYS_listxattr, + SYS_llistxattr, + SYS_flistxattr, + SYS_removexattr, + SYS_lremovexattr, + SYS_fremovexattr, + SYS_tkill, + SYS_time, + SYS_futex, + SYS_sched_setaffinity, + SYS_sched_getaffinity, + SYS_set_thread_area, + SYS_io_setup, + SYS_io_destroy, + SYS_io_getevents, + SYS_io_submit, + SYS_io_cancel, + SYS_get_thread_area, + SYS_lookup_dcookie, + SYS_epoll_create, + SYS_epoll_ctl_old, + SYS_epoll_wait_old, + SYS_remap_file_pages, + SYS_getdents64, + SYS_set_tid_address, + SYS_restart_syscall, + SYS_semtimedop, + SYS_fadvise64, + SYS_timer_create, + SYS_timer_settime, + SYS_timer_gettime, + SYS_timer_getoverrun, + SYS_timer_delete, + SYS_clock_settime, + SYS_clock_gettime, + SYS_clock_getres, + SYS_clock_nanosleep, + SYS_exit_group, + SYS_epoll_wait, + SYS_epoll_ctl, + SYS_tgkill, + SYS_utimes, + SYS_vserver, + SYS_mbind, + SYS_set_mempolicy, + SYS_get_mempolicy, + SYS_mq_open, + SYS_mq_unlink, + SYS_mq_timedsend, + SYS_mq_timedreceive, + SYS_mq_notify, + SYS_mq_getsetattr, + SYS_kexec_load, + SYS_waitid, + SYS_add_key, + SYS_request_key, + SYS_keyctl, + SYS_ioprio_set, + SYS_ioprio_get, + SYS_inotify_init, + SYS_inotify_add_watch, + SYS_inotify_rm_watch, + SYS_migrate_pages, + SYS_openat, + SYS_mkdirat, + SYS_mknodat, + SYS_fchownat, + SYS_futimesat, + SYS_newfstatat, + SYS_unlinkat, + SYS_renameat, + SYS_linkat, + SYS_symlinkat, + SYS_readlinkat, + SYS_fchmodat, + SYS_faccessat, + SYS_pselect6, + SYS_ppoll, + SYS_unshare, + SYS_set_robust_list, + SYS_get_robust_list, + SYS_splice, + SYS_tee, + SYS_sync_file_range, + SYS_vmsplice, + SYS_move_pages, + SYS_utimensat, + SYS_epoll_pwait, + SYS_signalfd, + SYS_timerfd_create, + SYS_eventfd, + SYS_fallocate, + SYS_timerfd_settime, + SYS_timerfd_gettime, + SYS_accept4, + SYS_signalfd4, + SYS_eventfd2, + SYS_epoll_create1, + SYS_dup3, + SYS_pipe2, + SYS_inotify_init1, + SYS_preadv, + SYS_pwritev, + SYS_rt_tgsigqueueinfo, + SYS_perf_event_open, + SYS_recvmmsg, + SYS_fanotify_init, + SYS_fanotify_mark, + SYS_prlimit64, + SYS_name_to_handle_at, + SYS_open_by_handle_at, + SYS_clock_adjtime, + SYS_syncfs, + SYS_sendmmsg, + SYS_setns, + SYS_getcpu, + SYS_process_vm_readv, + SYS_process_vm_writev, + SYS_kcmp, + SYS_finit_module, + SYS_sched_setattr, + SYS_sched_getattr, + SYS_renameat2, + SYS_seccomp, + SYS_getrandom, + SYS_memfd_create, + SYS_kexec_file_load, + SYS_bpf, + SYS_execveat, + SYS_userfaultfd, + SYS_membarrier, + SYS_mlock2, + SYS_copy_file_range, + SYS_preadv2, + SYS_pwritev2, + SYS_pkey_mprotect, + SYS_pkey_alloc, + SYS_pkey_free, + SYS_statx, + SYS_io_pgetevents, + SYS_rseq, + SYS_pidfd_send_signal, + SYS_io_uring_setup, + SYS_io_uring_enter, + SYS_io_uring_register, + SYS_open_tree, + SYS_move_mount, + SYS_fsopen, + SYS_fsconfig, + SYS_fsmount, + SYS_fspick, + SYS_pidfd_open, + SYS_clone3, +]; +impl From for SyscallNo { + fn from(item: i32) -> Self { + if item as usize > SYSCALL_IDS.len() { + panic!("invalid syscall: {}", item) + } else { + SYSCALL_IDS[item as usize] + } + } +} diff --git a/src/ns.rs b/reverie/src/ns.rs similarity index 100% rename from src/ns.rs rename to reverie/src/ns.rs diff --git a/src/remote.rs b/reverie/src/remote.rs similarity index 99% rename from src/remote.rs rename to reverie/src/remote.rs index fca8ef4..d6c277f 100644 --- a/src/remote.rs +++ b/reverie/src/remote.rs @@ -11,8 +11,9 @@ use std::io::{Error, ErrorKind, Result}; use std::path::PathBuf; use std::ptr::NonNull; -use crate::consts; -use crate::consts::*; +use reverie_common::consts; +use reverie_common::consts::*; + use crate::hooks; use crate::nr; use crate::nr::SyscallNo; diff --git a/src/remote_rwlock.rs b/reverie/src/remote_rwlock.rs similarity index 100% rename from src/remote_rwlock.rs rename to reverie/src/remote_rwlock.rs diff --git a/src/rpc_ptrace.rs b/reverie/src/rpc_ptrace.rs similarity index 98% rename from src/rpc_ptrace.rs rename to reverie/src/rpc_ptrace.rs index 85bbecd..4d1a550 100644 --- a/src/rpc_ptrace.rs +++ b/reverie/src/rpc_ptrace.rs @@ -6,10 +6,11 @@ //! NB: the tracee must be in a ptrace stop //! +use reverie_common::consts; + use crate::remote::*; use crate::task::Task; use crate::traced_task::TracedTask; -use crate::consts; use nix::sys::wait; use nix::sys::signal; use nix::sys::ptrace; diff --git a/src/sched.rs b/reverie/src/sched.rs similarity index 93% rename from src/sched.rs rename to reverie/src/sched.rs index b2f42ff..c5e5764 100644 --- a/src/sched.rs +++ b/reverie/src/sched.rs @@ -8,7 +8,7 @@ use std::io::{Error, ErrorKind, Result}; use crate::remote::*; use crate::task::Task; -use crate::state::ReverieState; +use reverie_common::state::ReverieState; pub trait Scheduler { fn new() -> Self diff --git a/src/sched_wait.rs b/reverie/src/sched_wait.rs similarity index 99% rename from src/sched_wait.rs rename to reverie/src/sched_wait.rs index 612d1f8..3120f1a 100644 --- a/src/sched_wait.rs +++ b/reverie/src/sched_wait.rs @@ -11,7 +11,9 @@ use std::sync::atomic::{Ordering, AtomicUsize}; use procfs; -use crate::consts; +use reverie_common::consts; +use reverie_common::state::ReverieState; + use crate::nr::*; use crate::remote; use crate::remote::*; @@ -19,7 +21,6 @@ use crate::sched::*; use crate::task::*; use crate::traced_task::TracedTask; use crate::traced_task::*; -use crate::state::ReverieState; use crate::debug; /// the scheduler diff --git a/src/stubs.rs b/reverie/src/stubs.rs similarity index 98% rename from src/stubs.rs rename to reverie/src/stubs.rs index 0147417..2b1a694 100644 --- a/src/stubs.rs +++ b/reverie/src/stubs.rs @@ -5,7 +5,8 @@ use std::fs::File; use std::io::{Error, ErrorKind, Result, Write}; use std::path::PathBuf; -use crate::consts; +use reverie_common::consts; + use crate::hooks; // jmp *0x0(pc) diff --git a/src/task.rs b/reverie/src/task.rs similarity index 95% rename from src/task.rs rename to reverie/src/task.rs index cd41940..5234820 100644 --- a/src/task.rs +++ b/reverie/src/task.rs @@ -8,8 +8,9 @@ use std::io::{Error, ErrorKind, Result}; use std::path::PathBuf; use std::ptr::NonNull; -use crate::consts; -use crate::consts::*; +use reverie_common::consts; +use reverie_common::consts::*; + use crate::hooks; use crate::nr; use crate::remote::*; diff --git a/src/traced_task.rs b/reverie/src/traced_task.rs similarity index 99% rename from src/traced_task.rs rename to reverie/src/traced_task.rs index 3517bc9..78ce5b4 100644 --- a/src/traced_task.rs +++ b/reverie/src/traced_task.rs @@ -36,8 +36,11 @@ use std::ffi::c_void; use std::fs::File; use goblin::elf::Elf; -use crate::consts; -use crate::consts::*; +use reverie_common::state::*; +use reverie_common::local_state::*; +use reverie_common::consts; +use reverie_common::consts::*; + use crate::hooks; use crate::nr::*; use crate::remote; @@ -48,8 +51,6 @@ use crate::stubs; use crate::task::*; use crate::remote_rwlock::*; use crate::vdso; -use crate::state::*; -use crate::local_state::*; use crate::rpc_ptrace::*; use crate::auxv; use crate::aux; @@ -784,7 +785,7 @@ impl RemoteSyscall for TracedTask { } /// inject syscall for given tracee -/// +/// /// NB: limitations: /// - tracee must be in stopped state. /// - the tracee must have returned from PTRACE_EXEC_EVENT diff --git a/src/vdso.rs b/reverie/src/vdso.rs similarity index 100% rename from src/vdso.rs rename to reverie/src/vdso.rs diff --git a/sysnum/Cargo.toml b/sysnum/Cargo.toml index 28896f9..b2c42fe 100644 --- a/sysnum/Cargo.toml +++ b/sysnum/Cargo.toml @@ -4,5 +4,9 @@ version = "0.1.0" authors = ["Baojun Wang "] edition = "2018" +[lib] +name = "sysnum" +path = "src/lib.rs" + [dependencies] tempfile = "3.0" diff --git a/tools_helper/build.rs b/tools_helper/build.rs deleted file mode 100644 index a763893..0000000 --- a/tools_helper/build.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::fs::File; -use std::io::{Result, Write}; - -fn main() -> Result<()> { - let cwd = std::env::current_dir()?; - - let src_dir = std::fs::canonicalize(cwd.join("../src"))?; - let dst_dir = std::fs::canonicalize(cwd.join("src"))?; - - let files_to_copy = &[ "consts.rs", "profiling.rs", "state.rs", "local_state.rs"]; - files_to_copy.iter().for_each(|f| { - let do_copy: Box Result<()>> = Box::new(|| { - let mut src = File::open(src_dir.join(f))?; - let mut dst = File::create(dst_dir.join(f))?; - let header = format!("// AUTOMATICALLY GENERATED by build.rs by copying {:?}. DO NOT EDIT.\n\n",src_dir.join(f)); - dst.write_all(header.as_bytes())?; - std::io::copy(&mut src, &mut dst)?; - Ok(()) - }); - do_copy().expect("failed to copy files"); - }); - Ok(()) -} diff --git a/tools_helper/src/lib.rs b/tools_helper/src/lib.rs deleted file mode 100644 index 2b193b2..0000000 --- a/tools_helper/src/lib.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! reverie tools helper -//! - -#![feature(format_args_nl, slice_internals)] - -#[macro_use] -pub mod logger; -pub mod spinlock; -pub mod consts; -pub mod counter; -pub mod local_state; -pub mod profiling; - -pub use counter::note_syscall; -pub use counter::NoteInfo; -pub use local_state::ProcessState; -