diff --git a/Cargo.lock b/Cargo.lock index cb585cd..7ebc668 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -29,7 +29,7 @@ dependencies = [ [[package]] name = "autocfg" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -47,7 +47,7 @@ name = "c2-chacha" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", ] @@ -101,27 +101,18 @@ name = "colored" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "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 = "common" -version = "0.1.0" -dependencies = [ - "lazy_static 1.3.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 = "counter" version = "0.1.0" dependencies = [ "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "syscalls 0.1.0", + "reverie-tools-helper 0.1.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tools_helper 0.1.0", ] [[package]] @@ -139,9 +130,8 @@ dependencies = [ "cc 1.0.40 (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)", - "syscalls 0.1.0", + "reverie-tools-helper 0.1.0", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "tools_helper 0.1.0", ] [[package]] @@ -149,13 +139,12 @@ name = "echo" version = "0.1.0" dependencies = [ "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (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-tools-helper 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)", - "tools_helper 0.1.0", ] [[package]] @@ -173,7 +162,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "getrandom" -version = "0.1.10" +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)", @@ -203,7 +192,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "lazy_static" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -259,10 +248,9 @@ name = "none" version = "0.1.0" dependencies = [ "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", + "reverie-tools-helper 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)", - "tools_helper 0.1.0", ] [[package]] @@ -270,7 +258,7 @@ name = "num-integer" version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", ] @@ -287,7 +275,7 @@ name = "num-traits" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "autocfg 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -300,18 +288,6 @@ name = "ppv-lite86" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "preloader" -version = "0.1.0" -dependencies = [ - "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "common 0.1.0", - "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)", - "syscalls 0.1.0", -] - [[package]] name = "proc-macro2" version = "0.4.30" @@ -337,7 +313,7 @@ dependencies = [ "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.3.0 (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)", ] @@ -375,7 +351,7 @@ name = "rand" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "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)", @@ -409,7 +385,7 @@ name = "rand_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "getrandom 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -449,23 +425,70 @@ dependencies = [ "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)", - "common 0.1.0", "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.3.0 (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", + "reverie-syscalls 0.1.0", + "reverie-sysnum 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-preloader" +version = "0.1.0" +dependencies = [ + "cc 1.0.40 (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", + "reverie-syscalls 0.1.0", +] + +[[package]] +name = "reverie-syscalls" +version = "0.1.0" +dependencies = [ + "reverie-sysnum 0.1.0", +] + +[[package]] +name = "reverie-sysnum" +version = "0.1.0" +dependencies = [ + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "reverie-tools-helper" +version = "0.1.0" +dependencies = [ + "cc 1.0.40 (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", + "reverie-syscalls 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 = "rgb" -version = "0.8.13" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -533,7 +556,7 @@ 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.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -563,7 +586,7 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.3" +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)", @@ -571,20 +594,6 @@ dependencies = [ "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" @@ -621,19 +630,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "tools_helper" -version = "0.1.0" -dependencies = [ - "cc 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "common 0.1.0", - "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)", - "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 = "unicode-width" version = "0.1.6" @@ -689,8 +685,8 @@ 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.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rgb 0.8.13 (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)", ] @@ -699,7 +695,7 @@ dependencies = [ "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.5 (registry+https://github.com/rust-lang/crates.io-index)" = "22130e92352b948e7e82a49cdb0aa94f2211761117f29e052dd397c1ac33542b" +"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" @@ -712,11 +708,11 @@ dependencies = [ "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.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6171a6cc63fbabbe27c2b5ee268e8b7fe5dc1eb0dd2dfad537c1dfed6f69117e" +"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.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" +"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" @@ -742,7 +738,7 @@ dependencies = [ "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.13 (registry+https://github.com/rust-lang/crates.io-index)" = "4f089652ca87f5a82a62935ec6172a534066c7b97be003cc8f702ee9a7a59c92" +"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" @@ -755,7 +751,7 @@ dependencies = [ "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.3 (registry+https://github.com/rust-lang/crates.io-index)" = "158521e6f544e7e3dcfc370ac180794aa38cb34a1b1e07609376d4adcf429b93" +"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" diff --git a/Cargo.toml b/Cargo.toml index a70d677..e33e231 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,37 +1,3 @@ -[package] -name = "reverie" -version = "0.1.0" -authors = ["Baojun Wang "] -edition = "2018" - [workspace] -members= [".", "syscalls", "tools_helper", "common", "preloader", "examples/none", "examples/echo", "examples/counter", "examples/det" ] -default-members = [".", "syscalls", "common", "preloader" ] - -[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" } -common = { path = "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" } +members= ["reverie", "reverie-syscalls", "reverie-tools-helper", "reverie-common", "reverie-preloader", "examples/none", "examples/echo", "examples/counter", "examples/det" ] +default-members = ["reverie", "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..5fef11b 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-tools-helper = { path = "../../reverie-tools-helper" } log = { version = "0.4", default-features = false } [build-dependencies] diff --git a/examples/counter/src/lib.rs b/examples/counter/src/lib.rs index d702316..5207c45 100644 --- a/examples/counter/src/lib.rs +++ b/examples/counter/src/lib.rs @@ -6,8 +6,7 @@ #[allow(unused_imports)] use std::ffi::CStr; -use tools_helper::*; -use syscalls::*; +use reverie_tools_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..74ef4f7 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-tools-helper = { path = "../../reverie-tools-helper" } log = { version = "0.4", default-features = false } libc = { version = "0.2", default-features = false } diff --git a/examples/det/src/lib.rs b/examples/det/src/lib.rs index 08d6f31..62d1312 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_tools_helper::{syscalls::*, counter::*, common::local_state::ProcessState, logger}; use log::*; #[allow(unused_imports)] @@ -38,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..f65b769 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-tools-helper = { path = "../../reverie-tools-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/src/dpc.rs b/examples/echo/src/dpc.rs index 11dd4d6..e2a51f8 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_tools_helper::{ common::consts, syscalls::syscall, logger} ; use log::debug; -use tools_helper::common::consts; -use tools_helper::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 ce97d73..1064184 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 tools_helper::counter::{note_syscall, NoteInfo}; -use tools_helper::common::local_state::{ProcessState, ThreadState}; +use reverie_tools_helper::syscalls::*; +use reverie_tools_helper::counter::{note_syscall, NoteInfo}; +use reverie_tools_helper::common::local_state::{ProcessState, ThreadState}; + +use reverie_tools_helper::logger::*; +use reverie_tools_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 7728126..c8c7169 100644 --- a/examples/echo/src/lib.rs +++ b/examples/echo/src/lib.rs @@ -1,7 +1,7 @@ #![feature(format_args_nl, slice_internals)] #![allow(unused_attributes)] -use tools_helper::*; +use reverie_tools_helper::{counter, common, logger}; #[macro_use] pub mod macros; diff --git a/examples/echo/src/show/args.rs b/examples/echo/src/show/args.rs index b5ac059..77256a9 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_tools_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..2a215f4 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_tools_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..f3ffea8 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-tools-helper = { path = "../../reverie-tools-helper" } serde = { version = "1.0", default-features = false, features = [ "derive" ] } [build-dependencies] diff --git a/examples/none/src/lib.rs b/examples/none/src/lib.rs index 57d0e6a..584b3b5 100644 --- a/examples/none/src/lib.rs +++ b/examples/none/src/lib.rs @@ -1,8 +1,7 @@ #![allow(unused_imports)] #![allow(unused_attributes)] -use syscalls::*; -use tools_helper::*; +use reverie_tools_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/common/Cargo.toml b/reverie-common/Cargo.toml similarity index 76% rename from common/Cargo.toml rename to reverie-common/Cargo.toml index d614ddd..47fa90e 100644 --- a/common/Cargo.toml +++ b/reverie-common/Cargo.toml @@ -1,11 +1,15 @@ [package] -name = "common" +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/common/src/consts.rs b/reverie-common/src/consts.rs similarity index 100% rename from common/src/consts.rs rename to reverie-common/src/consts.rs diff --git a/common/src/lib.rs b/reverie-common/src/lib.rs similarity index 100% rename from common/src/lib.rs rename to reverie-common/src/lib.rs diff --git a/common/src/local_state.rs b/reverie-common/src/local_state.rs similarity index 100% rename from common/src/local_state.rs rename to reverie-common/src/local_state.rs diff --git a/common/src/profiling.rs b/reverie-common/src/profiling.rs similarity index 100% rename from common/src/profiling.rs rename to reverie-common/src/profiling.rs diff --git a/common/src/state.rs b/reverie-common/src/state.rs similarity index 100% rename from common/src/state.rs rename to reverie-common/src/state.rs diff --git a/preloader/Cargo.toml b/reverie-preloader/Cargo.toml similarity index 68% rename from preloader/Cargo.toml rename to reverie-preloader/Cargo.toml index e7a71ac..c5a2014 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,13 +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" } -common = { path = "../common" } +reverie-syscalls = { path = "../reverie-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 100% rename from preloader/build.rs rename to reverie-preloader/build.rs 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 98% rename from preloader/src/lib.rs rename to reverie-preloader/src/lib.rs index 64720bc..3d0b6c0 100644 --- a/preloader/src/lib.rs +++ b/reverie-preloader/src/lib.rs @@ -5,8 +5,8 @@ use std::io::Result; pub mod relink; pub mod seccomp_bpf; -use syscalls::*; -use common::consts; +use reverie_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/syscalls/Cargo.toml b/reverie-syscalls/Cargo.toml similarity index 60% rename from syscalls/Cargo.toml rename to reverie-syscalls/Cargo.toml index 70e1548..205df38 100644 --- a/syscalls/Cargo.toml +++ b/reverie-syscalls/Cargo.toml @@ -1,14 +1,14 @@ [package] -name = "syscalls" +name = "reverie-syscalls" version = "0.1.0" authors = ["Baojun Wang "] edition = "2018" [lib] -name = "syscalls" +name = "reverie_syscalls" path = "src/lib.rs" [dependencies] [build-dependencies] -sysnum = { path = "../sysnum" } +reverie-sysnum = { path = "../reverie-sysnum" } diff --git a/syscalls/build.rs b/reverie-syscalls/build.rs similarity index 98% rename from syscalls/build.rs rename to reverie-syscalls/build.rs index 1529cfb..2e0f9ae 100644 --- a/syscalls/build.rs +++ b/reverie-syscalls/build.rs @@ -1,7 +1,7 @@ use std::fs::File; use std::io::{Result, Write}; use std::path::PathBuf; -use sysnum::gen_syscalls; +use reverie_sysnum::gen_syscalls; fn gen_syscall_nrs(dest: PathBuf) -> Result<()> { let mut f = File::create(dest)?; diff --git a/syscalls/src/helper.rs b/reverie-syscalls/src/helper.rs similarity index 100% rename from syscalls/src/helper.rs rename to reverie-syscalls/src/helper.rs diff --git a/syscalls/src/lib.rs b/reverie-syscalls/src/lib.rs similarity index 100% rename from syscalls/src/lib.rs rename to reverie-syscalls/src/lib.rs diff --git a/syscalls/src/macros.rs b/reverie-syscalls/src/macros.rs similarity index 100% rename from syscalls/src/macros.rs rename to reverie-syscalls/src/macros.rs diff --git a/reverie-syscalls/src/nr.rs b/reverie-syscalls/src/nr.rs new file mode 100644 index 0000000..3d85a69 --- /dev/null +++ b/reverie-syscalls/src/nr.rs @@ -0,0 +1,1068 @@ +// AUTOMATICALLY GENERATED BY reverie/syscalls/build.rs. DO NOT EDIT. + +pub use self::SyscallNo::*; +use core::fmt; +#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)] + +#[derive(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 fmt::Debug for SyscallNo { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", SYSCALL_NAMES[self.clone() as usize]) + } +} +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/syscalls/src/raw.rs b/reverie-syscalls/src/raw.rs similarity index 100% rename from syscalls/src/raw.rs rename to reverie-syscalls/src/raw.rs diff --git a/sysnum/Cargo.toml b/reverie-sysnum/Cargo.toml similarity index 62% rename from sysnum/Cargo.toml rename to reverie-sysnum/Cargo.toml index 28896f9..341963f 100644 --- a/sysnum/Cargo.toml +++ b/reverie-sysnum/Cargo.toml @@ -1,8 +1,12 @@ [package] -name = "sysnum" +name = "reverie-sysnum" version = "0.1.0" authors = ["Baojun Wang "] edition = "2018" +[lib] +name = "reverie_sysnum" +path = "src/lib.rs" + [dependencies] tempfile = "3.0" diff --git a/sysnum/src/lib.rs b/reverie-sysnum/src/lib.rs similarity index 100% rename from sysnum/src/lib.rs rename to reverie-sysnum/src/lib.rs diff --git a/tools_helper/Cargo.toml b/reverie-tools-helper/Cargo.toml similarity index 68% rename from tools_helper/Cargo.toml rename to reverie-tools-helper/Cargo.toml index 54d4093..22d3bcb 100644 --- a/tools_helper/Cargo.toml +++ b/reverie-tools-helper/Cargo.toml @@ -1,19 +1,19 @@ [package] -name = "tools_helper" +name = "reverie-tools-helper" version = "0.1.0" authors = ["Baojun Wang "] edition = "2018" [lib] -name = "tools_helper" +name = "reverie_tools_helper" crate-type = ["lib"] [features] std = [] [dependencies] -syscalls = { path = "../syscalls" } -common = { path = "../common" } +reverie-syscalls = { path = "../reverie-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/tools_helper/build.rs b/reverie-tools-helper/build.rs similarity index 100% rename from tools_helper/build.rs rename to reverie-tools-helper/build.rs diff --git a/tools_helper/src/counter.rs b/reverie-tools-helper/src/counter.rs similarity index 92% rename from tools_helper/src/counter.rs rename to reverie-tools-helper/src/counter.rs index 518b9eb..35c06f4 100644 --- a/tools_helper/src/counter.rs +++ b/reverie-tools-helper/src/counter.rs @@ -2,7 +2,7 @@ use std::sync::atomic::Ordering; -use common::local_state::*; +use reverie_common::local_state::*; /// syscall events pub enum NoteInfo { diff --git a/tools_helper/src/ffi.rs b/reverie-tools-helper/src/ffi.rs similarity index 98% rename from tools_helper/src/ffi.rs rename to reverie-tools-helper/src/ffi.rs index 06c6564..564a2eb 100644 --- a/tools_helper/src/ffi.rs +++ b/reverie-tools-helper/src/ffi.rs @@ -8,10 +8,10 @@ /// cdylib is built correctly. use core::ffi::c_void; -use common::consts; -use common::local_state::*; +use reverie_common::consts; +use reverie_common::local_state::*; -use syscalls::*; +use reverie_syscalls::*; static SYSCALL_UNTRACED: u64 = 0x7000_0000; static SYSCALL_TRACED: u64 = 0x7000_0004; diff --git a/tools_helper/src/lib.rs b/reverie-tools-helper/src/lib.rs similarity index 56% rename from tools_helper/src/lib.rs rename to reverie-tools-helper/src/lib.rs index 683a5da..664ecfc 100644 --- a/tools_helper/src/lib.rs +++ b/reverie-tools-helper/src/lib.rs @@ -9,9 +9,5 @@ pub mod spinlock; pub mod counter; pub mod ffi; -pub use counter::note_syscall; -pub use counter::NoteInfo; - -pub use common; -pub use common::local_state::ProcessState; - +pub use reverie_common as common; +pub use reverie_syscalls as syscalls; diff --git a/tools_helper/src/logger.rs b/reverie-tools-helper/src/logger.rs similarity index 99% rename from tools_helper/src/logger.rs rename to reverie-tools-helper/src/logger.rs index 95e1349..43ea2a1 100644 --- a/tools_helper/src/logger.rs +++ b/reverie-tools-helper/src/logger.rs @@ -17,7 +17,7 @@ use log::{Log, Level, Metadata, Record, SetLoggerError}; use core::fmt::{Arguments, Error, Write}; -use syscalls::*; +use reverie_syscalls::*; use crate::spinlock::SpinLock; const RING_BUFF_SIZE: usize = 16384; diff --git a/tools_helper/src/raw_syscall.S b/reverie-tools-helper/src/raw_syscall.S similarity index 100% rename from tools_helper/src/raw_syscall.S rename to reverie-tools-helper/src/raw_syscall.S diff --git a/tools_helper/src/remote_call.S b/reverie-tools-helper/src/remote_call.S similarity index 100% rename from tools_helper/src/remote_call.S rename to reverie-tools-helper/src/remote_call.S diff --git a/tools_helper/src/scinfo.h b/reverie-tools-helper/src/scinfo.h similarity index 100% rename from tools_helper/src/scinfo.h rename to reverie-tools-helper/src/scinfo.h diff --git a/tools_helper/src/spinlock.rs b/reverie-tools-helper/src/spinlock.rs similarity index 98% rename from tools_helper/src/spinlock.rs rename to reverie-tools-helper/src/spinlock.rs index a9c604e..a5943fd 100644 --- a/tools_helper/src/spinlock.rs +++ b/reverie-tools-helper/src/spinlock.rs @@ -6,7 +6,7 @@ //! use core::sync::atomic::{AtomicUsize, Ordering}; -use syscalls::syscall; +use reverie_syscalls::syscall; /// spinlock struct #[derive(Default)] diff --git a/tools_helper/src/trampoline.S b/reverie-tools-helper/src/trampoline.S similarity index 100% rename from tools_helper/src/trampoline.S rename to reverie-tools-helper/src/trampoline.S diff --git a/reverie/Cargo.toml b/reverie/Cargo.toml new file mode 100644 index 0000000..e5edbab --- /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 } +reverie-syscalls = { path = "../reverie-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" +reverie-sysnum = { path = "../reverie-sysnum" } diff --git a/build.rs b/reverie/build.rs similarity index 98% rename from build.rs rename to reverie/build.rs index 4538c49..95e4761 100644 --- a/build.rs +++ b/reverie/build.rs @@ -1,7 +1,7 @@ use std::fs::File; use std::io::{Result, Write}; use std::path::PathBuf; -use sysnum::gen_syscalls; +use reverie_sysnum::gen_syscalls; fn gen_syscall_nrs(dest: PathBuf) -> Result<()> { let mut f = File::create(dest)?; 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..a1feb4d 100644 --- a/src/config.rs +++ b/reverie/src/config.rs @@ -1,49 +1,49 @@ -use syscalls::*; +use reverie_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 93% rename from src/lib.rs rename to reverie/src/lib.rs index 56c92e0..6bf12d8 100644 --- a/src/lib.rs +++ b/reverie/src/lib.rs @@ -10,8 +10,8 @@ #[macro_use] extern crate lazy_static; -pub use syscalls; -pub use common; +pub use reverie_syscalls; +pub use reverie_common; pub mod hooks; pub mod nr; 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 99% rename from src/main.rs rename to reverie/src/main.rs index 8c3156b..bc8514b 100644 --- a/src/main.rs +++ b/reverie/src/main.rs @@ -25,11 +25,11 @@ use reverie::{ns, task, hooks}; use reverie::sched::Scheduler; use reverie::sched_wait::SchedWait; use reverie::task::{RunTask, Task}; -use reverie::common::{state::*, consts}; +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 d329a69..d6c277f 100644 --- a/src/remote.rs +++ b/reverie/src/remote.rs @@ -11,8 +11,8 @@ use std::io::{Error, ErrorKind, Result}; use std::path::PathBuf; use std::ptr::NonNull; -use common::consts; -use common::consts::*; +use reverie_common::consts; +use reverie_common::consts::*; use crate::hooks; use crate::nr; 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 ba35995..4d1a550 100644 --- a/src/rpc_ptrace.rs +++ b/reverie/src/rpc_ptrace.rs @@ -6,7 +6,7 @@ //! NB: the tracee must be in a ptrace stop //! -use common::consts; +use reverie_common::consts; use crate::remote::*; use crate::task::Task; 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 bc48849..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 common::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 58118fd..3120f1a 100644 --- a/src/sched_wait.rs +++ b/reverie/src/sched_wait.rs @@ -11,8 +11,8 @@ use std::sync::atomic::{Ordering, AtomicUsize}; use procfs; -use common::consts; -use common::state::ReverieState; +use reverie_common::consts; +use reverie_common::state::ReverieState; use crate::nr::*; use crate::remote; 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 9945d74..2b1a694 100644 --- a/src/stubs.rs +++ b/reverie/src/stubs.rs @@ -5,7 +5,7 @@ use std::fs::File; use std::io::{Error, ErrorKind, Result, Write}; use std::path::PathBuf; -use common::consts; +use reverie_common::consts; use crate::hooks; 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 5ff096e..5234820 100644 --- a/src/task.rs +++ b/reverie/src/task.rs @@ -8,8 +8,8 @@ use std::io::{Error, ErrorKind, Result}; use std::path::PathBuf; use std::ptr::NonNull; -use common::consts; -use common::consts::*; +use reverie_common::consts; +use reverie_common::consts::*; use crate::hooks; use crate::nr; 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 5640887..78ce5b4 100644 --- a/src/traced_task.rs +++ b/reverie/src/traced_task.rs @@ -36,10 +36,10 @@ use std::ffi::c_void; use std::fs::File; use goblin::elf::Elf; -use common::state::*; -use common::local_state::*; -use common::consts; -use common::consts::*; +use reverie_common::state::*; +use reverie_common::local_state::*; +use reverie_common::consts; +use reverie_common::consts::*; use crate::hooks; use crate::nr::*; 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