New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fallback to dev_urandom doesn't work when py_getrandom returns -1 #76761
Comments
I'm playing with Gentoo in LXC running on ARM-based QNAP NAS, and when trying to compile Python 3.5.4, the build failed with "Fatal Python error: failed to get random numbers to initialize Python" (full details at https://forums.gentoo.org/viewtopic-p-8172124.html ). glibc in the environment is 2.25 (supports getrandom), while kernel is 3.10 (doesn't support getrandom). Looking at random.c, pyurandom returns -1 instead of falling back to dev_urandom when py_getrandom returns -1, so the attached fix is simple. |
I'm surprised. Python 3.5.4 does contain my latest fix: commit 035ba5d (bpo-29157).
Ignoring failures is not a good idea. What is the result of the getrandom() function?
I expect n < 0 with errno = ENOSYS: py_getrandom() should return 0 in this case, not -1. |
OK, looks like Qnap is doing something weird there - calls to getrandom result in EFAULT, which results in . PHP had the same problem: https://bugs.php.net/bug.php?id=75409 Changing "if (errno == ENOSYS || errno == EPERM) {" to "if (errno == ENOSYS || errno == EPERM || errno == EFAULT) {" also works. |
OK, looks like Qnap is doing something weird there - calls to getrandom result in EFAULT Aha, first time that I see this error on getrandom(). Is it a kernel change? A libc change? Is Qnap a kind of sandbox? |
Qnap is a NAS, and while I'm running Gentoo inside LXC, EFAULT is returned by getrandom syscall even in the host OS. The model I'm doing this on is TS-228, uname -a of the host OS reports: Linux qnap 3.10.20-al-2.5.3 #67 SMP PREEMPT Sat Dec 30 04:29:34 CST 2017 armv7l unknown This is with the latest firmware installed as of this writing - 4.3.4.0435 (30.12.2017). |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: