From a1030a6379ba4c0003eaeef9c4f1cf1193bff2c9 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 9 May 2017 21:40:13 -0600 Subject: [PATCH 01/45] Move randd from main repo --- Cargo.toml | 7 ++++ src/main.rs | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000000..3b7ebf2492 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "randd" +version = "0.1.0" + +[dependencies] +raw-cpuid = "2.0" +redox_syscall = "0.1" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000000..c15936d1e9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,92 @@ +#![feature(asm)] +#![feature(rand)] + +extern crate syscall; +extern crate raw_cpuid; +extern crate rand; + +use std::fs::File; +use std::io::{Read, Write}; + +use rand::chacha::ChaChaRng; +use rand::Rng; + +use raw_cpuid::CpuId; + +use syscall::{Packet, Result, SchemeMut}; + +//TODO: Use a CSPRNG, allow write of entropy +struct RandScheme { + prng: ChaChaRng +} + +impl SchemeMut for RandScheme { + fn open(&mut self, _path: &[u8], _flags: usize, _uid: u32, _gid: u32) -> Result { + Ok(0) + } + + fn dup(&mut self, file: usize, _buf: &[u8]) -> Result { + Ok(file) + } + + fn read(&mut self, _file: usize, buf: &mut [u8]) -> Result { + let mut i = 0; + for chunk in buf.chunks_mut(8) { + let mut rand = self.prng.next_u64(); + for b in chunk.iter_mut() { + *b = rand as u8; + rand = rand >> 8; + i += 1; + } + } + Ok(i) + } + + fn fpath(&mut self, _file: usize, buf: &mut [u8]) -> Result { + let mut i = 0; + let scheme_path = b"rand"; + while i < buf.len() && i < scheme_path.len() { + buf[i] = scheme_path[i]; + i += 1; + } + Ok(i) + } + + fn close(&mut self, _file: usize) -> Result { + Ok(0) + } +} + +fn main(){ + let has_rdrand = CpuId::new().get_feature_info().unwrap().has_rdrand(); + + // Daemonize + if unsafe { syscall::clone(0).unwrap() } == 0 { + let mut socket = File::create(":rand").expect("rand: failed to create rand scheme"); + + let mut rng = ChaChaRng::new_unseeded(); + + if has_rdrand { + println!("rand: seeding with rdrand"); + let rand: u64; + unsafe { + asm!("rdrand rax" + : "={rax}"(rand) + : + : + : "intel", "volatile"); + } + rng.set_counter(0, rand); + } else { + println!("rand: unseeded"); + } + + let mut scheme = RandScheme{prng: rng}; + loop { + let mut packet = Packet::default(); + socket.read(&mut packet).expect("rand: failed to read events from rand scheme"); + scheme.handle(&mut packet); + socket.write(&packet).expect("rand: failed to write responses to rand scheme"); + } + } +} From fa70dd8072b95aca1f6df912e657d6e58c2262c9 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Sun, 18 Jun 2017 12:56:01 -0700 Subject: [PATCH 02/45] Implement fstat() --- src/main.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main.rs b/src/main.rs index c15936d1e9..a4e98f495f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ use rand::Rng; use raw_cpuid::CpuId; use syscall::{Packet, Result, SchemeMut}; +use syscall::data::Stat; //TODO: Use a CSPRNG, allow write of entropy struct RandScheme { @@ -52,6 +53,15 @@ impl SchemeMut for RandScheme { Ok(i) } + fn fstat(&mut self, id: usize, stat: &mut Stat) -> Result { + *stat = Stat { + st_mode: 0o020000 /*IFCHR*/ | 0o666, + ..Default::default() + }; + + Ok(0) + } + fn close(&mut self, _file: usize) -> Result { Ok(0) } From 369be9ef77a9ef679b96d5d891db3d35f5e36c89 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Mon, 10 Jul 2017 15:51:14 -0700 Subject: [PATCH 03/45] Allow fcntl --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.rs b/src/main.rs index a4e98f495f..e40f45e81f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -62,6 +62,10 @@ impl SchemeMut for RandScheme { Ok(0) } + fn fcntl(&mut self, _id: usize, _cmd: usize, _arg: usize) -> Result { + Ok(0) + } + fn close(&mut self, _file: usize) -> Result { Ok(0) } From 589243ab2c3e2731ddcb3f32f6da6853a72fabfd Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Mon, 10 Jul 2017 16:47:29 -0700 Subject: [PATCH 04/45] Use syscall::MODE_CHR constant --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index e40f45e81f..cce75f9cdf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ use rand::Rng; use raw_cpuid::CpuId; -use syscall::{Packet, Result, SchemeMut}; +use syscall::{Packet, Result, SchemeMut, MODE_CHR}; use syscall::data::Stat; //TODO: Use a CSPRNG, allow write of entropy @@ -55,7 +55,7 @@ impl SchemeMut for RandScheme { fn fstat(&mut self, id: usize, stat: &mut Stat) -> Result { *stat = Stat { - st_mode: 0o020000 /*IFCHR*/ | 0o666, + st_mode: MODE_CHR | 0o666, ..Default::default() }; From bf5f0d0fad01d273eb9df5e30378725002d3aaed Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 22 Jul 2017 13:15:45 -0600 Subject: [PATCH 05/45] Return error when dup buf is not empty --- src/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index cce75f9cdf..de9a8dc4f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,8 +13,8 @@ use rand::Rng; use raw_cpuid::CpuId; -use syscall::{Packet, Result, SchemeMut, MODE_CHR}; -use syscall::data::Stat; +use syscall::{Error, Result, SchemeMut, MODE_CHR}; +use syscall::data::{Packet, Stat}; //TODO: Use a CSPRNG, allow write of entropy struct RandScheme { @@ -26,7 +26,11 @@ impl SchemeMut for RandScheme { Ok(0) } - fn dup(&mut self, file: usize, _buf: &[u8]) -> Result { + fn dup(&mut self, file: usize, buf: &[u8]) -> Result { + if ! buf.is_empty() { + return Err(Error::new(EINVAL)); + } + Ok(file) } From 2cce5b3499a290d023cb866c5fb8b0e8159676bf Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 22 Jul 2017 13:49:12 -0600 Subject: [PATCH 06/45] Add gitignore, add EINVAL import --- .gitignore | 2 ++ src/main.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..fa8d85ac52 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +Cargo.lock +target diff --git a/src/main.rs b/src/main.rs index de9a8dc4f9..95c5651361 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ use rand::Rng; use raw_cpuid::CpuId; -use syscall::{Error, Result, SchemeMut, MODE_CHR}; +use syscall::{Error, Result, SchemeMut, EINVAL, MODE_CHR}; use syscall::data::{Packet, Stat}; //TODO: Use a CSPRNG, allow write of entropy From cd46783126c664421276c075cacce40f420eeb14 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 26 Jul 2017 08:00:17 -0600 Subject: [PATCH 07/45] Add Cargo.lock --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index fa8d85ac52..b83d22266a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -Cargo.lock -target +/target/ From 191273e1ac8060136dccf54647039522e1c314e7 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 26 Jul 2017 08:03:55 -0600 Subject: [PATCH 08/45] Add Cargo.lock file --- Cargo.lock | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000000..3e674a9fdb --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,30 @@ +[root] +name = "randd" +version = "0.1.0" +dependencies = [ + "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "raw-cpuid" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" +"checksum raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" +"checksum redox_syscall 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "80dcf663dc552529b9bfc7bdb30ea12e5fa5d3545137d850a91ad410053f68e9" From 21d50cf7e63733ae2bb9691b2bde4fc14a622a25 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 29 Jul 2017 08:25:04 -0600 Subject: [PATCH 09/45] Update Cargo.lock --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e674a9fdb..ab5d1c7f01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "randd" version = "0.1.0" dependencies = [ "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -21,10 +21,10 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" -"checksum redox_syscall 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "80dcf663dc552529b9bfc7bdb30ea12e5fa5d3545137d850a91ad410053f68e9" +"checksum redox_syscall 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "ddab7acd8e7bf3e49dfdf78ac1209b992329eb2f66e0bf672ab49c70a76d1d68" From b00f1903775edba43ad45de7e292f0f0d15792b5 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 2 Aug 2017 19:52:13 -0600 Subject: [PATCH 10/45] Update Cargo.lock --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab5d1c7f01..f9f1e30ebf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "randd" version = "0.1.0" dependencies = [ "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -21,10 +21,10 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.28" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" -"checksum redox_syscall 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "ddab7acd8e7bf3e49dfdf78ac1209b992329eb2f66e0bf672ab49c70a76d1d68" +"checksum redox_syscall 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "3c9309631a35303bffb47e397198e3668cb544fe8834cd3da2a744441e70e524" From 8c6ba9df54f95a878f81c78ed7ddff63a964eeb8 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 19 Aug 2017 14:46:45 -0600 Subject: [PATCH 11/45] Update Cargo.lock --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f9f1e30ebf..9b567f3abd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "randd" version = "0.1.0" dependencies = [ "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -21,10 +21,10 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.29" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" -"checksum redox_syscall 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)" = "3c9309631a35303bffb47e397198e3668cb544fe8834cd3da2a744441e70e524" +"checksum redox_syscall 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "8312fba776a49cf390b7b62f3135f9b294d8617f7a7592cfd0ac2492b658cd7b" From b0ed813035a2033fab63342677878fdcb2a2f6f8 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 4 Oct 2017 20:29:41 -0600 Subject: [PATCH 12/45] Update Cargo.lock --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b567f3abd..6253014dcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "randd" version = "0.1.0" dependencies = [ "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -21,10 +21,10 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" -"checksum redox_syscall 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "8312fba776a49cf390b7b62f3135f9b294d8617f7a7592cfd0ac2492b658cd7b" +"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" From bcdfbb1dfad5962a4aa2d93b3639f2640d09fc50 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 9 Oct 2017 20:48:34 -0600 Subject: [PATCH 13/45] Utilize null namespace --- src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.rs b/src/main.rs index 95c5651361..6d8d1e9f1a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -100,6 +100,9 @@ fn main(){ } let mut scheme = RandScheme{prng: rng}; + + syscall::setrens(0, 0).expect("randd: failed to enter null namespace"); + loop { let mut packet = Packet::default(); socket.read(&mut packet).expect("rand: failed to read events from rand scheme"); From 1155db75b24880dfd7b6a6236639f80c0922b0fc Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 20 Oct 2017 20:10:03 -0600 Subject: [PATCH 14/45] Create LICENSE --- LICENSE | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..5deeece4f4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Redox OS + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. From fd92da99eb49262e31bb99fbdbff11a5d4266235 Mon Sep 17 00:00:00 2001 From: Robin Randhawa Date: Fri, 17 Nov 2017 17:48:56 +0000 Subject: [PATCH 15/45] Fix breakage due to missing dependency on the rand crate Also update Cargo.lock --- Cargo.lock | 51 +++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 1 + 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6253014dcd..dbdd95766d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,16 +1,47 @@ -[root] -name = "randd" -version = "0.1.0" -dependencies = [ - "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "fuchsia-zircon" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libc" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rand" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "randd" +version = "0.1.0" +dependencies = [ + "rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "raw-cpuid" version = "2.0.2" @@ -26,5 +57,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" +"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159" +"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82" +"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2" +"checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd" "checksum raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" "checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" diff --git a/Cargo.toml b/Cargo.toml index 3b7ebf2492..92baeaa761 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,5 +3,6 @@ name = "randd" version = "0.1.0" [dependencies] +rand = "0.3" raw-cpuid = "2.0" redox_syscall = "0.1" From af245a6db1f1bad7d9a8bf87b60debfa57614a93 Mon Sep 17 00:00:00 2001 From: Robin Randhawa Date: Fri, 17 Nov 2017 17:49:52 +0000 Subject: [PATCH 16/45] Silence build warning due to unused argument The fstat fn's 'id' argument was unused. Changed to '_id' as per compiler suggestion to quiescen warning. --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 6d8d1e9f1a..7605bb8060 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,7 +57,7 @@ impl SchemeMut for RandScheme { Ok(i) } - fn fstat(&mut self, id: usize, stat: &mut Stat) -> Result { + fn fstat(&mut self, _id: usize, stat: &mut Stat) -> Result { *stat = Stat { st_mode: MODE_CHR | 0o666, ..Default::default() From 03e99db648a109c3472e80703556110afa5ecadd Mon Sep 17 00:00:00 2001 From: Tibor Nagy Date: Sat, 18 Nov 2017 04:01:51 +0100 Subject: [PATCH 17/45] Use rand from crates.io The `rand` crate has been removed from the standard library. https://github.com/rust-lang/rust/commit/6bc8f164b09b9994e6a2d4c4ca60d7d36c09d3fe --- Cargo.lock | 51 +++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 1 + 2 files changed, 44 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6253014dcd..dbdd95766d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,16 +1,47 @@ -[root] -name = "randd" -version = "0.1.0" -dependencies = [ - "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "fuchsia-zircon" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libc" +version = "0.2.33" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rand" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "randd" +version = "0.1.0" +dependencies = [ + "rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "raw-cpuid" version = "2.0.2" @@ -26,5 +57,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" +"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159" +"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82" +"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2" +"checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd" "checksum raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" "checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" diff --git a/Cargo.toml b/Cargo.toml index 3b7ebf2492..92baeaa761 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,5 +3,6 @@ name = "randd" version = "0.1.0" [dependencies] +rand = "0.3" raw-cpuid = "2.0" redox_syscall = "0.1" From a7eb42fbeb471db98aa410215606861ac36006d9 Mon Sep 17 00:00:00 2001 From: jD91mZM2 Date: Wed, 29 Aug 2018 17:47:25 +0200 Subject: [PATCH 18/45] Send readable event from fevent This fixes one problem with openssl on relibc, since relibc correctly respects readable/writable status unlike the newlib implementation which always says it's readable. --- src/main.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7605bb8060..5850889f3a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,8 @@ use syscall::data::{Packet, Stat}; //TODO: Use a CSPRNG, allow write of entropy struct RandScheme { - prng: ChaChaRng + socket: File, + prng: ChaChaRng } impl SchemeMut for RandScheme { @@ -66,6 +67,17 @@ impl SchemeMut for RandScheme { Ok(0) } + fn fevent(&mut self, id: usize, _flags: usize) -> Result { + self.socket.write(&syscall::Packet { + a: syscall::SYS_FEVENT, + b: id, + c: syscall::EVENT_READ, + d: 1, + ..Default::default() + })?; + Ok(0) + } + fn fcntl(&mut self, _id: usize, _cmd: usize, _arg: usize) -> Result { Ok(0) } @@ -80,7 +92,7 @@ fn main(){ // Daemonize if unsafe { syscall::clone(0).unwrap() } == 0 { - let mut socket = File::create(":rand").expect("rand: failed to create rand scheme"); + let socket = File::create(":rand").expect("rand: failed to create rand scheme"); let mut rng = ChaChaRng::new_unseeded(); @@ -99,15 +111,15 @@ fn main(){ println!("rand: unseeded"); } - let mut scheme = RandScheme{prng: rng}; + let mut scheme = RandScheme{socket, prng: rng}; syscall::setrens(0, 0).expect("randd: failed to enter null namespace"); loop { let mut packet = Packet::default(); - socket.read(&mut packet).expect("rand: failed to read events from rand scheme"); + scheme.socket.read(&mut packet).expect("rand: failed to read events from rand scheme"); scheme.handle(&mut packet); - socket.write(&packet).expect("rand: failed to write responses to rand scheme"); + scheme.socket.write(&packet).expect("rand: failed to write responses to rand scheme"); } } } From 34cfe146de146f97086b76f71238668636fde07e Mon Sep 17 00:00:00 2001 From: jD91mZM2 Date: Wed, 29 Aug 2018 17:59:03 +0200 Subject: [PATCH 19/45] Fix compilation --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 5850889f3a..4e0f1d1972 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,7 @@ extern crate rand; use std::fs::File; use std::io::{Read, Write}; +use std::os::unix::io::AsRawFd; use rand::chacha::ChaChaRng; use rand::Rng; @@ -68,7 +69,7 @@ impl SchemeMut for RandScheme { } fn fevent(&mut self, id: usize, _flags: usize) -> Result { - self.socket.write(&syscall::Packet { + syscall::write(self.socket.as_raw_fd(), &syscall::Packet { a: syscall::SYS_FEVENT, b: id, c: syscall::EVENT_READ, From c1ddae5ceeb573c86754f68d7138cdf8ac874b52 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 14 Oct 2018 19:56:44 -0600 Subject: [PATCH 20/45] Update Cargo.lock --- Cargo.lock | 74 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dbdd95766d..f838e4a824 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,43 +3,57 @@ name = "bitflags" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "fuchsia-zircon" -version = "0.2.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "fuchsia-zircon-sys" -version = "0.2.0" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "libc" -version = "0.2.33" +version = "0.2.43" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rand" -version = "0.3.18" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "rand" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "randd" version = "0.1.0" dependencies = [ - "rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -52,14 +66,38 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.1.31" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.3.6" +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" [metadata] "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum fuchsia-zircon 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c0581a4e363262e52b87f59ee2afe3415361c6ec35e665924eb08afe8ff159" -"checksum fuchsia-zircon-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "43f3795b4bae048dc6123a6b972cadde2e676f9ded08aef6bb77f5f157684a82" -"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2" -"checksum rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6475140dfd8655aeb72e1fd4b7a1cc1c202be65d71669476e392fe62532b9edd" +"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" +"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" +"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" "checksum raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" -"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" +"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" +"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" +"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" From 0e55459e0e173014c8b3f7e2317b35f28cce51a7 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 12 Nov 2018 15:00:36 -0700 Subject: [PATCH 21/45] Remove unused feature --- src/main.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 4e0f1d1972..d50d6451e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ #![feature(asm)] -#![feature(rand)] extern crate syscall; extern crate raw_cpuid; From 0e613dcc15804e44c665566f07ce0391a41a03d1 Mon Sep 17 00:00:00 2001 From: Robin Randhawa Date: Tue, 15 Jan 2019 12:19:39 +0000 Subject: [PATCH 22/45] aarch64-prep: Wrap x86_64 specific crate references and code with conditionals --- Cargo.toml | 4 +++- src/main.rs | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 92baeaa761..95c8a04049 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,5 +4,7 @@ version = "0.1.0" [dependencies] rand = "0.3" -raw-cpuid = "2.0" redox_syscall = "0.1" + +[target.'cfg(target_arch = "x86_64")'.dependencies] +raw-cpuid = "2.0" diff --git a/src/main.rs b/src/main.rs index d50d6451e0..859e9dd052 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,8 @@ #![feature(asm)] extern crate syscall; + +#[cfg(target_arch = "x86_64")] extern crate raw_cpuid; extern crate rand; @@ -11,6 +13,7 @@ use std::os::unix::io::AsRawFd; use rand::chacha::ChaChaRng; use rand::Rng; +#[cfg(target_arch = "x86_64")] use raw_cpuid::CpuId; use syscall::{Error, Result, SchemeMut, EINVAL, MODE_CHR}; @@ -88,7 +91,12 @@ impl SchemeMut for RandScheme { } fn main(){ - let has_rdrand = CpuId::new().get_feature_info().unwrap().has_rdrand(); + let has_rdrand = false; + + #[cfg(target_arch = "x86_64")] + { + has_rdrand = CpuId::new().get_feature_info().unwrap().has_rdrand(); + } // Daemonize if unsafe { syscall::clone(0).unwrap() } == 0 { From 8e8e4a183737b2522c310b44e0b9643c90ffc559 Mon Sep 17 00:00:00 2001 From: Robin Randhawa Date: Tue, 15 Jan 2019 12:20:37 +0000 Subject: [PATCH 23/45] aarch64-prep: Update Cargo.lock Needed to work with the latest redox_syscall mods. --- Cargo.lock | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f838e4a824..e223bcc490 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,7 +24,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.43" +version = "0.2.47" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -33,27 +33,34 @@ version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.0 (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.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rand_core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "randd" version = "0.1.0" dependencies = [ "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -64,9 +71,17 @@ dependencies = [ "bitflags 0.7.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.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "redox_syscall" -version = "0.1.40" +version = "0.1.50" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -93,11 +108,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d" +"checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" "checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" -"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd" +"checksum rand 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dee497e66d8d76bf08ce20c8d36e16f93749ab0bf89975b4f8ae5cee660c2da2" +"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" "checksum raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" -"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" +"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" +"checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "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" From 43dfc178b54e650fc0ca7018aa2a94ff9acd992e Mon Sep 17 00:00:00 2001 From: Abhishek Bhattacherjee Date: Wed, 16 Jan 2019 09:51:42 +0000 Subject: [PATCH 24/45] Change value to be mutable Fixes #8. --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 859e9dd052..af3597aeb1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -91,7 +91,7 @@ impl SchemeMut for RandScheme { } fn main(){ - let has_rdrand = false; + let mut has_rdrand = false; #[cfg(target_arch = "x86_64")] { From 4b0707e6b2882b3f3d6ea0534d4005f7427b0bfb Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 13 Mar 2019 13:57:49 -0600 Subject: [PATCH 25/45] Support for new fevent --- src/main.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index af3597aeb1..5d3120e0ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,6 +18,7 @@ use raw_cpuid::CpuId; use syscall::{Error, Result, SchemeMut, EINVAL, MODE_CHR}; use syscall::data::{Packet, Stat}; +use syscall::flag::EVENT_READ; //TODO: Use a CSPRNG, allow write of entropy struct RandScheme { @@ -70,15 +71,8 @@ impl SchemeMut for RandScheme { Ok(0) } - fn fevent(&mut self, id: usize, _flags: usize) -> Result { - syscall::write(self.socket.as_raw_fd(), &syscall::Packet { - a: syscall::SYS_FEVENT, - b: id, - c: syscall::EVENT_READ, - d: 1, - ..Default::default() - })?; - Ok(0) + fn fevent(&mut self, _id: usize, _flags: usize) -> Result { + Ok(EVENT_READ) } fn fcntl(&mut self, _id: usize, _cmd: usize, _arg: usize) -> Result { From 953a4b9737746eac2b9901d7c053cd57d90e9352 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 18 Jul 2019 19:51:13 -0600 Subject: [PATCH 26/45] Break on EOF --- Cargo.lock | 2 ++ src/main.rs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index e223bcc490..516e915a84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "bitflags" version = "0.7.0" diff --git a/src/main.rs b/src/main.rs index 5d3120e0ab..508326d484 100644 --- a/src/main.rs +++ b/src/main.rs @@ -119,7 +119,9 @@ fn main(){ loop { let mut packet = Packet::default(); - scheme.socket.read(&mut packet).expect("rand: failed to read events from rand scheme"); + if scheme.socket.read(&mut packet).expect("rand: failed to read events from rand scheme") == 0 { + break; + } scheme.handle(&mut packet); scheme.socket.write(&packet).expect("rand: failed to write responses to rand scheme"); } From 43e8747f0c8e9d0ef1ad99a12abd377a5017b822 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 19 Oct 2019 20:56:31 -0600 Subject: [PATCH 27/45] Update dependencies --- Cargo.lock | 74 ++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 516e915a84..25245035e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,63 +6,56 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "bitflags" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" +name = "fuchsia-cprng" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "libc" -version = "0.2.47" +version = "0.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rand" -version = "0.3.22" +version = "0.3.23" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.65 (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.6 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" -version = "0.3.0" +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 = "randd" version = "0.1.0" dependencies = [ - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)", "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -78,17 +71,17 @@ name = "rdrand" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.1.50" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "winapi" -version = "0.3.6" +version = "0.3.8" 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)", @@ -107,16 +100,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum libc 0.2.47 (registry+https://github.com/rust-lang/crates.io-index)" = "48450664a984b25d5b479554c29cc04e3150c97aa4c01da5604a2d4ed9151476" -"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" -"checksum rand 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "dee497e66d8d76bf08ce20c8d36e16f93749ab0bf89975b4f8ae5cee660c2da2" -"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db" +"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" +"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" +"checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" +"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" +"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 raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" "checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.50 (registry+https://github.com/rust-lang/crates.io-index)" = "52ee9a534dc1301776eff45b4fa92d2c39b1d8c3d3357e6eb593e0d795506fc2" -"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" +"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" "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" From 0eb534417e77fa57db2ca004a8358bed80780a17 Mon Sep 17 00:00:00 2001 From: Kalfar Date: Tue, 7 Jan 2020 22:00:08 +0000 Subject: [PATCH 28/45] Change PRNG to be ChaCha20 PRNG and seeding with 512 bits of entropy from rdrand (if available) Add permissions to scheme operations Add ability to change owner/group/mode Add ability to write entropy to the PRNG scheme Add streaming of ChaCha20 PRNG output based on file open operation. Add not seeded message if rdrand not present on CPU Add extra TODOs for new future work --- Cargo.lock | 141 ++++++++++------- Cargo.toml | 4 +- src/main.rs | 429 ++++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 453 insertions(+), 121 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 25245035e7..4c660ebb37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,56 +6,96 @@ version = "0.7.0" source = "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 = "libc" -version = "0.2.65" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rand" -version = "0.3.23" +name = "block-buffer" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rand" -version = "0.4.6" +name = "block-padding" +version = "0.1.5" 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.65 (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.8 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "rand_core" +name = "byte-tools" version = "0.3.1" 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.3" +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)", + "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "generic-array" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "ppv-lite86" +version = "0.2.6" +source = "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.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rand_core" -version = "0.4.2" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "randd" version = "0.1.0" dependencies = [ - "rand 0.3.23 (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.1 (registry+https://github.com/rust-lang/crates.io-index)", "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -66,49 +106,42 @@ dependencies = [ "bitflags 0.7.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 = "winapi" -version = "0.3.8" +name = "sha2" +version = "0.8.1" 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)", + "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "opaque-debug 0.2.3 (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" +name = "typenum" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" -"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -"checksum libc 0.2.65 (registry+https://github.com/rust-lang/crates.io-index)" = "1a31a0627fdf1f6a39ec0dd577e101440b7db22672c0901fe00a9a6fbb5c24e8" -"checksum rand 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)" = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c" -"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" -"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 block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +"checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" +"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" +"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" +"checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" +"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" +"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" "checksum raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" -"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 winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -"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 sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" +"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" diff --git a/Cargo.toml b/Cargo.toml index 95c8a04049..c29ebdca85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,10 @@ name = "randd" version = "0.1.0" [dependencies] -rand = "0.3" +rand_chacha = "0.2" +rand_core = "0.5" redox_syscall = "0.1" +sha2 = "0.8" [target.'cfg(target_arch = "x86_64")'.dependencies] raw-cpuid = "2.0" diff --git a/src/main.rs b/src/main.rs index 508326d484..1a40e6bc38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,56 +2,369 @@ extern crate syscall; +extern crate rand_chacha; +extern crate rand_core; #[cfg(target_arch = "x86_64")] extern crate raw_cpuid; -extern crate rand; +extern crate sha2; use std::fs::File; use std::io::{Read, Write}; -use std::os::unix::io::AsRawFd; -use rand::chacha::ChaChaRng; -use rand::Rng; +use rand_chacha::ChaCha20Rng; +use rand_core::RngCore; + +pub const MODE_PERM: u16 = 0x0FFF; +pub const MODE_EXEC: u16 = 0o1; +pub const MODE_WRITE: u16 = 0o2; +pub const MODE_READ: u16 = 0o4; #[cfg(target_arch = "x86_64")] use raw_cpuid::CpuId; -use syscall::{Error, Result, SchemeMut, EINVAL, MODE_CHR}; use syscall::data::{Packet, Stat}; use syscall::flag::EVENT_READ; +use syscall::{ + Error, Result, SchemeMut, EBADF, EBADFD, EEXIST, EINVAL, ENOENT, EPERM, MODE_CHR, O_CLOEXEC, + O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_STAT, O_WRONLY, +}; -//TODO: Use a CSPRNG, allow write of entropy +// Create an RNG Seed to create initial seed from the rdrand intel instruction +use rand_core::SeedableRng; +use sha2::{Digest, Sha256}; +use std::collections::BTreeMap; +use std::num::Wrapping; + +// TODO consider adding blocking read based on available entropy as per linux /dev/random +// (compared to /dev/urandom which we are equivalent to) + +// Default file access mode for PRNG +const DEFAULT_PRNG_MODE: u16 = 0o644; +// Rand crate recommends at least 256 bits of entropy to seed the RNG +const SEED_BYTES: usize = 32; + +/// Create a true random seed for the RNG from the Intel x64 rdrand instruction if present. +/// Will seed with a zero (insecure) if rdrand not present. +fn create_rdrand_seed() -> [u8; SEED_BYTES] { + let mut rng = [0; SEED_BYTES]; + let mut have_seeded = false; + #[cfg(target_arch = "x86_64")] + { + if CpuId::new().get_feature_info().unwrap().has_rdrand() { + for i in 0..SEED_BYTES / 8 { + // We get 8 bytes at a time from rdrand instruction + let rand: u64; + unsafe { + asm!("rdrand rax" + : "={rax}"(rand) + : + : + : "intel", "volatile"); + } + + rng[i * 8..(i * 8 + 8)].copy_from_slice(&rand.to_le_bytes()); + } + have_seeded = true; + } + } // TODO integrate alternative entropy sources + if !have_seeded { + println!("randd: Seeding failed, no entropy source. Random numbers on this platform are NOT SECURE"); + } + rng +} + +/// Contains information about an open file +struct OpenFileInfo { + o_flags: usize, + /// Flags used when opening file. + uid: u32, + gid: u32, + file_stat: Stat, +} + +impl OpenFileInfo { + /// Tests if the current user has enough permissions to view the file, op is the operation, + /// like read and write, these modes are MODE_EXEC, MODE_READ, and MODE_WRITE + /// Copied from redoxfs + fn permission(&self, op: u16) -> bool { + let mut perm = self.file_stat.st_mode & 0o7; + if self.uid == self.file_stat.st_uid { + // If self.mode is 101100110, >> 6 would be 000000101 + // 0o7 is octal for 111, or, when expanded to 9 digits is 000000111 + perm |= (self.file_stat.st_mode >> 6) & 0o7; + // Since we erased the GID and OTHER bits when >>6'ing, |= will keep those bits in place. + } + if self.gid == self.file_stat.st_gid || self.file_stat.st_gid == 0 { + perm |= (self.file_stat.st_mode >> 3) & 0o7; + } + if self.uid == 0 { + //set the `other` bits to 111 + perm |= 0o7; + } + perm & op == op + } + fn o_flag_set(&self, f: usize) -> bool { + return (f & self.o_flags) == f; + } +} + +/// Struct to represent the rand scheme. struct RandScheme { socket: File, - prng: ChaChaRng + prng: ChaCha20Rng, + // ChaCha20 is a Cryptographically Secure PRNG + // https://docs.rs/rand/0.5.0/rand/prng/chacha/struct.ChaChaRng.html + // Allows 2^64 streams of random numbers, which we will equate with file numbers + prng_stat: Stat, + open_descriptors: BTreeMap, // Cannot use HashMap as the implementation + // calls the system RNG (us) for entropy to protect against HashDOS attacks. + // Trying to create a HashMap causes a system crash. + // + next_fd: Wrapping, +} + +impl RandScheme { + /// Create new rand scheme from a message socket + fn new(socket: File) -> RandScheme { + RandScheme { + socket, + prng: ChaCha20Rng::from_seed(create_rdrand_seed()), + prng_stat: Stat { + st_mode: MODE_CHR | DEFAULT_PRNG_MODE, + st_gid: 0, + st_uid: 0, + ..Default::default() + }, + open_descriptors: BTreeMap::new(), + next_fd: Wrapping(0), + } + } + + /// Gets the open file info for a file descriptor if it is open - error otherwise. + fn get_fd(&self, fd: usize) -> Result<&OpenFileInfo> { + // Check we've got a valid file descriptor + let file_info = match self.open_descriptors.get(&fd) { + Some(m) => m, + None => return Err(Error::new(EBADF)), + }; + Ok(file_info) + } + /// Checks to see if the op (MODE_READ, MODE_WRITE) can be performed on the open file + /// descriptor - Will return the open file info if successful, and error if the file + /// descriptor is invalid, or the permission is denied. + fn can_perform_op_on_fd(&self, fd: usize, op: u16) -> Result<&OpenFileInfo> { + let file_info = self.get_fd(fd)?; + if !file_info.permission(op) { + return Err(Error::new(EPERM)); + } + Ok(file_info) + } + /// Reseed the CSPRNG with the supplied entropy. + /// TODO add this to an entropy pool and give a limited estimate to the amount of entropy + /// TODO consider having trusted and untrusted entropy URIs, with different permissions. + fn reseed_prng(&mut self, entropy: &[u8]) { + // Need to fill a fixed size array for the from_seed, so we'll do 256 bit + // array and has the entropy into it. + let mut digest = Sha256::new(); + digest.input(entropy); + let hash = digest.result(); + let mut entropy_array: [u8; SEED_BYTES] = [0; SEED_BYTES]; + entropy_array.copy_from_slice(hash.as_slice()); + self.prng = ChaCha20Rng::from_seed(entropy_array); + } +} + +#[test] +fn test_scheme_perms() { + let mut scheme = RandScheme::new(File::open(".").unwrap()); + scheme.prng_stat.st_mode = MODE_CHR | 0o200; + scheme.prng_stat.st_uid = 1; + scheme.prng_stat.st_gid = 1; + assert!(scheme.open("/".as_bytes(), O_RDWR, 1, 1).is_err()); + assert!(scheme.open("/".as_bytes(), O_RDONLY, 1, 1).is_err()); + + scheme.prng_stat.st_mode = MODE_CHR | 0o400; + let mut fd = scheme.open("".as_bytes(), O_RDONLY, 1, 1).unwrap(); + assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); + assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_err()); + assert!(scheme.close(fd).is_ok()); + + assert!(scheme.open("".as_bytes(), O_WRONLY, 1, 1).is_err()); + assert!(scheme.open("".as_bytes(), O_RDWR, 1, 1).is_err()); + + scheme.prng_stat.st_mode = MODE_CHR | 0o600; + fd = scheme.open("".as_bytes(), O_RDWR, 1, 1).unwrap(); + assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); + assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_ok()); + assert!(scheme.close(fd).is_ok()); + + fd = scheme.open("".as_bytes(), O_STAT, 2, 2).unwrap(); + assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_err()); + assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_err()); + assert!(scheme.close(fd).is_ok()); + fd = scheme + .open("".as_bytes(), O_STAT | O_CLOEXEC, 2, 2) + .unwrap(); + assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_err()); + assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_err()); + assert!(scheme.close(fd).is_ok()); + + // Try another user in group (no group perms) + fd = scheme + .open("".as_bytes(), O_STAT | O_CLOEXEC, 2, 1) + .unwrap(); + assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_err()); + assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_err()); + assert!(scheme.close(fd).is_ok()); + scheme.prng_stat.st_mode = MODE_CHR | 0o660; + fd = scheme + .open("".as_bytes(), O_STAT | O_CLOEXEC, 2, 1) + .unwrap(); + assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); + assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_ok()); + assert!(scheme.close(fd).is_ok()); + + // Check root can do anything + scheme.prng_stat.st_mode = MODE_CHR | 0o000; + fd = scheme + .open("".as_bytes(), O_STAT | O_CLOEXEC, 0, 0) + .unwrap(); + assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); + assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_ok()); + assert!(scheme.close(fd).is_ok()); + + // Check the rand:/urandom URL (Equivalent to rand:/) + scheme.prng_stat.st_mode = MODE_CHR | 0o660; + fd = scheme + .open("/urandom".as_bytes(), O_STAT | O_CLOEXEC, 2, 1) + .unwrap(); + assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); + assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_ok()); + assert!(scheme.close(fd).is_ok()); } impl SchemeMut for RandScheme { - fn open(&mut self, _path: &[u8], _flags: usize, _uid: u32, _gid: u32) -> Result { - Ok(0) + fn open(&mut self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result { + // We are only allowing + // reads/writes from rand:/ and rand:/urandom - the root directory on its own is passed as an empty slice + if path != "".as_bytes() && path != "/urandom".as_bytes() { + return Err(Error::new(ENOENT)); + } + if flags & (O_CREAT | O_EXCL) == O_CREAT | O_EXCL { + return Err(Error::new(EEXIST)); + } + + let fd = self.next_fd; + let open_file_info = OpenFileInfo { + o_flags: flags, + file_stat: self.prng_stat, + uid, + gid, + }; + + if (open_file_info.o_flag_set(O_RDONLY) || open_file_info.o_flag_set(O_RDWR)) + && !open_file_info.permission(MODE_READ) + { + return Err(Error::new(EPERM)); + } + if (open_file_info.o_flag_set(O_WRONLY) || open_file_info.o_flag_set(O_RDWR)) + && !open_file_info.permission(MODE_WRITE) + { + return Err(Error::new(EPERM)); + } + self.open_descriptors.insert(fd.0, open_file_info); + // Get the next file descriptor + self.next_fd += Wrapping(1); + // If we've looped round there's a small chance that the file descriptor still exists, so loop till we get one that doesn't + loop { + if !self.open_descriptors.contains_key(&self.next_fd.0) { + break; + } else { + self.next_fd += Wrapping(1); + } + } + Ok(fd.0) + } + + fn chmod(&mut self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result { + // Defer to fchmod + let fd = self.open(path, O_WRONLY, uid, gid)?; + self.fchmod(fd, mode) } fn dup(&mut self, file: usize, buf: &[u8]) -> Result { - if ! buf.is_empty() { + if !buf.is_empty() { return Err(Error::new(EINVAL)); } Ok(file) } + /* Resource operations */ + fn read(&mut self, file: usize, buf: &mut [u8]) -> Result { + // Check fd and permissions + self.can_perform_op_on_fd(file, MODE_READ)?; - fn read(&mut self, _file: usize, buf: &mut [u8]) -> Result { - let mut i = 0; - for chunk in buf.chunks_mut(8) { - let mut rand = self.prng.next_u64(); - for b in chunk.iter_mut() { - *b = rand as u8; - rand = rand >> 8; - i += 1; - } - } - Ok(i) + // Setting the stream will ensure that if two clients are reading concurrently, they won't get the same numbers + self.prng.set_stream(file as u64); // Should probably find a way to re-instate the counter for this stream, but + // not doing so won't make the output any less 'random' + self.prng.fill_bytes(buf); + + Ok(buf.len()) } + fn write(&mut self, file: usize, buf: &[u8]) -> Result { + // Check fd and permissions + self.can_perform_op_on_fd(file, MODE_WRITE)?; + + // TODO - when we support other entropy sources, just add this to an entropy pool + // TODO - consider having trusted and untrusted entropy writing paths + // We have a healthy mistrust of the entropy we're being given, so we won't seed just with + // that as the resulting numbers would be predictable based on this input + // we'll take 512 bits (arbitrary) from the current PRNG, and seed with that + // and the supplied data. + + let mut rng_buf: [u8; SEED_BYTES] = [0; SEED_BYTES]; + self.prng.fill_bytes(&mut rng_buf); + let mut rng_vec = Vec::new(); + rng_vec.extend(&rng_buf); + rng_vec.extend(buf); + self.reseed_prng(&rng_vec); + Ok(buf.len()) + } + + fn fchmod(&mut self, file: usize, mode: u16) -> Result { + // Check fd and permissions + let file_info = self.get_fd(file)?; + // only root and owner can chmod + if file_info.uid != file_info.file_stat.st_uid && file_info.uid != 0 { + return Err(Error::new(EPERM)); + } + + self.prng_stat.st_mode = MODE_CHR | mode; + Ok(0) + } + + fn fchown(&mut self, file: usize, uid: u32, gid: u32) -> Result { + // Check fd and permissions + let file_info = self.get_fd(file)?; + // only root and owner can chmod + if file_info.uid != file_info.file_stat.st_uid && file_info.uid != 0 { + return Err(Error::new(EPERM)); + } + + self.prng_stat.st_uid = uid; + self.prng_stat.st_gid = gid; + Ok(0) + } + + fn fcntl(&mut self, _id: usize, _cmd: usize, _arg: usize) -> Result { + // Just ignore this. + Ok(0) + } + + fn fevent(&mut self, _id: usize, _flags: usize) -> Result { + Ok(EVENT_READ) + } fn fpath(&mut self, _file: usize, buf: &mut [u8]) -> Result { let mut i = 0; let scheme_path = b"rand"; @@ -62,68 +375,52 @@ impl SchemeMut for RandScheme { Ok(i) } - fn fstat(&mut self, _id: usize, stat: &mut Stat) -> Result { - *stat = Stat { - st_mode: MODE_CHR | 0o666, - ..Default::default() - }; + fn fstat(&mut self, file: usize, stat: &mut Stat) -> Result { + // Check fd and permissions + self.can_perform_op_on_fd(file, MODE_READ)?; + + *stat = self.prng_stat.clone(); Ok(0) } - fn fevent(&mut self, _id: usize, _flags: usize) -> Result { - Ok(EVENT_READ) - } - - fn fcntl(&mut self, _id: usize, _cmd: usize, _arg: usize) -> Result { - Ok(0) - } - - fn close(&mut self, _file: usize) -> Result { - Ok(0) + fn close(&mut self, file: usize) -> Result { + // just remove the file descriptor from the open descriptors + match self.open_descriptors.remove(&file) { + Some(_) => Ok(0), + None => Err(Error::new(EBADFD)), + } } } -fn main(){ - let mut has_rdrand = false; - - #[cfg(target_arch = "x86_64")] - { - has_rdrand = CpuId::new().get_feature_info().unwrap().has_rdrand(); - } - +fn main() { // Daemonize if unsafe { syscall::clone(0).unwrap() } == 0 { let socket = File::create(":rand").expect("rand: failed to create rand scheme"); - let mut rng = ChaChaRng::new_unseeded(); - - if has_rdrand { - println!("rand: seeding with rdrand"); - let rand: u64; - unsafe { - asm!("rdrand rax" - : "={rax}"(rand) - : - : - : "intel", "volatile"); - } - rng.set_counter(0, rand); - } else { - println!("rand: unseeded"); - } - - let mut scheme = RandScheme{socket, prng: rng}; + let mut scheme = RandScheme::new(socket); syscall::setrens(0, 0).expect("randd: failed to enter null namespace"); loop { let mut packet = Packet::default(); - if scheme.socket.read(&mut packet).expect("rand: failed to read events from rand scheme") == 0 { - break; + match scheme.socket.read(&mut packet) { + Ok(s) => { + if s == 0 { + break; + } + scheme.handle(&mut packet); + match scheme.socket.write(&packet) { + Err(e) => println!("Error writing packet {}", e), + _ => {} + } + } + Err(e) => println!("Error reading packet {}", e), } - scheme.handle(&mut packet); - scheme.socket.write(&packet).expect("rand: failed to write responses to rand scheme"); + scheme + .socket + .write(&packet) + .expect("rand: failed to write responses to rand scheme"); } } } From 276270fef57e6cbc423ae9bbf4748036bdb061c7 Mon Sep 17 00:00:00 2001 From: Kalfar Date: Mon, 20 Jan 2020 21:32:20 +0000 Subject: [PATCH 29/45] Remove /dev/random TODO comment and add explanation from https://www.2uo.de/myths-about-urandom/ --- src/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1a40e6bc38..edf438ef72 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,8 +35,10 @@ use sha2::{Digest, Sha256}; use std::collections::BTreeMap; use std::num::Wrapping; -// TODO consider adding blocking read based on available entropy as per linux /dev/random -// (compared to /dev/urandom which we are equivalent to) +// This Daemon implements a Cryptographically Secure Random Number Generator +// that does not block on read - i.e. it is equivalent to linux /dev/urandom +// We do not implement blocking reads as per linux /dev/random for the reasons outlined +// here: https://www.2uo.de/myths-about-urandom/ // Default file access mode for PRNG const DEFAULT_PRNG_MODE: u16 = 0o644; From 2f0ad188dd3e0393567fa91567bf1989465507c0 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 2 Aug 2020 15:33:32 -0600 Subject: [PATCH 30/45] Update syscall and raw-cpuid --- Cargo.lock | 83 ++++++++++++++++++++++++++++++++++------------------- Cargo.toml | 2 +- src/main.rs | 4 +-- 3 files changed, 56 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4c660ebb37..67776681e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,7 +2,7 @@ # It is not intended for manual editing. [[package]] name = "bitflags" -version = "0.7.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -12,7 +12,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -31,16 +31,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.3.2" +version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "c2-chacha" -version = "0.2.3" +name = "cc" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "digest" @@ -60,7 +57,7 @@ name = "generic-array" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -70,15 +67,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ppv-lite86" -version = "0.2.6" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rand_chacha" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -91,29 +88,52 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "randd" version = "0.1.0" dependencies = [ - "rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 8.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "raw-cpuid" -version = "2.0.2" +version = "8.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.1.56" +version = "0.1.57" +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 = "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 = "sha2" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -124,24 +144,27 @@ dependencies = [ [[package]] name = "typenum" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" +"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" -"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5" -"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" +"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +"checksum cc 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" -"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853" +"checksum ppv-lite86 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" +"checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -"checksum raw-cpuid 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "13b844e4049605ff38fed943f5c7b2c691fad68d9d5bf074d2720554c4e48246" -"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" -"checksum sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" -"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +"checksum raw-cpuid 8.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cee2c7710d96f9f90f56824fca5438b301dc0fb49ece4cf9dfa044e54067e10" +"checksum redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)" = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +"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 sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +"checksum typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" diff --git a/Cargo.toml b/Cargo.toml index c29ebdca85..b2d94d6b12 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,4 +9,4 @@ redox_syscall = "0.1" sha2 = "0.8" [target.'cfg(target_arch = "x86_64")'.dependencies] -raw-cpuid = "2.0" +raw-cpuid = "8.1" diff --git a/src/main.rs b/src/main.rs index edf438ef72..07deea2c61 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -#![feature(asm)] +#![feature(llvm_asm)] extern crate syscall; @@ -57,7 +57,7 @@ fn create_rdrand_seed() -> [u8; SEED_BYTES] { // We get 8 bytes at a time from rdrand instruction let rand: u64; unsafe { - asm!("rdrand rax" + llvm_asm!("rdrand rax" : "={rax}"(rand) : : From 0485990b0818ab1d05758e6f41a33bf74c4415b0 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 15 Jan 2021 13:03:03 -0700 Subject: [PATCH 31/45] Update redox_syscall --- Cargo.lock | 33 ++++++++++++++++++--------------- Cargo.toml | 2 +- src/main.rs | 8 ++++---- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 67776681e5..52cfee7b7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,7 +12,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -31,12 +31,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.3.4" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.58" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -67,7 +67,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "ppv-lite86" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -75,7 +75,7 @@ name = "rand_chacha" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ppv-lite86 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -90,25 +90,28 @@ version = "0.1.0" dependencies = [ "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-cpuid 8.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 8.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "raw-cpuid" -version = "8.1.1" +version = "8.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.1.57" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "rustc_version" @@ -152,17 +155,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" -"checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" -"checksum cc 1.0.58 (registry+https://github.com/rust-lang/crates.io-index)" = "f9a06fb2e53271d7c279ec1efea6ab691c35a2ae67ec0d91d7acec0caf13b518" +"checksum byteorder 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +"checksum cc 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -"checksum ppv-lite86 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" +"checksum ppv-lite86 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" "checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -"checksum raw-cpuid 8.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0cee2c7710d96f9f90f56824fca5438b301dc0fb49ece4cf9dfa044e54067e10" -"checksum redox_syscall 0.1.57 (registry+https://github.com/rust-lang/crates.io-index)" = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" +"checksum raw-cpuid 8.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73" +"checksum redox_syscall 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "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" diff --git a/Cargo.toml b/Cargo.toml index b2d94d6b12..75cf334654 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" [dependencies] rand_chacha = "0.2" rand_core = "0.5" -redox_syscall = "0.1" +redox_syscall = "0.2.4" sha2 = "0.8" [target.'cfg(target_arch = "x86_64")'.dependencies] diff --git a/src/main.rs b/src/main.rs index 07deea2c61..f99d4c7193 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ pub const MODE_READ: u16 = 0o4; use raw_cpuid::CpuId; use syscall::data::{Packet, Stat}; -use syscall::flag::EVENT_READ; +use syscall::flag::{CloneFlags, EventFlags}; use syscall::{ Error, Result, SchemeMut, EBADF, EBADFD, EEXIST, EINVAL, ENOENT, EPERM, MODE_CHR, O_CLOEXEC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_STAT, O_WRONLY, @@ -364,8 +364,8 @@ impl SchemeMut for RandScheme { Ok(0) } - fn fevent(&mut self, _id: usize, _flags: usize) -> Result { - Ok(EVENT_READ) + fn fevent(&mut self, _id: usize, _flags: EventFlags) -> Result { + Ok(EventFlags::EVENT_READ) } fn fpath(&mut self, _file: usize, buf: &mut [u8]) -> Result { let mut i = 0; @@ -397,7 +397,7 @@ impl SchemeMut for RandScheme { fn main() { // Daemonize - if unsafe { syscall::clone(0).unwrap() } == 0 { + if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0 { let socket = File::create(":rand").expect("rand: failed to create rand scheme"); let mut scheme = RandScheme::new(socket); From 8f833bf5453fd7253976df86ff97d45f0e2c522f Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 28 Apr 2021 20:48:07 -0600 Subject: [PATCH 32/45] Update dependencies --- Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 2 +- src/main.rs | 6 +++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52cfee7b7b..0260d3f99e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,8 +12,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "byteorder 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -31,12 +31,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "byteorder" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.66" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -44,7 +44,7 @@ name = "digest" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -54,10 +54,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "generic-array" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -91,7 +91,7 @@ dependencies = [ "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "raw-cpuid 8.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -101,13 +101,13 @@ version = "8.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.67 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.2.4" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -147,7 +147,7 @@ dependencies = [ [[package]] name = "typenum" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] @@ -155,19 +155,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" -"checksum byteorder 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" -"checksum cc 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)" = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" +"checksum byteorder 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" +"checksum cc 1.0.67 (registry+https://github.com/rust-lang/crates.io-index)" = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" -"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" +"checksum generic-array 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" "checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" "checksum ppv-lite86 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" "checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" "checksum raw-cpuid 8.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73" -"checksum redox_syscall 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570" +"checksum redox_syscall 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "85dd92e586f7355c633911e11f77f3d12f04b1b1bd76a198bd34ae3af8341ef2" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "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 sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -"checksum typenum 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" +"checksum typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" diff --git a/Cargo.toml b/Cargo.toml index 75cf334654..4030e3acbb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" [dependencies] rand_chacha = "0.2" rand_core = "0.5" -redox_syscall = "0.2.4" +redox_syscall = "0.2.7" sha2 = "0.8" [target.'cfg(target_arch = "x86_64")'.dependencies] diff --git a/src/main.rs b/src/main.rs index f99d4c7193..eaa8640ecf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -246,10 +246,10 @@ fn test_scheme_perms() { } impl SchemeMut for RandScheme { - fn open(&mut self, path: &[u8], flags: usize, uid: u32, gid: u32) -> Result { + fn open(&mut self, path: &str, flags: usize, uid: u32, gid: u32) -> Result { // We are only allowing // reads/writes from rand:/ and rand:/urandom - the root directory on its own is passed as an empty slice - if path != "".as_bytes() && path != "/urandom".as_bytes() { + if path != "" && path != "/urandom" { return Err(Error::new(ENOENT)); } if flags & (O_CREAT | O_EXCL) == O_CREAT | O_EXCL { @@ -288,7 +288,7 @@ impl SchemeMut for RandScheme { Ok(fd.0) } - fn chmod(&mut self, path: &[u8], mode: u16, uid: u32, gid: u32) -> Result { + fn chmod(&mut self, path: &str, mode: u16, uid: u32, gid: u32) -> Result { // Defer to fchmod let fd = self.open(path, O_WRONLY, uid, gid)?; self.fchmod(fd, mode) From 280bbcec2a79f49b29d8ae89be64eb5bbb90fd76 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Thu, 17 Jun 2021 14:28:38 +0200 Subject: [PATCH 33/45] Update dependencies. --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0260d3f99e..96b5d2ee4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,7 +36,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cc" -version = "1.0.67" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -91,7 +91,7 @@ dependencies = [ "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "raw-cpuid 8.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -101,13 +101,13 @@ version = "8.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.67 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -156,7 +156,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" "checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" "checksum byteorder 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -"checksum cc 1.0.67 (registry+https://github.com/rust-lang/crates.io-index)" = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" +"checksum cc 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)" = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum generic-array 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" @@ -165,7 +165,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" "checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" "checksum raw-cpuid 8.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73" -"checksum redox_syscall 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "85dd92e586f7355c633911e11f77f3d12f04b1b1bd76a198bd34ae3af8341ef2" +"checksum redox_syscall 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "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" diff --git a/Cargo.toml b/Cargo.toml index 4030e3acbb..1762f9e86d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" [dependencies] rand_chacha = "0.2" rand_core = "0.5" -redox_syscall = "0.2.7" +redox_syscall = "0.2.9" sha2 = "0.8" [target.'cfg(target_arch = "x86_64")'.dependencies] From ca64072b3805cbbd21c748880666316b4699f32b Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 28 Feb 2022 15:13:46 -0700 Subject: [PATCH 34/45] Use syscall::Daemon --- Cargo.lock | 102 ++++++++++++++++++++++++++-------------------------- src/main.rs | 54 +++++++++++++++------------- 2 files changed, 81 insertions(+), 75 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 96b5d2ee4d..bd9b290c4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,173 +1,173 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "block-buffer" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ - "block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "byteorder 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "generic-array 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", + "block-padding", + "byte-tools", + "byteorder", + "generic-array", ] [[package]] name = "block-padding" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" dependencies = [ - "byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "byte-tools", ] [[package]] name = "byte-tools" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.68" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" [[package]] name = "digest" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", + "generic-array", ] [[package]] name = "fake-simd" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "generic-array" version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ - "typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "typenum", ] [[package]] name = "opaque-debug" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "ppv-lite86" -version = "0.2.10" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "rand_chacha" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ - "ppv-lite86 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86", + "rand_core", ] [[package]] name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" [[package]] name = "randd" version = "0.1.0" dependencies = [ - "rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-cpuid 8.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_chacha", + "rand_core", + "raw-cpuid", + "redox_syscall", + "sha2", ] [[package]] name = "raw-cpuid" version = "8.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "cc", + "rustc_version", ] [[package]] name = "redox_syscall" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" dependencies = [ - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", ] [[package]] name = "rustc_version" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver", ] [[package]] name = "semver" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver-parser", ] [[package]] name = "semver-parser" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "sha2" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" dependencies = [ - "block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", - "fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "block-buffer", + "digest", + "fake-simd", + "opaque-debug", ] [[package]] name = "typenum" -version = "1.13.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -"checksum block-padding 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" -"checksum byteorder 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -"checksum cc 1.0.68 (registry+https://github.com/rust-lang/crates.io-index)" = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787" -"checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" -"checksum generic-array 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" -"checksum ppv-lite86 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" -"checksum rand_chacha 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -"checksum raw-cpuid 8.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73" -"checksum redox_syscall 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"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 sha2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -"checksum typenum 1.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" diff --git a/src/main.rs b/src/main.rs index eaa8640ecf..1963fcd865 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ extern crate sha2; use std::fs::File; use std::io::{Read, Write}; +use std::process; use rand_chacha::ChaCha20Rng; use rand_core::RngCore; @@ -23,7 +24,7 @@ pub const MODE_READ: u16 = 0o4; use raw_cpuid::CpuId; use syscall::data::{Packet, Stat}; -use syscall::flag::{CloneFlags, EventFlags}; +use syscall::flag::EventFlags; use syscall::{ Error, Result, SchemeMut, EBADF, EBADFD, EEXIST, EINVAL, ENOENT, EPERM, MODE_CHR, O_CLOEXEC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_STAT, O_WRONLY, @@ -395,34 +396,39 @@ impl SchemeMut for RandScheme { } } -fn main() { - // Daemonize - if unsafe { syscall::clone(CloneFlags::empty()).unwrap() } == 0 { - let socket = File::create(":rand").expect("rand: failed to create rand scheme"); +fn daemon(daemon: syscall::Daemon) -> ! { + let socket = File::create(":rand").expect("randd: failed to create rand scheme"); - let mut scheme = RandScheme::new(socket); + let mut scheme = RandScheme::new(socket); - syscall::setrens(0, 0).expect("randd: failed to enter null namespace"); + daemon.ready().expect("randd: failed to mark daemon as ready"); - loop { - let mut packet = Packet::default(); - match scheme.socket.read(&mut packet) { - Ok(s) => { - if s == 0 { - break; - } - scheme.handle(&mut packet); - match scheme.socket.write(&packet) { - Err(e) => println!("Error writing packet {}", e), - _ => {} - } + syscall::setrens(0, 0).expect("randd: failed to enter null namespace"); + + loop { + let mut packet = Packet::default(); + match scheme.socket.read(&mut packet) { + Ok(s) => { + if s == 0 { + break; + } + scheme.handle(&mut packet); + match scheme.socket.write(&packet) { + Err(e) => println!("Error writing packet {}", e), + _ => {} } - Err(e) => println!("Error reading packet {}", e), } - scheme - .socket - .write(&packet) - .expect("rand: failed to write responses to rand scheme"); + Err(e) => println!("Error reading packet {}", e), } + scheme + .socket + .write(&packet) + .expect("randd: failed to write responses to rand scheme"); } + + process::exit(0); +} + +fn main() { + syscall::Daemon::new(daemon).expect("randd: failed to daemonize"); } From 1804f1a302c46125a6c09530a7b5b8a48ddf4b3c Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Fri, 25 Mar 2022 15:28:35 +0100 Subject: [PATCH 35/45] Update syscall --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/main.rs | 12 ++++-------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd9b290c4a..ef50adf29b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" +checksum = "8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0" dependencies = [ "bitflags", ] diff --git a/Cargo.toml b/Cargo.toml index 1762f9e86d..2a3c0f3cf3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" [dependencies] rand_chacha = "0.2" rand_core = "0.5" -redox_syscall = "0.2.9" +redox_syscall = "0.2.12" sha2 = "0.8" [target.'cfg(target_arch = "x86_64")'.dependencies] diff --git a/src/main.rs b/src/main.rs index 1963fcd865..deaa9cf42e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -#![feature(llvm_asm)] - extern crate syscall; extern crate rand_chacha; @@ -12,6 +10,8 @@ use std::fs::File; use std::io::{Read, Write}; use std::process; +use std::arch::asm; + use rand_chacha::ChaCha20Rng; use rand_core::RngCore; @@ -58,11 +58,7 @@ fn create_rdrand_seed() -> [u8; SEED_BYTES] { // We get 8 bytes at a time from rdrand instruction let rand: u64; unsafe { - llvm_asm!("rdrand rax" - : "={rax}"(rand) - : - : - : "intel", "volatile"); + asm!("rdrand rax", out("rax") rand); } rng[i * 8..(i * 8 + 8)].copy_from_slice(&rand.to_le_bytes()); @@ -396,7 +392,7 @@ impl SchemeMut for RandScheme { } } -fn daemon(daemon: syscall::Daemon) -> ! { +fn daemon(daemon: syscall::Daemon) -> core::convert::Infallible { let socket = File::create(":rand").expect("randd: failed to create rand scheme"); let mut scheme = RandScheme::new(socket); From 3264ab537b4140790b399304afb680a8dbaf505d Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Tue, 26 Jul 2022 16:14:23 -0600 Subject: [PATCH 36/45] Update Cargo.lock --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef50adf29b..67c8a2b9f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -123,9 +123,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.12" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ "bitflags", ] From 934f1307a36d178e6d2b537e88c2d1c99ed43d6f Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Tue, 19 Jul 2022 10:38:19 +0200 Subject: [PATCH 37/45] Use redox-daemon --- Cargo.lock | 15 +++++++++++++++ Cargo.toml | 1 + src/main.rs | 4 ++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 67c8a2b9f4..2808039591 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,6 +71,12 @@ dependencies = [ "typenum", ] +[[package]] +name = "libc" +version = "0.2.126" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" + [[package]] name = "opaque-debug" version = "0.2.3" @@ -106,6 +112,7 @@ dependencies = [ "rand_chacha", "rand_core", "raw-cpuid", + "redox-daemon", "redox_syscall", "sha2", ] @@ -121,6 +128,14 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "redox-daemon" +version = "0.1.0" +dependencies = [ + "libc", + "redox_syscall", +] + [[package]] name = "redox_syscall" version = "0.2.16" diff --git a/Cargo.toml b/Cargo.toml index 2a3c0f3cf3..fcdcbc1aa5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ version = "0.1.0" [dependencies] rand_chacha = "0.2" rand_core = "0.5" +redox-daemon = "0.1" redox_syscall = "0.2.12" sha2 = "0.8" diff --git a/src/main.rs b/src/main.rs index deaa9cf42e..cc39f87cb8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -392,7 +392,7 @@ impl SchemeMut for RandScheme { } } -fn daemon(daemon: syscall::Daemon) -> core::convert::Infallible { +fn daemon(daemon: redox_daemon::Daemon) -> ! { let socket = File::create(":rand").expect("randd: failed to create rand scheme"); let mut scheme = RandScheme::new(socket); @@ -426,5 +426,5 @@ fn daemon(daemon: syscall::Daemon) -> core::convert::Infallible { } fn main() { - syscall::Daemon::new(daemon).expect("randd: failed to daemonize"); + redox_daemon::Daemon::new(daemon).expect("randd: failed to daemonize"); } From 717ece2a542a0494d68be8fffce892b6f6db36ce Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 11 Feb 2023 14:44:22 -0700 Subject: [PATCH 38/45] Update libc crate --- Cargo.lock | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2808039591..581c51df82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,9 +73,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.126" +version = "0.2.139" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "opaque-debug" @@ -131,6 +131,8 @@ dependencies = [ [[package]] name = "redox-daemon" version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21e31c834277709c7ff3eb74959fe62be4b45b1189ba9d41fd3744cd3a9c554f" dependencies = [ "libc", "redox_syscall", From 2e2c4b188810255773606d92add6ecc930539dc3 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Mon, 3 Jul 2023 18:40:58 +0200 Subject: [PATCH 39/45] Fix scheme socket double write. --- src/main.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index cc39f87cb8..b811b61e5c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -416,10 +416,6 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { } Err(e) => println!("Error reading packet {}", e), } - scheme - .socket - .write(&packet) - .expect("randd: failed to write responses to rand scheme"); } process::exit(0); From bdbcb0a0e8a5037279fb4fe52244a923048b7734 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Thu, 31 Aug 2023 20:51:50 +0200 Subject: [PATCH 40/45] Update dependencies. --- Cargo.lock | 27 +++++++++++++++------------ Cargo.toml | 4 ++-- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 581c51df82..ab31016552 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,9 +43,12 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "cc" -version = "1.0.73" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] [[package]] name = "digest" @@ -73,9 +76,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.139" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "opaque-debug" @@ -85,9 +88,9 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "rand_chacha" @@ -130,9 +133,9 @@ dependencies = [ [[package]] name = "redox-daemon" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21e31c834277709c7ff3eb74959fe62be4b45b1189ba9d41fd3744cd3a9c554f" +checksum = "811fd0d382a70c9e9192166ee794567b65ef34cc7309c86a49b071779ca9b5f3" dependencies = [ "libc", "redox_syscall", @@ -140,9 +143,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.16" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ "bitflags", ] @@ -185,6 +188,6 @@ dependencies = [ [[package]] name = "typenum" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" diff --git a/Cargo.toml b/Cargo.toml index fcdcbc1aa5..306bfae7fe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ version = "0.1.0" [dependencies] rand_chacha = "0.2" rand_core = "0.5" -redox-daemon = "0.1" -redox_syscall = "0.2.12" +redox-daemon = "0.1.1" +redox_syscall = "0.3" sha2 = "0.8" [target.'cfg(target_arch = "x86_64")'.dependencies] From dabcfa2158a44546ed19fb4876dbb9a02c2b6b6b Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Thu, 16 Nov 2023 14:22:24 +0100 Subject: [PATCH 41/45] Migrate to libredox and redox-scheme. --- Cargo.lock | 102 +++++++++++++++++++++++++++------------------------- Cargo.toml | 9 +++-- src/main.rs | 78 ++++++++++++---------------------------- 3 files changed, 81 insertions(+), 108 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab31016552..2ee9b3cc52 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,6 +8,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + [[package]] name = "block-buffer" version = "0.7.3" @@ -37,18 +43,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "byteorder" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" - -[[package]] -name = "cc" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "libc", -] +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "digest" @@ -76,9 +73,31 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.147" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall", +] + +[[package]] +name = "libredox" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "962b650e6b934f95cec493e1464e0f5cba98dd9ba9ef2b1c42cdfdb7864cab5a" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall", +] [[package]] name = "opaque-debug" @@ -112,68 +131,53 @@ checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" name = "randd" version = "0.1.0" dependencies = [ + "libredox 0.0.3", "rand_chacha", "rand_core", "raw-cpuid", "redox-daemon", + "redox-scheme", "redox_syscall", "sha2", ] [[package]] name = "raw-cpuid" -version = "8.1.2" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73" +checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" dependencies = [ - "bitflags", - "cc", - "rustc_version", + "bitflags 2.4.1", ] [[package]] name = "redox-daemon" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "811fd0d382a70c9e9192166ee794567b65ef34cc7309c86a49b071779ca9b5f3" +checksum = "353178b5771a301b9d2b318914ab5dfeb21dd6e65930faedde19248cfceca5a7" dependencies = [ "libc", + "libredox 0.0.1", +] + +[[package]] +name = "redox-scheme" +version = "0.1.0" +source = "git+https://gitlab.redox-os.org/redox-os/redox-scheme.git#2c4a85399defee72d25091922450126cdf6130a2" +dependencies = [ + "libredox 0.0.3", "redox_syscall", ] [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "sha2" version = "0.8.2" @@ -188,6 +192,6 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" diff --git a/Cargo.toml b/Cargo.toml index 306bfae7fe..8dde5e6b41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,13 +1,16 @@ [package] name = "randd" version = "0.1.0" +edition = "2021" [dependencies] rand_chacha = "0.2" rand_core = "0.5" -redox-daemon = "0.1.1" -redox_syscall = "0.3" +redox-daemon = "0.1.2" +redox_syscall = "0.4.1" +libredox = "0.0.3" sha2 = "0.8" +redox-scheme = { git = "https://gitlab.redox-os.org/redox-os/redox-scheme.git" } [target.'cfg(target_arch = "x86_64")'.dependencies] -raw-cpuid = "8.1" +raw-cpuid = "11.0.1" diff --git a/src/main.rs b/src/main.rs index b811b61e5c..d841d2006b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,3 @@ -extern crate syscall; - -extern crate rand_chacha; -extern crate rand_core; -#[cfg(target_arch = "x86_64")] -extern crate raw_cpuid; -extern crate sha2; - -use std::fs::File; -use std::io::{Read, Write}; use std::process; use std::arch::asm; @@ -23,10 +13,11 @@ pub const MODE_READ: u16 = 0o4; #[cfg(target_arch = "x86_64")] use raw_cpuid::CpuId; -use syscall::data::{Packet, Stat}; +use redox_scheme::{Socket, SignalBehavior, SchemeMut}; +use syscall::data::Stat; use syscall::flag::EventFlags; use syscall::{ - Error, Result, SchemeMut, EBADF, EBADFD, EEXIST, EINVAL, ENOENT, EPERM, MODE_CHR, O_CLOEXEC, + Error, Result, EBADF, EBADFD, EEXIST, EINVAL, ENOENT, EPERM, MODE_CHR, O_CLOEXEC, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_STAT, O_WRONLY, }; @@ -109,7 +100,7 @@ impl OpenFileInfo { /// Struct to represent the rand scheme. struct RandScheme { - socket: File, + socket: Socket, prng: ChaCha20Rng, // ChaCha20 is a Cryptographically Secure PRNG // https://docs.rs/rand/0.5.0/rand/prng/chacha/struct.ChaChaRng.html @@ -124,7 +115,7 @@ struct RandScheme { impl RandScheme { /// Create new rand scheme from a message socket - fn new(socket: File) -> RandScheme { + fn new(socket: Socket) -> RandScheme { RandScheme { socket, prng: ChaCha20Rng::from_seed(create_rdrand_seed()), @@ -179,30 +170,30 @@ fn test_scheme_perms() { scheme.prng_stat.st_mode = MODE_CHR | 0o200; scheme.prng_stat.st_uid = 1; scheme.prng_stat.st_gid = 1; - assert!(scheme.open("/".as_bytes(), O_RDWR, 1, 1).is_err()); - assert!(scheme.open("/".as_bytes(), O_RDONLY, 1, 1).is_err()); + assert!(scheme.open("/", O_RDWR, 1, 1).is_err()); + assert!(scheme.open("/", O_RDONLY, 1, 1).is_err()); scheme.prng_stat.st_mode = MODE_CHR | 0o400; - let mut fd = scheme.open("".as_bytes(), O_RDONLY, 1, 1).unwrap(); + let mut fd = scheme.open("", O_RDONLY, 1, 1).unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_err()); assert!(scheme.close(fd).is_ok()); - assert!(scheme.open("".as_bytes(), O_WRONLY, 1, 1).is_err()); - assert!(scheme.open("".as_bytes(), O_RDWR, 1, 1).is_err()); + assert!(scheme.open("", O_WRONLY, 1, 1).is_err()); + assert!(scheme.open("", O_RDWR, 1, 1).is_err()); scheme.prng_stat.st_mode = MODE_CHR | 0o600; - fd = scheme.open("".as_bytes(), O_RDWR, 1, 1).unwrap(); + fd = scheme.open("", O_RDWR, 1, 1).unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_ok()); assert!(scheme.close(fd).is_ok()); - fd = scheme.open("".as_bytes(), O_STAT, 2, 2).unwrap(); + fd = scheme.open("", O_STAT, 2, 2).unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_err()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_err()); assert!(scheme.close(fd).is_ok()); fd = scheme - .open("".as_bytes(), O_STAT | O_CLOEXEC, 2, 2) + .open("", O_STAT | O_CLOEXEC, 2, 2) .unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_err()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_err()); @@ -210,14 +201,14 @@ fn test_scheme_perms() { // Try another user in group (no group perms) fd = scheme - .open("".as_bytes(), O_STAT | O_CLOEXEC, 2, 1) + .open("", O_STAT | O_CLOEXEC, 2, 1) .unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_err()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_err()); assert!(scheme.close(fd).is_ok()); scheme.prng_stat.st_mode = MODE_CHR | 0o660; fd = scheme - .open("".as_bytes(), O_STAT | O_CLOEXEC, 2, 1) + .open("", O_STAT | O_CLOEXEC, 2, 1) .unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_ok()); @@ -226,7 +217,7 @@ fn test_scheme_perms() { // Check root can do anything scheme.prng_stat.st_mode = MODE_CHR | 0o000; fd = scheme - .open("".as_bytes(), O_STAT | O_CLOEXEC, 0, 0) + .open("", O_STAT | O_CLOEXEC, 0, 0) .unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_ok()); @@ -235,7 +226,7 @@ fn test_scheme_perms() { // Check the rand:/urandom URL (Equivalent to rand:/) scheme.prng_stat.st_mode = MODE_CHR | 0o660; fd = scheme - .open("/urandom".as_bytes(), O_STAT | O_CLOEXEC, 2, 1) + .open("/urandom", O_STAT | O_CLOEXEC, 2, 1) .unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_ok()); @@ -285,19 +276,6 @@ impl SchemeMut for RandScheme { Ok(fd.0) } - fn chmod(&mut self, path: &str, mode: u16, uid: u32, gid: u32) -> Result { - // Defer to fchmod - let fd = self.open(path, O_WRONLY, uid, gid)?; - self.fchmod(fd, mode) - } - - fn dup(&mut self, file: usize, buf: &[u8]) -> Result { - if !buf.is_empty() { - return Err(Error::new(EINVAL)); - } - - Ok(file) - } /* Resource operations */ fn read(&mut self, file: usize, buf: &mut [u8]) -> Result { // Check fd and permissions @@ -393,29 +371,17 @@ impl SchemeMut for RandScheme { } fn daemon(daemon: redox_daemon::Daemon) -> ! { - let socket = File::create(":rand").expect("randd: failed to create rand scheme"); + let socket = Socket::create("rand").expect("randd: failed to create rand scheme"); let mut scheme = RandScheme::new(socket); daemon.ready().expect("randd: failed to mark daemon as ready"); - syscall::setrens(0, 0).expect("randd: failed to enter null namespace"); + libredox::call::setrens(0, 0).expect("randd: failed to enter null namespace"); - loop { - let mut packet = Packet::default(); - match scheme.socket.read(&mut packet) { - Ok(s) => { - if s == 0 { - break; - } - scheme.handle(&mut packet); - match scheme.socket.write(&packet) { - Err(e) => println!("Error writing packet {}", e), - _ => {} - } - } - Err(e) => println!("Error reading packet {}", e), - } + while let Some(request) = scheme.socket.next_request(SignalBehavior::Restart).expect("error reading packet") { + let response = request.handle_scheme_mut(&mut scheme); + scheme.socket.write_responses(&[response], SignalBehavior::Restart).expect("error writing packet"); } process::exit(0); From a22fc45c0df2455e33bd67e025af617d1c86ea4e Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Sat, 16 Mar 2024 09:56:50 +0100 Subject: [PATCH 42/45] Handle but don't implement scheme cancellation. --- Cargo.lock | 54 +++++++++++++++++++---------------------------------- Cargo.toml | 6 +++--- src/main.rs | 7 +++++-- 3 files changed, 27 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ee9b3cc52..eb816b77f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,15 +4,9 @@ version = 3 [[package]] name = "bitflags" -version = "1.3.2" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "block-buffer" @@ -73,28 +67,17 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.150" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libredox" -version = "0.0.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +checksum = "309ba69985d5170852ebbe8fbb33850d20794d0aed5b210dfea2db798df64e10" dependencies = [ - "bitflags 2.4.1", - "libc", - "redox_syscall", -] - -[[package]] -name = "libredox" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "962b650e6b934f95cec493e1464e0f5cba98dd9ba9ef2b1c42cdfdb7864cab5a" -dependencies = [ - "bitflags 2.4.1", + "bitflags", "libc", "redox_syscall", ] @@ -131,7 +114,7 @@ checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" name = "randd" version = "0.1.0" dependencies = [ - "libredox 0.0.3", + "libredox", "rand_chacha", "rand_core", "raw-cpuid", @@ -147,35 +130,36 @@ version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" dependencies = [ - "bitflags 2.4.1", + "bitflags", ] [[package]] name = "redox-daemon" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "353178b5771a301b9d2b318914ab5dfeb21dd6e65930faedde19248cfceca5a7" +checksum = "7fbdeffdb03cf2961b211a2023e683d71f2c225ea93404da5dc34b0dc94f0341" dependencies = [ "libc", - "libredox 0.0.1", + "libredox", ] [[package]] name = "redox-scheme" -version = "0.1.0" -source = "git+https://gitlab.redox-os.org/redox-os/redox-scheme.git#2c4a85399defee72d25091922450126cdf6130a2" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a4d4161697395d7cc9b182a14a753b2ba0243dcf622e278e644c6e7f74904c1" dependencies = [ - "libredox 0.0.3", + "libredox", "redox_syscall", ] [[package]] name = "redox_syscall" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +checksum = "13c178f952cc7eac391f3124bd9851d1ac0bdbc4c9de2d892ccd5f0d8b160e96" dependencies = [ - "bitflags 1.3.2", + "bitflags", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 8dde5e6b41..7d77129c7c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,10 +7,10 @@ edition = "2021" rand_chacha = "0.2" rand_core = "0.5" redox-daemon = "0.1.2" -redox_syscall = "0.4.1" -libredox = "0.0.3" +redox_syscall = "0.5" +libredox = "0.1.2" sha2 = "0.8" -redox-scheme = { git = "https://gitlab.redox-os.org/redox-os/redox-scheme.git" } +redox-scheme = "0.2" [target.'cfg(target_arch = "x86_64")'.dependencies] raw-cpuid = "11.0.1" diff --git a/src/main.rs b/src/main.rs index d841d2006b..09d7a8b025 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ pub const MODE_READ: u16 = 0o4; #[cfg(target_arch = "x86_64")] use raw_cpuid::CpuId; -use redox_scheme::{Socket, SignalBehavior, SchemeMut}; +use redox_scheme::{RequestKind, SchemeMut, SignalBehavior, Socket}; use syscall::data::Stat; use syscall::flag::EventFlags; use syscall::{ @@ -380,7 +380,10 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { libredox::call::setrens(0, 0).expect("randd: failed to enter null namespace"); while let Some(request) = scheme.socket.next_request(SignalBehavior::Restart).expect("error reading packet") { - let response = request.handle_scheme_mut(&mut scheme); + let RequestKind::Call(call) = request.kind() else { + continue; + }; + let response = call.handle_scheme_mut(&mut scheme); scheme.socket.write_responses(&[response], SignalBehavior::Restart).expect("error writing packet"); } From 1c88eea6c45e24a20100b43f3ae3faf3295048ef Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Sat, 7 Sep 2024 01:02:03 +0200 Subject: [PATCH 43/45] Rustfmt, use v2 scheme. --- Cargo.lock | 87 ++++++++++++++++++++++++++++++++++++++++++++--------- Cargo.toml | 4 +-- src/main.rs | 47 ++++++++++++++--------------- 3 files changed, 98 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb816b77f4..e74dcc1bb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "bitflags" -version = "2.4.2" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block-buffer" @@ -67,15 +67,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.153" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libredox" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "309ba69985d5170852ebbe8fbb33850d20794d0aed5b210dfea2db798df64e10" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags", "libc", @@ -90,9 +90,30 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] [[package]] name = "rand_chacha" @@ -126,9 +147,9 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "11.0.1" +version = "11.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d86a7c4638d42c44551f4791a20e687dbb4c3de1f33c43dd71e355cd429def1" +checksum = "cb9ee317cfe3fbd54b36a511efc1edd42e216903c9cd575e686dd68a2ba90d8d" dependencies = [ "bitflags", ] @@ -145,9 +166,9 @@ dependencies = [ [[package]] name = "redox-scheme" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a4d4161697395d7cc9b182a14a753b2ba0243dcf622e278e644c6e7f74904c1" +checksum = "2148c23b7ed5bf1cc3919b4830e4bf2a674a5d3691c619317624ccd78d13a3ac" dependencies = [ "libredox", "redox_syscall", @@ -155,9 +176,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.0" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c178f952cc7eac391f3124bd9851d1ac0bdbc4c9de2d892ccd5f0d8b160e96" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ "bitflags", ] @@ -174,8 +195,46 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "syn" +version = "2.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml index 7d77129c7c..6d30d0c999 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,9 +8,9 @@ rand_chacha = "0.2" rand_core = "0.5" redox-daemon = "0.1.2" redox_syscall = "0.5" -libredox = "0.1.2" +libredox = "0.1.3" sha2 = "0.8" -redox-scheme = "0.2" +redox-scheme = "0.2.1" [target.'cfg(target_arch = "x86_64")'.dependencies] raw-cpuid = "11.0.1" diff --git a/src/main.rs b/src/main.rs index 09d7a8b025..35399b8eb6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,12 +13,12 @@ pub const MODE_READ: u16 = 0o4; #[cfg(target_arch = "x86_64")] use raw_cpuid::CpuId; -use redox_scheme::{RequestKind, SchemeMut, SignalBehavior, Socket}; +use redox_scheme::{RequestKind, SchemeMut, SignalBehavior, Socket, V2}; use syscall::data::Stat; use syscall::flag::EventFlags; use syscall::{ - Error, Result, EBADF, EBADFD, EEXIST, EINVAL, ENOENT, EPERM, MODE_CHR, O_CLOEXEC, - O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_STAT, O_WRONLY, + Error, Result, EBADF, EBADFD, EEXIST, EINVAL, ENOENT, EPERM, MODE_CHR, O_CLOEXEC, O_CREAT, + O_EXCL, O_RDONLY, O_RDWR, O_STAT, O_WRONLY, }; // Create an RNG Seed to create initial seed from the rdrand intel instruction @@ -192,42 +192,32 @@ fn test_scheme_perms() { assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_err()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_err()); assert!(scheme.close(fd).is_ok()); - fd = scheme - .open("", O_STAT | O_CLOEXEC, 2, 2) - .unwrap(); + fd = scheme.open("", O_STAT | O_CLOEXEC, 2, 2).unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_err()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_err()); assert!(scheme.close(fd).is_ok()); // Try another user in group (no group perms) - fd = scheme - .open("", O_STAT | O_CLOEXEC, 2, 1) - .unwrap(); + fd = scheme.open("", O_STAT | O_CLOEXEC, 2, 1).unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_err()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_err()); assert!(scheme.close(fd).is_ok()); scheme.prng_stat.st_mode = MODE_CHR | 0o660; - fd = scheme - .open("", O_STAT | O_CLOEXEC, 2, 1) - .unwrap(); + fd = scheme.open("", O_STAT | O_CLOEXEC, 2, 1).unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_ok()); assert!(scheme.close(fd).is_ok()); // Check root can do anything scheme.prng_stat.st_mode = MODE_CHR | 0o000; - fd = scheme - .open("", O_STAT | O_CLOEXEC, 0, 0) - .unwrap(); + fd = scheme.open("", O_STAT | O_CLOEXEC, 0, 0).unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_ok()); assert!(scheme.close(fd).is_ok()); // Check the rand:/urandom URL (Equivalent to rand:/) scheme.prng_stat.st_mode = MODE_CHR | 0o660; - fd = scheme - .open("/urandom", O_STAT | O_CLOEXEC, 2, 1) - .unwrap(); + fd = scheme.open("/urandom", O_STAT | O_CLOEXEC, 2, 1).unwrap(); assert!(scheme.can_perform_op_on_fd(fd, MODE_READ).is_ok()); assert!(scheme.can_perform_op_on_fd(fd, MODE_WRITE).is_ok()); assert!(scheme.close(fd).is_ok()); @@ -277,7 +267,7 @@ impl SchemeMut for RandScheme { } /* Resource operations */ - fn read(&mut self, file: usize, buf: &mut [u8]) -> Result { + fn read(&mut self, file: usize, buf: &mut [u8], _offset: u64, _flags: u32) -> Result { // Check fd and permissions self.can_perform_op_on_fd(file, MODE_READ)?; @@ -289,7 +279,7 @@ impl SchemeMut for RandScheme { Ok(buf.len()) } - fn write(&mut self, file: usize, buf: &[u8]) -> Result { + fn write(&mut self, file: usize, buf: &[u8], _offset: u64, _flags: u32) -> Result { // Check fd and permissions self.can_perform_op_on_fd(file, MODE_WRITE)?; @@ -371,20 +361,29 @@ impl SchemeMut for RandScheme { } fn daemon(daemon: redox_daemon::Daemon) -> ! { - let socket = Socket::create("rand").expect("randd: failed to create rand scheme"); + let socket = Socket::::create("rand").expect("randd: failed to create rand scheme"); let mut scheme = RandScheme::new(socket); - daemon.ready().expect("randd: failed to mark daemon as ready"); + daemon + .ready() + .expect("randd: failed to mark daemon as ready"); libredox::call::setrens(0, 0).expect("randd: failed to enter null namespace"); - while let Some(request) = scheme.socket.next_request(SignalBehavior::Restart).expect("error reading packet") { + while let Some(request) = scheme + .socket + .next_request(SignalBehavior::Restart) + .expect("error reading packet") + { let RequestKind::Call(call) = request.kind() else { continue; }; let response = call.handle_scheme_mut(&mut scheme); - scheme.socket.write_responses(&[response], SignalBehavior::Restart).expect("error writing packet"); + scheme + .socket + .write_responses(&[response], SignalBehavior::Restart) + .expect("error writing packet"); } process::exit(0); From 2988e1e0971f4590675f407b41dd26506e585efe Mon Sep 17 00:00:00 2001 From: Andrey Turkin Date: Thu, 17 Oct 2024 08:48:16 +0300 Subject: [PATCH 44/45] Bump dependencies --- Cargo.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e74dcc1bb9..f78bfbc45a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -67,9 +67,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.158" +version = "0.2.160" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "f0b21006cd1874ae9e650973c565615676dc4a274c965bb0a73796dac838ce4f" [[package]] name = "libredox" @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" dependencies = [ "unicode-ident", ] @@ -147,9 +147,9 @@ dependencies = [ [[package]] name = "raw-cpuid" -version = "11.1.0" +version = "11.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb9ee317cfe3fbd54b36a511efc1edd42e216903c9cd575e686dd68a2ba90d8d" +checksum = "1ab240315c661615f2ee9f0f2cd32d5a7343a84d5ebcccb99d46e6637565e7b0" dependencies = [ "bitflags", ] @@ -166,9 +166,9 @@ dependencies = [ [[package]] name = "redox-scheme" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2148c23b7ed5bf1cc3919b4830e4bf2a674a5d3691c619317624ccd78d13a3ac" +checksum = "95624e20d2c1808f7ca0820720d30aad9f5d2fc404e1ef379431ad7a790c3f7e" dependencies = [ "libredox", "redox_syscall", @@ -176,9 +176,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags", ] @@ -197,9 +197,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -214,9 +214,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "zerocopy" From 80e27cb3d923e3a2c91b59122376e18233111a99 Mon Sep 17 00:00:00 2001 From: Ribbon Date: Thu, 9 Jan 2025 12:03:02 +0000 Subject: [PATCH 45/45] Add README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..96c6b227ff --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# randd + +Random number generator daemon. + +## How To Contribute + +To learn how to contribute to this system component you need to read the following document: + +- [CONTRIBUTING.md](https://gitlab.redox-os.org/redox-os/redox/-/blob/master/CONTRIBUTING.md) + +## Development + +To learn how to do development with this system component inside the Redox build system you need to read the [Build System](https://doc.redox-os.org/book/build-system-reference.html) and [Coding and Building](https://doc.redox-os.org/book/coding-and-building.html) pages. + +### How To Build + +To build this system component you need to download the Redox build system, you can learn how to do it on the [Building Redox](https://doc.redox-os.org/book/podman-build.html) page. + +This is necessary because they only work with cross-compilation to a Redox virtual machine, but you can do some testing from Linux.