php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71200 incorrect getrandom checks
Submitted: 2015-12-23 00:47 UTC Modified: 2017-01-22 09:32 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: crrodriguez at opensuse dot org Assigned: leigh (profile)
Status: Closed Package: *Compile Issues
PHP Version: master-Git-2015-12-22 (Git) OS: linux
Private report: No CVE-ID: None
 [2015-12-23 00:47 UTC] crrodriguez at opensuse dot org
Description:
------------
getrandom() system call is not used on linux due to incorrect ifdef's.

HAVE_DECL_GETRANDOM is always undefined as there is no declaration of getrandom on the C library or kernel headers and the code that follows does not use it, only the raw syscall interface.

Test script:
---------------
strace -egetrandom php -r 'random_bytes(1);'


Expected result:
----------------
getrandom("\221", 1, 0)                 = 1

Actual result:
--------------
(nothing, getrandom unused)

Patches

fix_getrandom_tests (last revision 2015-12-23 00:49 UTC by crrodriguez at opensuse dot org)

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-23 15:59 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2015-12-23 15:59 UTC] ab@php.net
Thanks for the report. HAVE_DECL_GETRANDOM is generated by autotools, please see ext/standard/config.m4 . Do you mean the getrandom declaration could be missing, but the syscall still available? If so, probably better to check both.

Thanks.
 [2015-12-23 16:10 UTC] crrodriguez at opensuse dot org
-Status: Feedback +Status: Open
 [2015-12-23 16:10 UTC] crrodriguez at opensuse dot org
@ab No I do not mean getrandom() may be missing. There is no getrandom declaration to check for, glibc does not (yet) provide a wrapper to this system call and it is not clear if it ever will.. even if it did, it might end with different semantics or parameters..but this is a moot point as the code does not use it but the syscall interface instead, which case you need to test if you are in linux and if the SYS_getrandom macro is defined.
 [2015-12-23 21:56 UTC] leigh@php.net
@crrodriguez Looks like a simple fix, this works on my system, can you give it a quick test on yours?

https://github.com/lt/php-src/tree/getrandom-fix
 [2015-12-24 01:39 UTC] crrodriguez at opensuse dot org
@leigh That should also work just fine.
 [2017-01-09 05:46 UTC] krakjoe@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: leigh
 [2017-01-09 05:46 UTC] krakjoe@php.net
Leigh can you open a PR on github for this please.
 [2017-01-22 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2017-01-22 09:32 UTC] nikic@php.net
-Status: No Feedback +Status: Closed
 [2017-01-22 09:32 UTC] nikic@php.net
Has been fixed.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 21:01:27 2024 UTC