Skip to content

Commit 57f9d1f

Browse files
author
Askar Safin
committed
This commit is part of clone3 clean up. As part of clean up we will
remove tests/ui/command/command-create-pidfd.rs . But it contains very useful comment, so let's move the comment to library/std/src/sys/pal/unix/rand.rs , which contains another instance of the same Docker problem
1 parent f6ee4bf commit 57f9d1f

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

library/std/src/sys/pal/unix/rand.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,18 @@ mod imp {
106106
// supported on the current kernel.
107107
//
108108
// Also fall back in case it is disabled by something like
109-
// seccomp or inside of virtual machines.
109+
// seccomp or inside of docker.
110+
//
111+
// If the `getrandom` syscall is not implemented in the current kernel version it should return an
112+
// `ENOSYS` error. Docker also blocks the whole syscall inside unprivileged containers, and
113+
// returns `EPERM` (instead of `ENOSYS`) when a program tries to invoke the syscall. Because of
114+
// that we need to check for *both* `ENOSYS` and `EPERM`.
115+
//
116+
// Note that Docker's behavior is breaking other projects (notably glibc), so they're planning
117+
// to update their filtering to return `ENOSYS` in a future release:
118+
//
119+
// https://github.com/moby/moby/issues/42680
120+
//
110121
GETRANDOM_UNAVAILABLE.store(true, Ordering::Relaxed);
111122
return false;
112123
} else if err == libc::EAGAIN {

tests/ui/command/command-create-pidfd.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@ fn has_clone3() -> bool {
1616
.then(|| Error::last_os_error())
1717
.expect("probe syscall should not succeed");
1818

19-
// If the `clone3` syscall is not implemented in the current kernel version it should return an
20-
// `ENOSYS` error. Docker also blocks the whole syscall inside unprivileged containers, and
21-
// returns `EPERM` (instead of `ENOSYS`) when a program tries to invoke the syscall. Because of
22-
// that we need to check for *both* `ENOSYS` and `EPERM`.
23-
//
24-
// Note that Docker's behavior is breaking other projects (notably glibc), so they're planning
25-
// to update their filtering to return `ENOSYS` in a future release:
26-
//
27-
// https://github.com/moby/moby/issues/42680
28-
//
2919
err.raw_os_error() != Some(libc::ENOSYS) && err.raw_os_error() != Some(libc::EPERM)
3020
}
3121

0 commit comments

Comments
 (0)