Bug #74175 [Opn->Dup]: php_random_bytes() failing with php built on system where SYS_getrandom is defnd

From: Date: Mon, 27 Feb 2017 15:48:47 +0000
Subject: Bug #74175 [Opn->Dup]: php_random_bytes() failing with php built on system where SYS_getrandom is defnd
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-207582@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74175&edit=1 ID: 74175 Updated by: requinix@php.net Reported by: lbarnaud@php.net Summary: php_random_bytes() failing with php built on system where SYS_getrandom is defnd -Status: Open +Status: Duplicate Type: Bug Package: Unknown/Other Function Operating System: Linux PHP Version: 7.1.2 Block user comment: N Private report: N New Comment: Duplicate of bug #74105 which has been fixed in master. Previous Comments: ------------------------------------------------------------------------ [2017-02-27 13:11:59] lbarnaud@php.net Description: ------------ - Built PHP on a system where the SYS_getrandom macro is defined - Ran the executable on a Kernel that doesn't implement this syscall - php_random_bytes() is unable to generate random bytes (always returns FAILURE) I stumbled upon this issue by running a "php:7-alpine" Docker container (from https://hub.docker.com/_/php/) on a Debian 8 with a 3.16 kernel. The getrandom syscall is apparently implemented in linux 3.17. The problem became visible when session_regenerate_id() failed with the following error: Failed to create new session ID: user (path: /sessions) Which I traced to php_random_bytes() returning FAILURE. Expected result: ---------------- php_random_bytes() could fallback to other methods, such as readon /dev/urandom, when the "getrandom" syscall is not implemented by the kernel. Actual result: -------------- php_random_bytes() calls syscall(SYS_getrandom, ...). This returns -1, with errno=38. php_random_bytes() returns FAILURE. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74175&edit=1

« previous php.bugs (#207582) next »