about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2020-06-28Rename the lint to clashing_extern_declarations.jumbatm-2/+2
Also, run RustFmt on the clashing_extern_fn test case and update stderrs.
2020-06-26Rollup merge of #72937 - AdrianCX:master, r=nikomatsakisManish Goregaokar-5/+9
Fortanix SGX target libunwind build process changes Ticket: https://github.com/fortanix/rust-sgx/issues/174 LLVM related changes (merged): https://github.com/rust-lang/llvm-project/pull/57 Description: libunwind changes needed to run code in sgx environment via rust-sgx. Target that uses this in rust: x86_64-fortanix-unknown-sgx. Without this change, rust std for this toolchain is forced to use a precompiled library loaded via environment variable. With this change we act the same as musl target.
2020-06-26remove some compiler warningsStefan Lankes-3/+1
2020-06-26Map ERROR_INVALID_PARAMETER to InvalidInputTyler Ruckinger-0/+1
2020-06-26reorder crates to pass the format checkStefan Lankes-1/+1
2020-06-26minor changes to pass the format checkStefan Lankes-6/+2
2020-06-26revise RwLock, which is derived from the wasm implementationStefan Lankes-38/+143
- increasing the readability of `Condvar` - simplify the interface to the libos HermitCore
2020-06-25Rollup merge of #72700 - davidtwco:issue-66220-improper-ctypes-declarations, ↵Dylan DPC-0/+1
r=lcnr,varkor `improper_ctypes_definitions` lint Addresses #19834, #66220, and #66373. This PR takes another attempt at #65134 (reverted in #66378). Instead of modifying the existing `improper_ctypes` lint to consider `extern "C" fn` definitions in addition to `extern "C" {}` declarations, this PR adds a new lint - `improper_ctypes_definitions` - which only applies to `extern "C" fn` definitions. In addition, the `improper_ctype_definitions` lint differs from `improper_ctypes` by considering `*T` and `&T` (where `T: Sized`) FFI-safe (addressing #66220). There wasn't a clear consensus in #66220 (where the issues with #65134 were primarily discussed) on the approach to take, but there has [been some discussion in Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.2366220.20improper_ctypes.20definitions.20vs.20declarations/near/198903086). I fully expect that we'll want to iterate on this before landing. cc @varkor + @shepmaster (from #19834) @hanna-kruppe (active in discussing #66220), @SimonSapin (#65134 caused problems for Servo, want to make sure that this PR doesn't)
2020-06-24Rollup merge of #73638 - yuqio:remove-unused-crate-imports, r=nikomatsakisDylan DPC-10/+0
Remove unused crate imports in 2018 edition crates Closes #73570
2020-06-24lints: add `improper_ctypes_definitions`David Wood-0/+1
This commit adds a new lint - `improper_ctypes_definitions` - which functions identically to `improper_ctypes`, but on `extern "C" fn` definitions (as opposed to `improper_ctypes`'s `extern "C" {}` declarations). Signed-off-by: David Wood <david@davidtw.co>
2020-06-24Update libunwind build process for x86_64-fortanix-unknown-sgx targetAdrian Cruceru-5/+9
2020-06-23Remove unused crate imports in 2018 edition cratesyuqio-10/+0
2020-06-23Rollup merge of #73495 - Lucretiel:wasi-io-impls, r=sfacklerDylan DPC-56/+49
Converted all platform-specific stdin/stdout/stderr implementations to use io:: traits Currently, some of the platform-specific standard streams (`src/libstd/sys/*/stdio.rs`) manually implement parts of the `io::Write` interface directly as methods on the struct, rather than by actually implementing the trait. There doesn't seem to be any reason for this, other than an unused advantage of `fn write(&self, ...)` instead of `fn write(&mut self, ...)`. Unfortunately, this means that those implementations don't have the default-implemented io methods, like `read_exact` and `write_all`. This caused #72705, which adds forwarding methods to the user-facing standard stream implementations, to fail to compile on those platforms. This change converts *all* such standard stream structs to use the standard library traits. This change should not cause any breakages, because the changed types are not publicly exported, and in fact are only ever used in `src/libstd/io/stdio.rs`.
2020-06-23Rollup merge of #71756 - carstenandrich:master, r=dtolnayDylan DPC-3/+33
add Windows system error codes that should map to io::ErrorKind::TimedOut closes #71646 **Disclaimer:** The author of this pull request has a negligible amount of experience (i.e., kinda zero) with the Windows API. This PR should _definitely_ be reviewed by someone familiar with the API and its error handling. While porting POSIX software using serial ports to Windows, I found that for many Windows system error codes, an `io::Error` created via `io::Error::from_raw_os_error()` or `io::Error::last_os_error()` is not `io::ErrorKind::TimedOut`. For example, when a (non-overlapped) write to a COM port via [`WriteFile()`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile) times out, [`GetLastError()`](https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror) returns `ERROR_SEM_TIMEOUT` ([121](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-)). However, an `io::Error` created from this error code will have `io::ErrorKind::Other`. Currently, only the error codes `ERROR_OPERATION_ABORTED` and `WSAETIMEDOUT` will instantiate `io::Error`s with kind `io::ErrorKind::TimedOut`. This makes `io::Error::last_os_error()` unsuitable for error handling of syscalls that could time out, because timeouts can not be caught by matching the error's kind against `io::ErrorKind::TimedOut`. Downloading the [list of Windows system error codes](https://gist.github.com/carstenandrich/c331d557520b8a0e7f44689ca257f805) and grepping anything that sounds like a timeout (`egrep -i "timed?.?(out|limit)"`), I've identified the following error codes that should also have `io::ErrorKind::TimedOut`, because they could be I/O-related: Name | Code | Description --- | --- | --- `ERROR_SEM_TIMEOUT` | [121](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-) | The semaphore timeout period has expired. `WAIT_TIMEOUT` | [258](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-) | The wait operation timed out. `ERROR_DRIVER_CANCEL_TIMEOUT` | [594](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--500-999-) | The driver %hs failed to complete a cancelled I/O request in the allotted time. `ERROR_COUNTER_TIMEOUT` | [1121](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--1000-1299-) | A serial I/O operation completed because the timeout period expired. The IOCTL_SERIAL_XOFF_COUNTER did not reach zero.) `ERROR_TIMEOUT` | [1460](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--1300-1699-) | This operation returned because the timeout period expired. `ERROR_CTX_MODEM_RESPONSE_TIMEOUT` | [7012](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--6000-8199-) | The modem did not respond to the command sent to it. Verify that the modem is properly cabled and powered on. `ERROR_CTX_CLIENT_QUERY_TIMEOUT` | [7040](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--6000-8199-) | The client failed to respond to the server connect message. `ERROR_DS_TIMELIMIT_EXCEEDED` | [8226](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--8200-8999-) | The time limit for this request was exceeded. `DNS_ERROR_RECORD_TIMED_OUT` | [9705](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--9000-11999-) | DNS record timed out. `ERROR_IPSEC_IKE_TIMED_OUT` | [13805](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--12000-15999-) | Negotiation timed out. The following errors are also timeouts, but they don't seem to be directly related to I/O or network operations: Name | Code | Description --- | --- | --- `ERROR_SERVICE_REQUEST_TIMEOUT` | [1053](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--1000-1299-) | The service did not respond to the start or control request in a timely fashion. `ERROR_RESOURCE_CALL_TIMED_OUT` | [5910](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--4000-5999-) | The call to the cluster resource DLL timed out. `FRS_ERR_SYSVOL_POPULATE_TIMEOUT` | [8014](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--6000-8199-) | The file replication service cannot populate the system volume because of an internal timeout. The event log may have more information. `ERROR_RUNLEVEL_SWITCH_TIMEOUT` | [15402](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--12000-15999-) | The requested run level switch cannot be completed successfully since one or more services will not stop or restart within the specified timeout. `ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT` | [15403](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--12000-15999-) | A run level switch agent did not respond within the specified timeout. Please note that `ERROR_SEM_TIMEOUT` is the only timeout error I have [seen in action](https://gist.github.com/carstenandrich/10b3962fa1abc9e50816b6460010900b). The remainder of the error codes listed above is based purely on reading documentation. This pull request adds all of the errors listed in both tables, but I'm not sure whether adding all of them makes sense. Someone with actual Windows API experience should decide that. I expect these changes to be fairly backwards compatible, because only the error's [`.kind()`](https://doc.rust-lang.org/std/io/struct.Error.html#method.kind) will change, but matching the error's code via [`.raw_os_error()`](https://doc.rust-lang.org/std/io/struct.Error.html#method.raw_os_error) will not be affected. However, code expecting these errors to be `io::ErrorKind::Other` would break. Even though I personally do not think such an implementation would make sense, after all the docs say that `io::ErrorKind` is _intended to grow over time_, a residual risk remains, of course. I took the liberty to ammend the docstring of `io::ErrorKind::Other` with a remark that discourages matching against it. As per the contributing guidelines I'm adding @steveklabnik due to the changed documentation. Also @retep998 might have some valuable insights on the error codes. r? @steveklabnik cc @retep998 cc @Mark-Simulacrum
2020-06-21Auto merge of #70946 - jumbatm:clashing-extern-decl, r=nagisabors-0/+2
Add a lint to catch clashing `extern` fn declarations. Closes #69390. Adds lint `clashing_extern_decl` to detect when, within a single crate, an extern function of the same name is declared with different types. Because two symbols of the same name cannot be resolved to two different functions at link time, and one function cannot possibly have two types, a clashing extern declaration is almost certainly a mistake. This lint does not run between crates because a project may have dependencies which both rely on the same extern function, but declare it in a different (but valid) way. For example, they may both declare an opaque type for one or more of the arguments (which would end up distinct types), or use types that are valid conversions in the language the extern fn is defined in. In these cases, we can't say that the clashing declaration is incorrect. r? @eddyb
2020-06-20Rollup merge of #73471 - raoulstrackx:raoul/fpu_tag_word, r=jethrogbRalf Jung-12/+8
Prevent attacker from manipulating FPU tag word used in SGX enclave Insufficient sanitization of the x87 FPU tag word in the trusted enclave runtime allowed unprivileged adversaries in the containing host application to induce incoherent or unexpected results for ABI-compliant compiled enclave application code that uses the x87 FPU. Vulnerability was disclosed to us by Fritz Alder, Jo Van Bulck, David Oswald and Frank Piessens cc: @jethrogb
2020-06-20Rollup merge of #73171 - tblah:riscv-qemu-test, r=pietroalbiniRalf Jung-0/+1
RISC-V Emulated Testing Adds a disabled docker image on which to run RISC-V tests. Based on the armhf image. Test using ``` ./src/ci/docker/run.sh riscv64gc-linux ``` cc: @msizanoen1
2020-06-20Add ClashingExternDecl lint.jumbatm-0/+2
This lint checks that all declarations for extern fns of the same name are declared with the same types.
2020-06-19Using xsave restore to restore complete FPU stateRaoul Strackx-12/+1
2020-06-19Remove old commented codeNathan West-2/+0
2020-06-19Fixed missing `mut`Nathan West-1/+1
2020-06-19Converted all platform-specific stdin/stdout/stderr implementations to io traitsNathan West-54/+49
2020-06-18Improve wait_timeout_sgx, simplify usercalls::waitMohsen Zohrevandi-28/+56
2020-06-18Prevent attacker from manipulating FPU tag word used in SGX enclaveRaoul Strackx-0/+7
Insufficient sanitization of the x87 FPU tag word in the trusted enclave runtime allowed unprivileged adversaries in the containing host application to induce incoherent or unexpected results for ABI-compliant compiled enclave application code that uses the x87 FPU. Vulnerability was disclosed to us by Fritz Alder, Jo Van Bulck, David Oswald and Frank Piessens
2020-06-18Document format correctionqy3u-2/+4
2020-06-16Use `Ipv4Addr::from<[u8; 4]>` when possibleLzu Tao-8/+2
2020-06-15remove obsolete , to pass the format checkStefan Lankes-2/+2
2020-06-15add comment about the usage of ArcStefan Lankes-0/+3
2020-06-15use Ipv6Addr::from to build the IPv6 addressStefan Lankes-24/+2
2020-06-15Revert "simplify conversion to IpAddr::V6"Stefan Lankes-2/+18
This reverts commit d221ffc68e543f4a38efcc2bd34f52145f89003b.
2020-06-15Revert "changes to pass the format check"Stefan Lankes-4/+10
This reverts commit 9d596b50f15dfff47fa2272ee63cdc9aeb9307fa.
2020-06-15remove obsolete lineStefan Lankes-1/+0
2020-06-15changes to pass the format checkStefan Lankes-10/+4
2020-06-14simplify conversion to IpAddr::V6Stefan Lankes-18/+2
2020-06-14remove unused functionStefan Lankes-6/+0
2020-06-13add TcpListener support for HermitCoreStefan Lankes-46/+111
Add basic support of TcpListerner for HermitCore. In addition, revise TcpStream to support peer_addr.
2020-06-13add link list of error codes on docs.microsoft.comCarsten Andrich-0/+2
2020-06-12Handle spurious wakeups in wait_timeout_sgxMohsen Zohrevandi-6/+14
2020-06-12Enable some timeouts in SGX platformMohsen Zohrevandi-15/+179
This would partially resolve https://github.com/fortanix/rust-sgx/issues/31
2020-06-10Migrate to numeric associated constsLzu Tao-52/+40
2020-06-09Mark tests whcih don't work under riscv emulationTom Eccles-0/+1
2020-06-07Enable LVI hardening for x86_64-fortanix-unknown-sgxJethro Beekman-5/+15
2020-06-03Bump to 1.46Mark Rousskov-8/+2
2020-05-25Auto merge of #72472 - LeSeulArtichaut:sync-command, r=dtolnaybors-4/+8
Implement `Sync` for `process::Command on unix and vxworks Closes #72387. r? @cuviper
2020-05-22Implement `Sync` for `process::Command on unix and vxworksLeSeulArtichaut-4/+8
2020-05-22Rollup merge of #72123 - jsgf:stabilize-arg0, r=sfacklerRalf Jung-2/+2
Stabilize process_set_argv0 feature for Unix This stabilizes process_set_argv0 targeting 1.45.0. It has been useful in practice and seems useful as-is. The equivalent feature could be implemented for Windows, but as far as I know nobody has. That can be done separately. Tracking issue: #66510
2020-05-18Auto merge of #72289 - RalfJung:abort_internal, r=Mark-Simulacrumbors-18/+26
abort_internal is safe `sys::abort_internal` is stably exposed as a safe function. Forward that assumption "inwards" to the `sys` module by making the function itself safe, too. This corresponds to what https://github.com/rust-lang/rust/pull/72204 did for the intrinsic. We should probably wait until that lands because some of the intrinsic calls in this PR might then need adjustments.
2020-05-18minor changes to pass the format checkStefan Lankes-3/+1
2020-05-17use new interface to initialize CondvarStefan Lankes-4/+4
HermitCore introduce a new interface to intialize conditional variables. Consequently, minor changes are required to support this interface.
2020-05-17abort_internal is safeRalf Jung-18/+26