Make WordPress Core

Changes between Initial Version and Version 2 of Ticket #57050


Ignore:
Timestamp:
11/09/2022 09:19:13 PM (4 years ago)
Author:
costdev
Comment:

@petroski Thanks for opening this ticket and welcome to Trac!

Just cleaning up some ticket properties and noting that this preg_match() call has existed since WordPress 3.0 in changeset [12732].

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #57050

    • Property Component Security → Bootstrap/Load
    • Property Focuses coding-standards removed
    • Property Keywords changes-requested removed
    • Property Version 6.1 → 3.0
  • Ticket #57050 – Description

    initial v2  
    1212For quite some time, ASL has been reporting the following error code hundreds of times a day …
    1313
    14 60027 : Denied a RWX mmap event. An application just attempted to use the mprotect function to bypass memory protection functions in the kernel.
     14  60027 : Denied a RWX mmap event. An application just attempted to use the mprotect function to bypass memory protection functions in the kernel.
    1515
    1616I have contacted Atomic support several times over this issue but the problem is not with their software, it is doing what it is supposed to do. ASL uses their own custom kernel that would deny attempts to bypass memory protection.
    1717
    18 So, digging a little deeper, I find this in my server logs at:
     18So, digging a little deeper, I find this in my server logs at `/var/log/plesk-php74-fpm/error.log`:
    1919
    20 /var/log/plesk-php74-fpm/error.log
    21 
    22 WARNING: [pool xxxxxxxxx.ca] child 23848 said into stderr: “PHP message: PHP Warning: preg_match(): Allocation of JIT memory failed, PCRE JIT will be disabled. This is likely caused by security restrictions. Either grant PHP permission to allocate executable memory, or set pcre.jit=0 in /var/www/vhosts/xxxxxxxxx.ca/httpdocs/wp-includes/load.php on line 43”
     20  WARNING: [pool xxxxxxxxx.ca] child 23848 said into stderr: “PHP message: PHP Warning: preg_match(): Allocation of JIT memory failed, PCRE JIT will be disabled. This is likely caused by security restrictions. Either grant PHP permission to allocate executable memory, or set pcre.jit=0 in /var/www/vhosts/xxxxxxxxx.ca/httpdocs/wp-includes/load.php on line 43”
    2321
    2422So, every time any of the domains on my server loads, this error is generated.
    2523
    26 Looking at the file wp-includes/load.php, here is the errant code ((note lines 42 and 43 as marked)
     24Looking at `wp_fix_server_vars()` in [https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/load.php#L42-L43 wp-includes/load.php], here is the errant code at lines 42-43:
    2725
    28 function wp_fix_server_vars() {
    29         global $PHP_SELF;
     26{{{#!php
     27<?php
    3028
    31         $default_server_values = array(
    32                 'SERVER_SOFTWARE' => '',
    33                 'REQUEST_URI'     => '',
    34         );
    35 
    36         $_SERVER = array_merge( $default_server_values, $_SERVER );
    37 
    38 Line 42 // Fix for IIS when running with PHP ISAPI.
    39 Line 43 if ( empty( $_SERVER['REQUEST_URI'] ) || ( 'cgi-fcgi' !== PHP_SAPI && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
    40 
    41                 if ( isset( $_SERVER['HTTP_X_ORIGINAL_URL'] ) ) {
    42                         // IIS Mod-Rewrite.
    43                         $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
    44                 } elseif ( isset( $_SERVER['HTTP_X_REWRITE_URL'] ) ) {
    45                         // IIS Isapi_Rewrite.
    46                         $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
    47                 } else {
    48                         // Use ORIG_PATH_INFO if there is no PATH_INFO.
    49                         if ( ! isset( $_SERVER['PATH_INFO'] ) && isset( $_SERVER['ORIG_PATH_INFO'] ) ) {
    50                                 $_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];
    51                         }
    52 
    53                         // Some IIS + PHP configurations put the script-name in the path-info (no need to append it twice).
    54                         if ( isset( $_SERVER['PATH_INFO'] ) ) {
    55                                 if ( $_SERVER['PATH_INFO'] == $_SERVER['SCRIPT_NAME'] ) {
    56                                         $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
    57                                 } else {
    58                                         $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . $_SERVER['PATH_INFO'];
    59                                 }
    60                         }
    61 
    62                         // Append the query string if it exists and isn't null.
    63                         if ( ! empty( $_SERVER['QUERY_STRING'] ) ) {
    64                                 $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
    65                         }
    66                 }
     29// Fix for IIS when running with PHP ISAPI.
     30if ( empty( $_SERVER['REQUEST_URI'] ) || ( 'cgi-fcgi' !== PHP_SAPI && preg_match( '/^Microsoft-IIS\//', $_SERVER['SERVER_SOFTWARE'] ) ) ) {
     31}}}