Skip to content

Commit

Permalink
Fix bug #81472: Support large device major/minor number
Browse files Browse the repository at this point in the history
Latest linux kernel use large number (12 bits for major device, 20
bits for minor device). Current code only supports previous standard
(5 chars), which means 8 bits for major and 8 bits for minor device.
It will fail if device number is out of that range. So this patch
increases device number read from /proc/self/maps file.

Closes GH-7512.
  • Loading branch information
linericyang authored and nikic committed Sep 24, 2021
1 parent c0dcd14 commit 9ad8fad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ PHP NEWS
. Fixed bug #61700 (FILTER_FLAG_IPV6/FILTER_FLAG_NO_PRIV|RES_RANGE failing).
(cmb, Nikita)

- Opcache:
. Fixed bug #81472 (Cannot support large linux major/minor device number when
read /proc/self/maps). (Lin Yang)

- PCRE:
. Fixed bug #81424 (PCRE2 10.35 JIT performance regression). (cmb)

Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/ZendAccelerator.c
Original file line number Diff line number Diff line change
Expand Up @@ -2803,11 +2803,11 @@ static void accel_move_code_to_huge_pages(void)
f = fopen("/proc/self/maps", "r");
if (f) {
long unsigned int start, end, offset, inode;
char perm[5], dev[6], name[MAXPATHLEN];
char perm[5], dev[10], name[MAXPATHLEN];
int ret;

while (1) {
ret = fscanf(f, "%lx-%lx %4s %lx %5s %ld %s\n", &start, &end, perm, &offset, dev, &inode, name);
ret = fscanf(f, "%lx-%lx %4s %lx %9s %ld %s\n", &start, &end, perm, &offset, dev, &inode, name);
if (ret == 7) {
if (perm[0] == 'r' && perm[1] == '-' && perm[2] == 'x' && name[0] == '/') {
long unsigned int seg_start = ZEND_MM_ALIGNED_SIZE_EX(start, huge_page_size);
Expand Down

0 comments on commit 9ad8fad

Please sign in to comment.