Bug 1380930 - SELinux is preventing php-fpm from using the 'execmem' accesses on a process.
Summary: SELinux is preventing php-fpm from using the 'execmem' accesses on a process.
Keywords:
Status: CLOSED EOL
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy
Version: 26
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Lukas Vrabec
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard: abrt_hash:73bc6ad4177b31758c84f61e070...
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-01 17:08 UTC by Mikhail
Modified: 2018-05-29 11:39 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-05-29 11:39:58 UTC


Attachments (Terms of Use)

Description Mikhail 2016-10-01 17:08:29 UTC
Description of problem:
SELinux is preventing php-fpm from using the 'execmem' accesses on a process.

*****  Plugin catchall_boolean (89.3 confidence) suggests   ******************

If you want to allow httpd to execmem
Then you must tell SELinux about this by enabling the 'httpd_execmem' boolean.
You can read 'None' man page for more details.
Do
setsebool -P httpd_execmem 1

*****  Plugin catchall (11.6 confidence) suggests   **************************

If you believe that php-fpm should be allowed execmem access on processes labeled httpd_t by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'php-fpm' --raw | audit2allow -M my-phpfpm
# semodule -X 300 -i my-phpfpm.pp

Additional Information:
Source Context                system_u:system_r:httpd_t:s0
Target Context                system_u:system_r:httpd_t:s0
Target Objects                Unknown [ process ]
Source                        php-fpm
Source Path                   php-fpm
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-215.fc25.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Permissive
Host Name                     (removed)
Platform                      Linux (removed)
                              4.8.0-0.rc8.git0.1.fc25.x86_64+debug #1 SMP Mon
                              Sep 26 16:46:31 UTC 2016 x86_64 x86_64
Alert Count                   5
First Seen                    2016-10-01 15:34:17 YEKT
Last Seen                     2016-10-01 16:11:15 YEKT
Local ID                      f9953d1b-78c9-4dc3-89bb-6939596177c0

Raw Audit Messages
type=AVC msg=audit(1475320275.871:1076): avc:  denied  { execmem } for  pid=30139 comm="php-fpm" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=process permissive=1


Hash: php-fpm,httpd_t,httpd_t,process,execmem

Version-Release number of selected component:
selinux-policy-3.13.1-215.fc25.noarch

Additional info:
reporter:       libreport-2.8.0
hashmarkername: setroubleshoot
kernel:         4.8.0-0.rc8.git0.1.fc25.x86_64+debug
type:           libreport

Comment 1 krp 2016-12-12 09:04:08 UTC
Description of problem:
After i install nginx, php-fpm and try to start it

Version-Release number of selected component:
selinux-policy-3.13.1-225.1.fc25.noarch

Additional info:
reporter:       libreport-2.8.0
hashmarkername: setroubleshoot
kernel:         4.8.12-300.fc25.x86_64
type:           libreport

Comment 2 David Strauss 2017-03-21 19:07:03 UTC
Description of problem:
My understanding is that PHP-FPM uses execmem for the regex JIT.

Version-Release number of selected component:
selinux-policy-3.13.1-225.11.fc25.noarch

Additional info:
reporter:       libreport-2.8.0
hashmarkername: setroubleshoot
kernel:         4.9.14-200.fc25.x86_64
type:           libreport

Comment 3 David Strauss 2017-03-21 19:12:56 UTC
Running this command seems to work around the issue without any dirty audit2allow:

setsebool -P httpd_execmem 1

However, execmem appears to be standard functionality in the shipping PHP 7 configuration. Fedora ought to do one of the following:

(1) Allow execmem for PHP-FPM under label httpd.
(2) Configure PHP-FPM to not use the regex JIT. Ideally, comment next to the disabled option to instruct administrators to update their selinux bools if they want to use it.

Comment 4 David Strauss 2017-03-21 19:28:52 UTC
Actually, I'm still seeing selinux errors after the setsebool. After running setsebool, I see this:

SELinux is preventing php-fpm from execute access on the file
2F616E6F6E5F6875676570616765202864656C6574656429.

*****  Plugin catchall (100. confidence)
suggests   **************************

If you believe that php-fpm should be allowed execute access on the
2F616E6F6E5F6875676570616765202864656C6574656429 file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'php-fpm' --raw | audit2allow -M my-phpfpm
# semodule -X 300 -i my-phpfpm.pp

Additional Information:
Source Context                system_u:system_r:httpd_t:s0
Target Context                system_u:object_r:hugetlbfs_t:s0
Target
Objects                2F616E6F6E5F6875676570616765202864656C6574656429
[
                              file ]
Source                        php-fpm
Source Path                   php-fpm
Port                          <Unknown>
Host                          t560.davidstrauss.net
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-225.11.fc25.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     t560.davidstrauss.net
Platform                      Linux t560.davidstrauss.net 4.9.14-
200.fc25.x86_64
                              #1 SMP Mon Mar 13 19:26:40 UTC 2017
x86_64 x86_64
Alert Count                   1
First Seen                    2017-03-21 12:27:21 PDT
Last Seen                     2017-03-21 12:27:21 PDT
Local ID                      26256816-45b7-4aa3-b991-75d0fe3eedbb

Raw Audit Messages
type=AVC msg=audit(1490124441.38:313): avc:  denied  { execute }
for  pid=9841 comm="php-fpm"
path=2F616E6F6E5F6875676570616765202864656C6574656429 dev="hugetlbfs"
ino=173219 scontext=system_u:system_r:httpd_t:s0
tcontext=system_u:object_r:hugetlbfs_t:s0 tclass=file permissive=0


Hash: php-fpm,httpd_t,hugetlbfs_t,file,execute

Comment 5 David Strauss 2017-03-21 19:32:03 UTC
It also looks like the PCRE JIT is disabled by default in /etc/php.d/php.ini:

pcre.jit=0

So, I'm at a loss for why this is occurring.

Comment 6 David Strauss 2017-11-07 22:44:24 UTC
This is still occurring for me on Fedora 26 with PHP 7.1.

Comment 7 Lukas Vrabec 2017-11-08 12:43:15 UTC
#============= httpd_t ==============

#!!!! This avc is allowed in the current policy
allow httpd_t hugetlbfs_t:file execute;


ยป rpm -q selinux-policy 
selinux-policy-3.13.1-260.15.fc26.noarch

Denial related to hugetlbfs_t is fixed in current version of selinux-policy and for execmem you need to use boolean: 

setsebool -P httpd_execmem 1

Closing.

Comment 8 David Strauss 2017-11-09 00:53:04 UTC
> Denial related to hugetlbfs_t is fixed in current version of selinux-policy and for execmem you need to use boolean: 
>
> setsebool -P httpd_execmem 1

Tried that already. It just results in getting a bit further before getting the error in #4.

Comment 9 Fedora End Of Life 2018-05-03 08:26:55 UTC
This message is a reminder that Fedora 26 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 26. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '26'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 26 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 10 Fedora End Of Life 2018-05-29 11:39:58 UTC
Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26
is no longer maintained, which means that it will not receive any
further security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.


Note You need to log in before you can comment on or make changes to this bug.