Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NULL access with preloading and INI option #18112

Closed
YuanchengJiang opened this issue Mar 19, 2025 · 1 comment
Closed

NULL access with preloading and INI option #18112

YuanchengJiang opened this issue Mar 19, 2025 · 1 comment

Comments

@YuanchengJiang
Copy link

Description

The following code:

Resulted in this output:

/home/phpfuzz/WorkSpace/flowfusion/php-src/Zend/zend_virtual_cwd.c:1446:2: runtime error: null pointer passed as argument 2, which is declared to never be null
/usr/include/string.h:44:28: note: nonnull attribute specified here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/phpfuzz/WorkSpace/flowfusion/php-src/Zend/zend_virtual_cwd.c:1446:2 in 

To reproduce:

./php-src/sapi/cli/php  -d "log_errors=1" -d "zend_extension=/home/phpfuzz/WorkSpace/flowfusion/php-src/modules/opcache.so" -d "opcache.enable_cli=1" -d "opcache.preload=/home/phpfuzz/WorkSpace/flowfusion/php-src/tests/fused/preload_class_alias_2.inc" -d "error_log=" -d "allow_url_include=1" ./test.php

Commit:

aa9d140a2abb5b2d795d688b6c6afe0a886640d6

Configurations:

CC="clang-12" CXX="clang++-12" CFLAGS="-DZEND_VERIFY_TYPE_INFERENCE" CXXFLAGS="-DZEND_VERIFY_TYPE_INFERENCE" ./configure --enable-debug --enable-address-sanitizer --enable-undefined-sanitizer --enable-re2c-cgoto --enable-fpm --enable-litespeed --enable-phpdbg-debug --enable-zts --enable-bcmath --enable-calendar --enable-dba --enable-dl-test --enable-exif --enable-ftp --enable-gd --enable-gd-jis-conv --enable-mbstring --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-zend-test --with-zlib --with-bz2 --with-curl --with-enchant --with-gettext --with-gmp --with-mhash --with-ldap --with-libedit --with-readline --with-snmp --with-sodium --with-xsl --with-zip --with-mysqli --with-pdo-mysql --with-pdo-pgsql --with-pgsql --with-sqlite3 --with-pdo-sqlite --with-webp --with-jpeg --with-freetype --enable-sigchild --with-readline --with-pcre-jit --with-iconv

Operating System:

Ubuntu 20.04 Host, Docker 0599jiangyc/flowfusion:latest

This report is automatically generated by FlowFusion

PHP Version

aa9d140

Operating System

No response

@nielsdos
Copy link
Member

nielsdos commented Mar 19, 2025

Needs ZTS, prolly related to the difference in construction/destruction for globals

@nielsdos nielsdos changed the title SEGV Zend/zend_virtual_cwd.c NULL access with preloading and INI option Mar 19, 2025
nielsdos added a commit to nielsdos/php-src that referenced this issue Mar 19, 2025
Preloading shutdown calls request shutdown which will deactivate the
virtual cwd state. However, further startup code still assumes the state
that was set by virtual_cwd_startup(). So we need to reactivate it
manually.

Creating a test was a bit difficult because the INI setting I wanted to
test this with is overridden by the test runner apparently.
To reproduce the issue, create an empty file test.php and execute this
in a ZTS build:
`php -d opcache.preload=./ext/opcache/tests/preload_class_alias_2.inc -d "error_log=" -d "allow_url_include=1" test.php`
@nielsdos nielsdos linked a pull request Mar 19, 2025 that will close this issue
@nielsdos nielsdos added the ZTS label Mar 19, 2025
nielsdos added a commit that referenced this issue Mar 20, 2025
* PHP-8.3:
  Fix GH-18112: NULL access with preloading and INI option
nielsdos added a commit that referenced this issue Mar 20, 2025
* PHP-8.4:
  Fix GH-18112: NULL access with preloading and INI option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants