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

Disable RTLD_DEEPBIND on all PHP SAPIs except for apache #420

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion php/.SRCINFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pkgbase = php
pkgver = 8.3.13
pkgrel = 2
pkgrel = 3
url = https://www.php.net/
arch = x86_64
license = PHP-3.01
Expand Down Expand Up @@ -32,6 +32,7 @@ pkgbase = php
source = apache.patch
source = apache.conf
source = php-fpm.patch
source = disable-deepbind.patch
source = php-fpm.tmpfiles
source = php.ini.patch
source = php-cachy.patch
Expand All @@ -45,6 +46,7 @@ pkgbase = php
sha256sums = 702b163c66c65af92dcad8d79f41bda84bcd5d863235fcf1497c33a86db9e4ca
sha256sums = 4a2add00d93fa991ccdf6356090264c1059c79935642afff6e8d4a2107fa037e
sha256sums = 78b8074461cdfc5d4e0ba428a8387f308d60720c8ad35c6176801e5088f02090
sha256sums = a57e4f2e7b12f745472ab7ca242e4f2f310d32a2bcaf304a4e98020c335e2ec2
sha256sums = 640dba0d960bfeaae9ad38d2826d3f6b5d6c175a4d3e16664eefff29141faad5
sha256sums = 73d7641022985a0b8aa1817c16935956ffde118cf61c4c349ed445d51d91af1b
sha256sums = 40de67e43a972159c54d948ef1bf4e94e2d0e96da1f21efc9002ba71f39b80ae
Expand Down
6 changes: 4 additions & 2 deletions php/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pkgname=('php'
'php-tidy'
'php-xsl')
pkgver=8.3.13
pkgrel=2
pkgrel=3
arch=('x86_64')
license=('PHP-3.01')
url='https://www.php.net/'
Expand All @@ -29,13 +29,14 @@ makedepends=('apache' 'aspell' 'enchant' 'gd' 'gmp' 'icu' 'libsodium' 'libxslt'
'oniguruma')
checkdepends=('procps-ng')
source=("https://php.net/distributions/${pkgbase}-${pkgver}.tar.xz"{,.asc}
'apache.patch' 'apache.conf' 'php-fpm.patch' 'php-fpm.tmpfiles' 'php.ini.patch' 'php-cachy.patch' '0005-Enable-hugepages.patch'
'apache.patch' 'apache.conf' 'php-fpm.patch' 'disable-deepbind.patch' 'php-fpm.tmpfiles' 'php.ini.patch' 'php-cachy.patch' '0005-Enable-hugepages.patch'
'https://raw.githubusercontent.com/SergiX44/php-benchmark-script/master/bench.php')
sha256sums=('89adb978cca209124fe53fd6327bc4966ca21213a7fa2e9504f854e340873018'
'SKIP'
'702b163c66c65af92dcad8d79f41bda84bcd5d863235fcf1497c33a86db9e4ca'
'4a2add00d93fa991ccdf6356090264c1059c79935642afff6e8d4a2107fa037e'
'78b8074461cdfc5d4e0ba428a8387f308d60720c8ad35c6176801e5088f02090'
'a57e4f2e7b12f745472ab7ca242e4f2f310d32a2bcaf304a4e98020c335e2ec2'
'640dba0d960bfeaae9ad38d2826d3f6b5d6c175a4d3e16664eefff29141faad5'
'73d7641022985a0b8aa1817c16935956ffde118cf61c4c349ed445d51d91af1b'
'40de67e43a972159c54d948ef1bf4e94e2d0e96da1f21efc9002ba71f39b80ae'
Expand All @@ -56,6 +57,7 @@ prepare() {
patch -p0 -i "${srcdir}/php-fpm.patch"
patch -p0 -i "${srcdir}/php.ini.patch"
patch -p0 -i "${srcdir}/php-cachy.patch"
patch -Np1 -i "${srcdir}/disable-deepbind.patch"
patch -Np1 -i "${srcdir}/0005-Enable-hugepages.patch"
autoconf

Expand Down
7 changes: 5 additions & 2 deletions php/PKGBUILD.pgo
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pkgname=('php'
'php-tidy'
'php-xsl')
pkgver=8.3.8
pkgrel=2
pkgrel=3
arch=('x86_64')
license=('PHP')
url='https://github.com/php/php-src'
Expand All @@ -29,7 +29,7 @@ makedepends=('apache' 'aspell' 'enchant' 'gd' 'gmp' 'icu' 'libsodium' 'libxslt'
'oniguruma')
checkdepends=('procps-ng')
source=("https://php.net/distributions/${pkgbase}-${pkgver}.tar.xz"{,.asc}
'apache.patch' 'apache.conf' 'php-fpm.patch' 'php-fpm.tmpfiles' 'php.ini.patch' 'php-cachy.patch' '0005-Enable-hugepages.patch'
'apache.patch' 'apache.conf' 'php-fpm.patch' 'disable-deepbind.patch' 'php-fpm.tmpfiles' 'php.ini.patch' 'php-cachy.patch' '0005-Enable-hugepages.patch'
'https://raw.githubusercontent.com/SergiX44/php-benchmark-script/master/bench.php')
sha256sums=('aea358b56186f943c2bbd350c9005b9359133d47e954cfc561385319ae5bb8d7'
'SKIP'
Expand All @@ -45,6 +45,8 @@ validpgpkeys=('1198C0117593497A5EC5C199286AF1F9897469DC'
'39B641343D8C104B2B146DC3F9C39DC0B9698544'
'E60913E4DF209907D8E30D96659A97C9CF2A795A')
_interpreter=${pkgver%.*}
options=('!lto')


prepare() {
cd "${srcdir}/${pkgbase}-${pkgver}"
Expand All @@ -53,6 +55,7 @@ prepare() {
patch -p0 -i "${srcdir}/php-fpm.patch"
patch -p0 -i "${srcdir}/php.ini.patch"
patch -p0 -i "${srcdir}/php-cachy.patch"
patch -p0 -i "${srcdir}/disable-deepbind.patch"
patch -Np1 -i "${srcdir}/0005-Enable-hugepages.patch"
autoconf

Expand Down
41 changes: 41 additions & 0 deletions php/disable-deepbind.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h
index 67068797314..f74cd83578a 100644
--- a/Zend/zend_portability.h
+++ b/Zend/zend_portability.h
@@ -155,7 +155,7 @@

# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
-# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__) && !__has_feature(memory_sanitizer)
+# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__) && !__has_feature(memory_sanitizer) && defined(PHP_USE_RTLD_DEEPBIND)
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL | RTLD_DEEPBIND)
# else
# define DL_LOAD(libname) dlopen(libname, PHP_RTLD_MODE | RTLD_GLOBAL)
diff --git a/configure.ac b/configure.ac
index 8784bbf0885..838bf1dcb7f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -933,6 +933,23 @@ if test "$PHP_RTLD_NOW" = "yes"; then
AC_DEFINE(PHP_USE_RTLD_NOW, 1, [ Use dlopen with RTLD_NOW instead of RTLD_LAZY ])
fi

+if test "$PHP_SAPI" = "apache2handler"; then
+ PHP_RTLD_DEEPBIND_DEFAULT=yes
+else
+ PHP_RTLD_DEEPBIND_DEFAULT=no
+fi
+
+PHP_ARG_ENABLE([rtld-deepbind],
+ [whether to dlopen extensions with RTLD_DEEPBIND],
+ [AS_HELP_STRING([--enable-rtld-deepbind],
+ [Use dlopen with RTLD_DEEPBIND])],
+ [$PHP_RTLD_DEEPBIND_DEFAULT],
+ [$PHP_RTLD_DEEPBIND_DEFAULT])
+
+if test "$PHP_RTLD_DEEPBIND" = "yes"; then
+ AC_DEFINE(PHP_USE_RTLD_DEEPBIND, 1, [ Use dlopen with RTLD_DEEPBIND ])
+fi
+
PHP_ARG_WITH([layout],
[layout of installed files],
[AS_HELP_STRING([--with-layout=TYPE],