Commit Graph

540 Commits

Author SHA1 Message Date
Jonah Petri
6c4b9133f1 uclibc support 2022-01-24 10:06:35 -05:00
Alan Somers
475da53d56 Better type safety for mqueue
On some platforms, mqd_t is a pointer.  That means code like the below
can trigger a segfault.  Fix it by defining a Newtype around mqd_t that
prevents use-after-free and dangling pointer scenarios.

```rust
fn invalid_mqd_t() {
    let mqd: libc::mqd_t = std::ptr::null_mut();
    mq_close(mqd).unwrap();
}
```

Also, get test coverage for mqueue in CI on FreeBSD.
2022-01-22 14:48:48 -07:00
bors[bot]
f8e27505f5
Merge #1630
1630: Change port used by test_txtime to avoid conflict r=asomers a=rtzoeller

The socket tests request specific ports, and `test_timestamping` and `test_txtime` are currently conflicting in the port they request.

This leads to the second of the tests failing with `EADDRINUSE` when run locally.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-11 05:15:35 +00:00
Ryan Zoeller
ebd4acebc0 Change port used by test_txtime to avoid conflict 2022-01-10 21:57:55 -06:00
Ryan Zoeller
1b32230831 Add getresuid/gid and setresuid/gid on BSDs 2022-01-10 20:14:34 -06:00
Ryan Zoeller
4d5c090fcf Add sendfile(2) for DragonFly 2022-01-03 04:05:09 -06:00
Ryan Zoeller
b7dd35e9b3 Correct MAP_FIXED documentation for NetBSD
The previous documentation described the default behavior, rather than
the behavior when the flag was set.

Also fix a test which is failing due to passing this flag erroneously.
2022-01-02 16:53:42 -06:00
bors[bot]
c1abab9714
Merge #1624
1624: Fix mq tests on NetBSD and DragonFly r=asomers a=rtzoeller

NetBSD (and DragonFly, which borrows its implementation) include additional flags beyond O_NONBLOCK in MqAttr, such as the flags passed to mq_open(). Modify the mq tests to validate _at least_ the expected flags are set, but don't require strict equality on these platforms.

Verified these tests pass on DragonFly and NetBSD locally.

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2022-01-02 22:32:19 +00:00
Alan Somers
e5b9b972b2 Fix intermittency in test_timer::alarm_fires
The test was disabling the signal handler before disabling the timer.
Fix intermittent failures by:
* Reversing the cleanup order.
* Sleeping for a while before removing the signal handler, since POSIX
  does not guarantee that timer_delete will clear pending signals.

Also, speed up the timer to make the test suite complete faster.
2022-01-02 15:06:24 -07:00
Ryan Zoeller
58d7c04dfb Fix mq tests on NetBSD and DragonFly
NetBSD (and DragonFly, which borrows its implementation) include
additional flags beyond O_NONBLOCK in MqAttr, such as the flags
passed to mq_open().
2022-01-01 22:44:56 -06:00
Brian L. Troutwine
77febe0e6b
Introduce timer_* support
This commit adds support for the signal timer mechanism in POSIX, the
mirror to timerfd on Linux.

Resolves #1424

Signed-off-by: Brian L. Troutwine <brian@troutwine.us>
2021-12-30 20:40:48 -08:00
Alessandro Ghedini
a9829853df Add support for the SO_TXTIME sockopt and SCM_TXTIME control message 2021-12-29 14:15:54 +00:00
bors[bot]
2043bceb5b
Merge #1596 #1621
1596: Add NetBSD configuration for supported process resources r=asomers a=schctl

In addition to existing resources, NetBSD supports `RLIMIT_MEMLOCK`, `RLIMIT_NPROC` and `RLIMIT_RSS`.

https://man.netbsd.org/setrlimit.2

`RLIMIT_AS` is also supported, but it looks like it was added [after version 5.0](https://mail-index.netbsd.org/tech-kern/2009/03/28/msg004702.html), so I'm not sure if that should be enabled.

1621: Add posix_fallocate on DragonFly r=asomers a=rtzoeller

Enable the existing `posix_fallocate()` tests as they are passing locally.

Co-authored-by: Sachin Cherian <sachinctl@protonmail.com>
Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
2021-12-27 18:48:12 +00:00
Ryan Zoeller
1eeccb942e Add posix_fallocate on DragonFly 2021-12-27 02:56:19 -06:00
Ryan Zoeller
57f41a8898 Fix typos 2021-12-26 20:14:50 -06:00
bors[bot]
a392647f45
Merge #1547
1547: feat: Add glibc::SOF_TIMESTAMPING_* support r=asomers a=pacak

Support for kernel and hardware receive timestamps

Co-authored-by: Michael Baikov <manpacket@gmail.com>
2021-12-24 22:20:36 +00:00
Ryan Zoeller
9fe9432181 Disable mknod and mknodat tests on DragonFly 2021-12-24 21:47:39 -06:00
Michael Baikov
9aa61ef975 feat: Add glibc::SOF_TIMESTAMPING_* support 2021-12-23 06:41:30 +08:00
Ryan Zoeller
1fbdd29d45 Enable sched_get/setaffinity on DragonFly BSD 2021-12-22 13:56:16 -06:00
Ryan Zoeller
e5af884251 Recent versions of Android support EPOLLEXCLUSIVE
Enable epoll tests on Android, because they are passing.
2021-12-22 12:59:35 -06:00
Ryan Zoeller
2eb6e88406 DragonFly 6.0 added fexecve(2) 2021-12-21 16:20:48 -06:00
Alan Somers
3c52c56e12 Test preadv and pwritev on more operating systems
This was an oversight from PR #1511
2021-12-14 20:47:29 -07:00
Alan Somers
e7e8abc506 clippy cleanup with the latest nightly 2021-12-11 16:55:15 -07:00
Ryan Zoeller
09bddc3676 Avoid lock poisoning by using parking_lot
parking_lot provides synchronization primitives which aren't
poisoned on panic. This makes it easier to determine which tests
are failing, as a test failure no longer causes all subsequent tests
using that mutex to fail.
2021-11-27 13:50:29 -06:00
taylor.fish
dc80b4cd52 Fix unsoundness in FdSet methods
Ensure file descriptors are nonnegative and less than `FD_SETSIZE`.
(Fixes #1572.)
2021-10-21 21:06:04 -07:00
Haruki Okada
a60703430e Fix return value of posix_fadvise
libc::posix_fadvise returns errnos directly rather than in the errno
variable.
2021-09-28 19:17:48 -06:00
Conrad Meyer
b16e70eebf Fix #411 - Provide accessors for 'events' in PollFd
Test: `cargo test --test test test_pollfd_events`
2021-09-19 17:14:30 -07:00
Alan Somers
f2be3c3fe3 Actually connect the mman tests to the build
This was an oversight from #1306.

Reported-by:	@ocadaruma
2021-09-19 10:11:37 -06:00
Alan Somers
a09b1c8ac6 Clippy cleanup
And this time, start running Clippy in CI
2021-09-19 07:58:15 -06:00
bors[bot]
4f58c8c8e3
Merge #1496
1496: Rework UnixAddr to fix soundness issues r=asomers a=coolreader18

Fixes #1494

I went with making `sun_path` always nul-terminated since that just seems to make things easier, since (at least according to linux man pages) `sockaddr_un`s returned by the kernel will always be nul-terminated.


Co-authored-by: Noa <33094578+coolreader18@users.noreply.github.com>
2021-09-19 02:04:04 +00:00
David Carlier
a477541d78 mman module netbsd additions. 2021-09-12 17:38:45 +01:00
bors[bot]
bf4f2738c9
Merge #1509 #1515
1509: Allow Android to use timerfd r=asomers a=rtzoeller

This is a continuation of #1336 which also enables the timerfd tests.

```
running 3 tests
test sys::test_timerfd::test_timerfd_unset ... ok
test sys::test_timerfd::test_timerfd_oneshot ... ok
test sys::test_timerfd::test_timerfd_interval ... ok
```

1515: Add IP_TTL/IPV6_UNICAST_HOPS SockOpts r=asomers a=cemeyer

Test: `cargo test --test test test_ttl_opts`

Co-authored-by: Ryan Zoeller <rtzoeller@rtzoeller.com>
Co-authored-by: Conrad Meyer <cem@FreeBSD.org>
2021-09-12 03:49:16 +00:00
Conrad Meyer
1ce595f526 Add IP_TTL/IPV6_UNICAST_HOPS SockOpts
Test: `cargo test --test test test_ttl_opts`
2021-09-07 19:19:41 -07:00
Alan Somers
b06c26f16f
Merge branch 'master' into socket-mss 2021-09-07 18:22:54 -06:00
bors[bot]
53fea96dd4
Merge #1516
1516: Implement AsRawFd for PollFd r=asomers a=cemeyer

Implement the trait on PollFd, providing an `as_raw_fd()` accessor to
get the RawFd associated with the PollFd.

Subsumes #1147, #1286.  Closes #1146.

Test: `cargo test --test test test_pollfd_fd`

Co-authored-by: Conrad Meyer <cem@FreeBSD.org>
2021-09-07 23:50:23 +00:00
bors[bot]
630700eb7c
Merge #1317
1317: test_af_alg_aead waits indefinitely r=asomers a=ritzk

Starting with linux kernel 4.9, the crypto interface changed slightly such that the authentication tag memory is only needed in the output buffer for encryption and in the input buffer for decryption. Thus, we have fewer bytes to read than the buffer size. Do not block on read.

alternatively,  we can adjust the decrypted buffer size based on kernel version ( ">= 4.9") to not include auth_size .
```
     if kernel_version >= "4.9":
         let mut decrypted = vec![0u8; payload_len + (assoc_size as usize) ];
```

before 
```
test sys::test_socket::test_af_alg_aead ... test sys::test_socket::test_af_alg_aead has been running for over 60 seconds
```
after
```
test sys::test_socket::test_af_alg_aead ... ok
```


Co-authored-by: Ritesh Khadgaray <khadgaray@gmail.com>
2021-09-07 23:37:26 +00:00
Conrad Meyer
b0b7beb2a8 Implement AsRawFd for PollFd
Implement the trait on PollFd, providing an `as_raw_fd()` accessor to
get the RawFd associated with the PollFd.

Subsumes #1147, #1286.  Closes #1146.

Test: `cargo test --test test test_pollfd_fd`
2021-09-07 08:57:17 -07:00
Conrad Meyer
d23e7c7575 Add support for IP_RECVERR and IPV6_RECVERR
Setting these options enables receiving errors, such as ICMP errors from
the network, via `recvmsg()` with `MSG_ERRQUEUE`.

Adds new `Ipv{4,6}RecvErr` variants to `ControlMessageOwned`.  These
control messages are produced when `Ipv4RecvErr` or `Ipv6RecvErr`
options are enabled on a raw or datagram socket.

New tests for the functionality can be run with `cargo test --test test
test_recverr`.

This commit builds on an earlier draft of the functionality authored by
Matthew McPherrin <git@mcpherrin.ca>.
2021-09-06 16:59:35 -07:00
eaon
67b487283e
Merge branch 'master' into socket-mss 2021-09-04 22:53:24 -04:00
eaon
76fe409f4b
Support for TCP_MAXSEG TCP MSS socket option 2021-09-04 22:39:55 -04:00
Ryan Zoeller
2a31ac127a Allow Android to use timerfd
Co-authored-by: zachoverflow <zach@zachjohnson.net>
2021-08-31 16:40:30 -06:00
Noa
8e963a093f
Rework UnixAddr to fix soundness issues 2021-08-29 17:25:41 -05:00
bors[bot]
48fbce9f8f
Merge #1506
1506: Test Linux aarch64 on real aarch64 hardware. r=asomers a=asomers



Co-authored-by: Alan Somers <asomers@gmail.com>
2021-08-28 14:31:02 +00:00
Alan Somers
18c095b367 Ignore vsock tests on Linux aarch64
Apparently AWS Graviton containers don't support it.  socket() retunrs
EAFNOSUPPORT in that environment.

Also, be more selective about skipping tests under QEMU

Instead of skipping them on architectures where we happen to use QEMU,
only skip them when QEMU is actually being used.
2021-08-27 22:31:20 -06:00
Ryan Zoeller
7ab6731cf6 Print function name and missing capability when skipping tests 2021-08-22 21:27:33 -05:00
Alan Somers
f3cb6b321f Fix building the tests for Redox and Illumos
Also, split the overbroad test_mknod_family into two tests
2021-08-22 10:31:39 -06:00
Noah
c96141d423
Deprecate SockAddr/InetAddr::to_str 2021-08-21 16:59:35 -05:00
Kyle Huey
d133d3db76 Relax assertions in sockaddr_storage_to_addr to match the documentation.
Fixes #1479
2021-08-17 19:26:12 -07:00
bors[bot]
06b5d3344a
Merge #1482
1482: Add support for LOCAL_PEER_CRED r=asomers a=asomers

On FreeBSD and its derivatives, this socket option gets the credentials
of the connected peer.

Co-authored-by: Alan Somers <asomers@gmail.com>
2021-08-11 00:39:47 +00:00
Alan Somers
0d3bc089d5 Add support for LOCAL_PEER_CRED
On FreeBSD and its derivatives, this socket option gets the credentials
of the connected peer.
2021-08-10 17:57:32 -06:00