Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 591b324

Browse files
authored
Do not use RTLD_DEEPBIND if dlmopen is available (#18612)
DL_LOAD now doesn't use RTLD_DEEPBIND deepbind anymore on platforms where dlmopen with LM_ID_NEWLM is available: this means shared library symbol isolation (if needed) must be enabled on the user side when requiring libphp.so, by using dlmopen with LM_ID_NEWLM instead of dlopen. RTLD_DEEPBIND is still enabled when the Apache SAPI is in use. Closes GH-10670.
1 parent 6eed02b commit 591b324

File tree

6 files changed

+23
-1
lines changed

6 files changed

+23
-1
lines changed

‎NEWS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ PHP NEWS
5858
. Added the pipe (|>) operator. (crell)
5959
. Added support for `final` with constructor property promotion.
6060
(DanielEScherzer)
61+
. Do not use RTLD_DEEPBIND if dlmopen is available. (Daniil Gentili)
6162

6263
- Curl:
6364
. Added curl_multi_get_handles(). (timwolla)

‎UPGRADING.INTERNALS‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ PHP 8.5 INTERNALS UPGRADE NOTES
1717
- Core
1818
. PG(arg_separator).input and PG(arg_separator).output are now `zend_string*`
1919
instead of `char*`.
20+
. DL_LOAD now doesn't use RTLD_DEEPBIND deepbind anymore on platforms
21+
where dlmopen with LM_ID_NEWLM is available:
22+
this means shared library symbol isolation (if needed) must be enabled on
23+
the user side when requiring libphp.so, by using dlmopen with LM_ID_NEWLM
24+
instead of dlopen.
25+
RTLD_DEEPBIND is still enabled when the Apache SAPI is in use.
2026

2127
- Zend
2228
. Added zend_safe_assign_to_variable_noref() function to safely assign

‎Zend/zend_API.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,20 @@
4040
/* these variables are true statics/globals, and have to be mutex'ed on every access */
4141
ZEND_API HashTable module_registry;
4242

43+
ZEND_API bool zend_dl_use_deepbind = false;
44+
4345
static zend_module_entry **module_request_startup_handlers;
4446
static zend_module_entry **module_request_shutdown_handlers;
4547
static zend_module_entry **module_post_deactivate_handlers;
4648
static zend_module_entry **modules_dl_loaded;
4749

4850
static zend_class_entry **class_cleanup_handlers;
4951

52+
ZEND_API void zend_set_dl_use_deepbind(bool use_deepbind)
53+
{
54+
zend_dl_use_deepbind = use_deepbind;
55+
}
56+
5057
ZEND_API zend_result zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array) /* {{{ */
5158
{
5259
zval *param_ptr;

‎Zend/zend_API.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ typedef struct _zend_fcall_info_cache {
343343
ZEND_API int zend_next_free_module(void);
344344

345345
BEGIN_EXTERN_C()
346+
ZEND_API void zend_set_dl_use_deepbind(bool use_deepbind);
347+
346348
ZEND_API zend_result zend_get_parameters_array_ex(uint32_t param_count, zval *argument_array);
347349

348350
/* internal function to efficiently copy parameters when executing __call() */

‎Zend/zend_portability.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,12 @@
165165
# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
166166
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
167167
# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__) && !__has_feature(memory_sanitizer)
168-
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND)
168+
# if defined(LM_ID_NEWLM)
169+
ZEND_API extern bool zend_dl_use_deepbind;
170+
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | (zend_dl_use_deepbind ? RTLD_DEEPBIND : 0))
171+
# else
172+
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND)
173+
# endif
169174
# else
170175
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL)
171176
# endif

‎sapi/apache2handler/sapi_apache2.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp
466466
{
467467
void *data = NULL;
468468
const char *userdata_key = "apache2hook_post_config";
469+
zend_set_dl_use_deepbind(true);
469470

470471
/* Apache will load, unload and then reload a DSO module. This
471472
* prevents us from starting PHP until the second load. */

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /