|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-03-08 14:13 UTC] felipe@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: felipe
[2011-03-08 14:13 UTC] felipe@php.net
[2011-03-08 15:04 UTC] felipe@php.net
-CVE-ID:
+CVE-ID: 2011-1092
[2021-07-23 09:26 UTC] mr dot sol dot 7788 at gmail dot com
[2021-07-23 09:46 UTC] mr dot sol dot 7788 at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 21:00:01 2025 UTC |
Description: ------------ "The problem is in the shmop_read php function, in the file ext/shmop/shmop.c. This functions reads a given number of bytes from memory, at a given offset starting from a shared memory area. string shmop_read (int shmid, int start, int count) Inside the code of the function itself, there are checks in the start parameter and in the count parameter, to avoid reading arbitrary memory outside the shared memory object: if (start < 0 || start > shmop->size) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "start is out of range"); RETURN_FALSE; } if (start + count > shmop->size || count < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "count is out of range"); RETURN_FALSE; } The first block check if start is lower than 0 or bigger than the size of the shared memory area. The second block checks that the SUM (ADDITION) of "start" and "count" is not greater than the shared memory area, and later checks if count its not lower than 0. The problem is that both variables are signed longs, in 32 bits architectures this means 2^31 maximum value, after this value, the variable becomes negative. So, if we put exactly 2^31 as a value in count, and 1 as a value in start, the first condition: start + count would become negative (2^31+1) and will pass the check, and the second condition (count > 0) will also pass the check, because count its positive (2^31) and do not get negative until the addition of 1." CREDITS: Jose Carlos Norte <jose at eyeos dot org> Test script: --------------- <?php $shm_key = ftok(__FILE__, 't'); $shm_id = shmop_open($shm_key, "c", 0644, 100); $shm_data = shmop_read($shm_id, 1, 2147483647); //if there is no segmentation fault past this point, we have 2gb of memory! echo $shm_data; Expected result: ---------------- No SIGSEGV Actual result: -------------- SIGSEGV