about summary refs log tree commit diff
path: root/library/std/src/sys
AgeCommit message (Collapse)AuthorLines
2020-09-08Capitalize safety commentsFlying-Toast-2/+2
2020-09-07Rollup merge of #76346 - gillespiecd:nlinks-docs, r=Dylan-DPCDylan DPC-2/+2
Docs: nlink example typo Small typo fix for the `nlink` function, extra whitespace before the `use` declaration
2020-09-05Auto merge of #75428 - the8472:fix-copy-eopnotsupp, r=joshtriplettbors-10/+17
Workarounds for copy_file_range issues fixes #75387 fixes #75446
2020-09-04Fix nlink example typoChris Gillespie-2/+2
2020-09-04Add is_enclave_range/is_user_range overflow checksTheodore Cipicchio-8/+34
Functions such as `is_enclave_range` and `is_user_range` in `sgx::os::fortanix_sgx::mem` are often used to make sure memory ranges passed to an enclave from untrusted code or passed to other trusted code functions are safe to use for their intended purpose. Currently, these functions do not perform any checks to make sure the range provided doesn't overflow when adding the range length to the base address. While debug builds will panic if overflow occurs, release builds will simply wrap the result, leading to false positive results for either function. The burden is placed on application authors to know to perform overflow checks on their own before calling these functions, which can easily lead to security vulnerabilities if omitted. Additionally, since such checks are performed in the Intel SGX SDK versions of these functions, developers migrating from Intel SGX SDK code may expect these functions to operate the same. This commit adds explicit overflow checking to `is_enclave_range` and `is_user_range`, returning `false` if overflow occurs in order to prevent misuse of invalid memory ranges. It also alters the checks to account for ranges that lie exactly at the end of the address space, where calculating `p + len` would overflow despite the range being valid.
2020-09-03Improve SGX RWLock initializer testJethro Beekman-23/+11
2020-09-03Auto merge of #76235 - jyn514:std-intra-links, r=poliorceticsbors-2/+5
Convert many files to intra-doc links Helps with https://github.com/rust-lang/rust/issues/75080 r? @poliorcetics I recommend reviewing one commit at a time, but the diff is small enough you can do it all at once if you like :)
2020-09-03Auto merge of #75971 - Amjad50:libstd-deny-unsafe_op_in_unsafe_fn, ↵bors-8/+60
r=Mark-Simulacrum Applied `#![deny(unsafe_op_in_unsafe_fn)]` in library/std/src/wasi partial fix for #73904 There are still more that was not applied in [mod.rs]( https://github.com/rust-lang/rust/blob/38fab2ea92a48980219989817201bf2094ae826a/library/std/src/sys/wasi/mod.rs) and that is due to its using files from `../unsupported` like: ``` #[path = "../unsupported/cmath.rs"] pub mod cmath; ```
2020-09-03Applied `#![deny(unsafe_op_in_unsafe_fn)]` in library/std/src/wasiAmjad Alsharafi-8/+60
All refactoring needed was only in `alloc.rs`, changed part of the code in `alloc` method to satisfy the SAFETY statement
2020-09-02Convert many files to intra-doc linksJoshua Nelson-2/+5
- Use intra-doc links for `std::io` in `std::fs` - Use intra-doc links for File::read in unix/ext/fs.rs - Remove explicit intra-doc links for `true` in `net/addr.rs` - Use intra-doc links in alloc/src/sync.rs - Use intra-doc links in src/ascii.rs - Switch to intra-doc links in alloc/rc.rs - Use intra-doc links in core/pin.rs - Use intra-doc links in std/prelude - Use shorter links in `std/fs.rs` `io` is already in scope.
2020-09-02Update docs of OpenOptions::as_flagsFederico Ponzi-3/+3
2020-08-31Update OpenOptions::as_flags docs, and minor stylingFederico Ponzi-9/+9
2020-08-31Merge branch 'convert-openoptions-cint' of github.com:FedericoPonzi/rust ↵Federico Ponzi-1/+0
into convert-openoptions-cint
2020-08-31Add as_flag function to the OpenOptionsExt structFederico Ponzi-7/+35
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-1182/+1160
Also doing fmt inplace as requested.
2020-08-30Fix typo get openoptions function nameFederico Ponzi-1/+1
Co-authored-by: Ivan Tham <pickfire@riseup.net>
2020-08-30initial implementation of OpenOptions to c_intFederico Ponzi-0/+7
2020-08-30Rollup merge of #75990 - rylev:arm-fastfail, r=alexcrichtonDylan DPC-3/+13
Add __fastfail for Windows on arm/aarch64 Fixes #73215
2020-08-30Rollup merge of #75832 - kofls:intradoc-fix, r=jyn514Dylan DPC-25/+2
Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs… …, primitive_docs.rs & poison.rs Partial fix for #75080 r? @jyn514
2020-08-29Explicitly look for 'thumb-mode' before using __fastfail on 'arm'Ryan Levick-1/+1
2020-08-28Back to opcode for 32 bit ARM __fastfailRyan Levick-1/+1
2020-08-28Switch to asm! macro and use brk instruction on ARMRyan Levick-3/+3
2020-08-27Add __fastfail for Windows on arm/aarch64Ryan Levick-3/+13
2020-08-27Rollup merge of #75758 - bpangWR:master, r=Mark-SimulacrumDylan DPC-14/+5
Fixes for VxWorks r? @alexcrichton
2020-08-26Move to intra-doc links for wasi/ext/fs.rs, os_str_bytes.rs, ↵Surya Midatala-25/+2
primitive_docs.rs & poison.rs
2020-08-25For VxWorks:Pang, Baoshan-14/+5
fix building errors use wr-c++ as linker
2020-08-25Auto merge of #75364 - rylev:libpanic-abort-failfast, r=alexcrichtonbors-8/+4
Call into fastfail on abort in libpanic_abort on Windows x86(_64) This partially resolves #73215 though this is only for x86 targets. This code is directly lifted from [libstd](https://github.com/rust-lang/rust/blob/13290e83a6e20f3b408d177a9d64d8cf98fe4615/library/std/src/sys/windows/mod.rs#L315). `__fastfail` is the preferred way to abort a process on Windows as it will hook into debugger toolchains. Other platforms expose a `_rust_abort` symbol which wraps `std::sys::abort_internal`. This would also work on Windows, but is a slightly largely change as we'd need to make sure that the symbol is properly exposed to the linker. I'm inlining the call to the `__fastfail`, but the indirection through `rust_abort` might be a cleaner approach. A different instruction must be used on ARM architectures. I'd like to verify this works first before tackling ARM.
2020-08-21Make raw standard stream constructors constTomasz Miąsko-27/+27
2020-08-21Remove result type from raw standard streams constructorsTomasz Miąsko-61/+61
Raw standard streams constructors are infallible. Remove unnecessary result type.
2020-08-21Add `#![allow(unsafe_op_in_unsafe_fn)]` in sys/hermitmaekawatoshiki-0/+17
2020-08-21Revert "`#![deny(unsafe_op_in_unsafe_fn)]` in sys/hermit"maekawatoshiki-147/+75
This reverts commit 7cae9e8c88e468e94c157d9aaee4b8e3cf90b9a4.
2020-08-19Enable stack-overflow detection on musl for non-main threadsTomasz Miąsko-6/+21
2020-08-19resolve commentsPrabakaran Kumaresshan-11/+0
2020-08-19Switch to intra-doc links in /src/sys/unix/ext/*.rsPrabakaran Kumaresshan-74/+35
2020-08-16Switch to intra-doc links in /sys/windows/ext/{ffi,fs,process}.rsPrabakaran Kumaresshan-34/+8
2020-08-15inline linkingPrabakaran Kumaresshan-6/+2
2020-08-15remove empty linesPrabakaran Kumaresshan-7/+0
2020-08-15resolve commentsPrabakaran Kumaresshan-16/+8
2020-08-15Switch to intra-doc links in std/src/sys/vxworks/ext/{fs,process}.rsPrabakaran Kumaresshan-19/+19
2020-08-15std/sys/unix/time: make it easier for LLVM to optimize `Instant` subtraction.Eduard-Mihai Burtescu-8/+20
2020-08-14perform copy_file_range until EOF is reached instead of basing things on ↵The8472-3/+12
file size This solves several problems - race conditions where a file is truncated while copying from it. if we blindly trusted the file size this would lead to an infinite loop - proc files appearing empty to copy_file_range but not to read/write https://github.com/coreutils/coreutils/commit/4b04a0c - copy_file_range returning 0 for some filesystems (overlay? bind mounts?) inside docker, again leading to an infinite loop
2020-08-13Rollup merge of #75189 - kawamuray:bugfix-wasi-append, r=KodrAusYuki Okushi-3/+5
Fix wasi::fs::OpenOptions to imply write when append is on This PR fixes a bug in `OpenOptions` of `wasi` platform that it currently doesn't imply write mode when only `append` is enabled. As explained in the [doc of OpenOptions#append](https://doc.rust-lang.org/std/fs/struct.OpenOptions.html#method.append), calling `.append(true)` should imply `.write(true)` as well. ## Reproduce Given below simple Rust program: ```rust use std::fs::OpenOptions; use std::io::Write; fn main() { let mut file = OpenOptions::new() .write(true) .create(true) .open("foo.txt") .unwrap(); writeln!(file, "abc").unwrap(); } ``` it can successfully compiled into wasm and execute by `wasmtime` runtime: ```sh $ rustc --target wasm32-wasi write.rs $ ~/wasmtime/target/debug/wasmtime run --dir=. write.wasm $ cat foo.txt abc ``` However when I change `.write(true)` to `.append(true)`, it fails to execute by the error "Capabilities insufficient": ```sh $ ~/wasmtime/target/debug/wasmtime run --dir=. append.wasm thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 76, kind: Other, message: "Capabilities insufficient" }', append.rs:10:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Error: failed to run main module `append.wasm` ... ``` This is because of lacking "rights" on the opened file: ```sh $ RUST_LOG=trace ~/wasmtime/target/debug/wasmtime run --dir=. append.wasm 2>&1 | grep validate_rights TRACE wasi_common::entry > | validate_rights failed: required rights = HandleRights { base: fd_write (0x40), inheriting: empty (0x0) }; actual rights = HandleRights { base: fd_seek|fd_fdstat_set_flags|fd_sync|fd_tell|fd_advise|fd_filestat_set_times|poll_fd_readwrite (0x88000bc), inheriting: empty (0x0) } ```
2020-08-12more concise error matchingThe8472-8/+4
2020-08-12Workaround for copy_file_range spuriously returning EOPNOTSUPP when attemted ↵The8472-2/+4
on a NFS mount under RHEL/CentOS 7. The syscall is supposed to return ENOSYS in most cases but when calling it on NFS it may leak through EOPNOTSUPP even though that's supposed to be handled by the kernel and not returned to userspace. Since it returns ENOSYS in some cases anyway this will trip the HAS_COPY_FILE_RANGE detection anyway, so treat EOPNOTSUPP as if it were a ENOSYS. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/7.8_release_notes/deprecated_functionality#the_literal_copy_file_range_literal_call_has_been_disabled_on_local_file_systems_and_in_nfs https://bugzilla.redhat.com/show_bug.cgi?id=1783554
2020-08-10Reverse formattingRyan Levick-5/+1
2020-08-10Fix up docsRyan Levick-9/+9
2020-08-09Rollup merge of #74842 - hermitcore:thread_local, r=Mark-SimulacrumYuki Okushi-2/+2
adjust remaining targets - fix commit 7dc3886 - previous commit doesn't adjust all targets
2020-08-08Auto merge of #74289 - lzutao:unroll, r=LukasKalbertodtbors-28/+13
Remove some redundant parts from `unrolled_find_u16s` See each commit message for details. r? @wesleywiser from old PR #67705 .
2020-08-06Keep stdout open in limit_vector_count testTomasz Miąsko-2/+2
2020-08-05Add fallback for cfg(unix) targets that do not define libc::_SC_IOV_MAX.Adam Reichold-0/+7