heap-use-after-free of a user stream wrapper when a STDOUT user filter opens a stream during shutdown
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 40/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Área
- backend, operating-systems
Línea de trabajo
Start with the reported stack trace in main/streams/streams.c at php_stream_locate_url_wrapper (line 2039), then trace wrapper registration and cleanup through main/streams/userspace.c, especially stream_wrapper_dtor. Reproduce with the supplied PHP script under AddressSanitizer using the stated command. Done means opening a stream from the STDOUT filter during shutdown no longer produces a heap-use-after-free.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
The following code:
<?php
class W {
public $context;
function stream_open($path, $mode, $options, &$opened_path) { return true; }
}
class F extends php_user_filter {
function filter($in, $out, &$consumed, bool $closing): int {
if ($closing) {
fopen("w2://x", "r");
}
return PSFS_PASS_ON;
}
}
stream_wrapper_register("w2", "W");
stream_filter_register("f", "F");
stream_filter_append(STDOUT, "f");
Resulted in this output:
==2253707==ERROR: AddressSanitizer: heap-use-after-free on address 0x6040000f5f60 at pc 0x0000055f9ef4 bp 0x7ffd5858dcf0 sp 0x7ffd5858dce8
READ of size 4 at 0x6040000f5f60 thread T0
#0 0x55f9ef3 in php_stream_locate_url_wrapper main/streams/streams.c:2039:26
#1 0x55fc355 in _php_stream_open_wrapper_ex main/streams/streams.c:2192:12
#2 0x4570374 in zif_fopen ext/standard/file.c:766:11
#3 0x383d6e3 in zif_phar_fopen ext/phar/func_interceptors.c:310:2
#4 0x636166a in ZEND_DO_ICALL_SPEC_RETVAL_UNUSED_HANDLER Zend/zend_vm_execute.h:1323:2
#5 0x5f1c61c in execute_ex Zend/zend_vm_execute.h:110621:12
#6 0x5eb4d18 in zend_call_function Zend/zend_execute_API.c:1079:3
...
#11 0x497abab in userfilter_filter ext/standard/user_filters.c:232:28
#12 0x55e8e86 in php_stream_write_filtered main/streams/streams.c:1183:12
#13 0x55d9972 in php_stream_flush_ex main/streams/streams.c:1245:3
#14 0x55d68e8 in php_stream_free main/streams/streams.c:339:18
#15 0x55f5564 in stream_resource_regular_dtor main/streams/streams.c:1798:19
#16 0x68e1559 in zend_resource_dtor Zend/zend_list.c:72:3
#17 0x68e3c84 in zend_close_rsrc_list Zend/zend_list.c:227:6
#18 0x5e95a47 in zend_shutdown_executor_values Zend/zend_execute_API.c:284:2
#19 0x5ea0a31 in shutdown_executor Zend/zend_execute_API.c:479:2
#20 0x6aa7f1e in zend_deactivate Zend/zend.c:1370:2
#21 0x548bf9f in php_request_shutdown main/main.c:2042:2
...
0x6040000f5f60 is located 16 bytes inside of 40-byte region [0x6040000f5f50,0x6040000f5f78)
freed by thread T0 here:
#0 0x681162 in free (sapi/cli/php+0x681162)
#1 0x5b22f53 in __zend_free Zend/zend_alloc.c:4108:2
#2 0x5b2d630 in _efree Zend/zend_alloc.c:3060:3
#3 0x560e725 in stream_wrapper_dtor main/streams/userspace.c:72:2
#4 0x68e1559 in zend_resource_dtor Zend/zend_list.c:72:3
#5 0x68e3c84 in zend_close_rsrc_list Zend/zend_list.c:227:6
#6 0x5e95a47 in zend_shutdown_executor_values Zend/zend_execute_API.c:284:2
#7 0x5ea0a31 in shutdown_executor Zend/zend_execute_API.c:479:2
...
previously allocated by thread T0 here:
#0 0x6813cd in malloc (sapi/cli/php+0x6813cd)
#1 0x5b2e3e3 in __zend_malloc Zend/zend_alloc.c:4079:14
#2 0x5b2d418 in _emalloc Zend/zend_alloc.c:3050:10
#3 0x5b2ef8c in _ecalloc Zend/zend_alloc.c:3138:6
#4 0x560f8a0 in zif_stream_wrapper_register main/streams/userspace.c:477:44
#5 0x636166a in ZEND_DO_ICALL_SPEC_RETVAL_UNUSED_HANDLER Zend/zend_vm_execute.h:1323:2
...
SUMMARY: AddressSanitizer: heap-use-after-free main/streams/streams.c:2039:26 in php_stream_locate_url_wrapper
To reproduce: USE_ZEND_ALLOC=0 ./sapi/cli/php test.php
Commit:
ff7a318304d6d18d23d79fe0c07bb0094aee81ed
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-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-pcre-jit --with-iconv
Operating System:
Ubuntu 20.04 Host, Docker 0599jiangyc/flowfusion:latest
This report is automatically generated by FlowFusion
PHP Version
nightly
Operating System
No response
- Lenguaje dominante
- C
- Estrellas
- 41.8k
- Forks
- 8.6k
- Merge medio
- 2 d 15 h
- PR fusionados (30 d)
- 125
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de php/php-src
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
ext/openssl: 8.2.31+/8.3.31+ fail to build against OpenSSL 1.0.2 (ASN1_STRING_get0_data in xp_ssl.c)AbiertoExtension: openssl Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
php/php-src#25402 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Bug Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
php/php-src#25397 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
SNMP accepts malformed remote portsPosiblemente ocupada @somethingwithproof la tomó hace 21 días. Abierto
Dificultad 2/5 Medio día Aptitud para principiantes 62/100
php/php-src#25137 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Bug Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
Todos los issues de php/php-src
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
ZIP/ZIPS decode dereferences NULL when the cached libdeflate decompressor can't be allocated (3.5 regression)Posiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
AcademySoftwareFoundation/openexr#2884 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
python-pillow/Pillow#10590 ·
Los mantenedores suelen responder en 1 día
-
status: needs-triage type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
openwrt/packages#31407 · 1 comentario ·
Los mantenedores suelen responder en 1 día