Bug 611308 - MediaWiki's ulimit4.sh triggers SELinux warnings when thumbnailing
Summary: MediaWiki's ulimit4.sh triggers SELinux warnings when thumbnailing
Alias: None
Product: Fedora
Classification: Fedora
Component: selinux-policy-targeted
Version: 13
Hardware: x86_64
OS: Linux
Target Milestone: ---
Assignee: Miroslav Grepl
QA Contact: Ben Levenson
Depends On:
TreeView+ depends on / blocked
Reported: 2010-07-04 19:55 UTC by Joel Uckelman
Modified: 2011-06-27 19:25 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2011-06-27 19:25:49 UTC
Type: ---

Attachments (Terms of Use)

Description Joel Uckelman 2010-07-04 19:55:34 UTC
Description of problem:

In my /var/log/httpd/error_log:

/usr/share/mediawiki/bin/ulimit4.sh: line 3: ulimit: cpu time: cannot modify lim
it: Permission denied

In my /var/log/messages:

Jul  4 12:26:01 test2 setroubleshoot: SELinux is preventing /bin/bash "setrlimit" access . For complete SELinux messages. run sealert -l 36689457-5bdb-490f-a22c-1fa211a9a772

[root@test2 log]# sealert -l 36689457-5bdb-490f-a22c-1fa211a9a772


SELinux is preventing /bin/bash "setrlimit" access .

Detailed Description:

[ulimit4.sh has a permissive type (httpd_t). This access was not denied.]

SELinux denied access requested by ulimit4.sh. It is not expected that this
access is required by ulimit4.sh and this access may signal an intrusion
attempt. It is also possible that the specific version or configuration of the
application is causing it to require additional access.

Allowing Access:

You can generate a local policy module to allow this access - see FAQ
(http://docs.fedoraproject.org/selinux-faq-fc5/#id2961385) Please file a bug

Additional Information:

Source Context                unconfined_u:system_r:httpd_t:s0
Target Context                unconfined_u:system_r:httpd_t:s0
Target Objects                None [ process ]
Source                        ulimit4.sh
Source Path                   /bin/bash
Port                          <Unknown>
Host                          test2.nomic.net
Source RPM Packages           bash-4.1.7-1.fc13
Target RPM Packages           
Policy RPM                    selinux-policy-3.7.19-28.fc13
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Plugin Name                   catchall
Host Name                     test2.nomic.net
Platform                      Linux test2.nomic.net #1
                              SMP Fri Jun 11 09:38:12 UTC 2010 x86_64 x86_64
Alert Count                   192
First Seen                    Sat Jul  3 16:15:21 2010
Last Seen                     Sun Jul  4 12:51:19 2010
Local ID                      36689457-5bdb-490f-a22c-1fa211a9a772
Line Numbers                  

Raw Audit Messages            

node=test2.nomic.net type=AVC msg=audit(1278273079.252:2470): avc:  denied  { setrlimit } for  pid=29044 comm="ulimit4.sh" scontext=unconfined_u:system_r:httpd_t:s0 tcontext=unconfined_u:system_r:httpd_t:s0 tclass=process

node=test2.nomic.net type=SYSCALL msg=audit(1278273079.252:2470): arch=c000003e syscall=160 success=yes exit=128 a0=0 a1=7fff8c7455f0 a2=0 a3=100 items=0 ppid=15336 pid=29044 auid=500 uid=48 gid=489 euid=48 suid=48 fsuid=48 egid=489 sgid=489 fsgid=489 tty=(none) ses=7 comm="ulimit4.sh" exe="/bin/bash" subj=unconfined_u:system_r:httpd_t:s0 key=(null)

The ulimit4.sh script is used by MediaWiki to apply $wgMaxShellTime and $wgMaxShellMemory when it has to execute commands (e.g., this happens when  thumbnailing images). On a busy wiki, you'll end up with tons of these warnings. Since this is normal behavior, it would be nice if SELinux didn't warn about it.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Brows to the wiki.
2. Request an image thumbnail which doesn't yet exist.
Actual results:

An SELinux warning.

Expected results:

No SELinux warning.

Comment 1 Daniel Walsh 2010-07-12 20:06:52 UTC
You can add these rules for now using

# grep avc /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

I think it might be best to add policy for mediawiki.  We really do not want to start granting setrlimit to all apache processes.

Comment 2 Daniel Walsh 2010-07-12 20:09:09 UTC
Actually Miroslav lets add a boolean.
## <desc>
## <p>
## Allow httpd daemon to change system limits
## </p>
## </desc>
gen_tunable(httpd_setrlimit, false)

	allow httpd_t self:process setrlimit;

Comment 3 Miroslav Grepl 2010-07-13 07:39:25 UTC
Fixed in selinux-policy-3.7.19-36.fc13

Comment 4 Joel Uckelman 2010-07-14 10:36:51 UTC
This seems not to work:

1. I got this error messasge when I installed selinux-policy-targeted-3.7.19-36.fc13:

/etc/selinux/targeted/contexts/files/file_contexts: Multiple different specifications for /usr/libexec/telepathy-sofiasip  (system_u:object_r:telepathysofiasip_exec_t:s0 and system_u:object_r:telepathy_sofiasip_exec_t:s0).
/etc/selinux/targeted/contexts/files/file_contexts: Invalid argument
libsemanage.semanage_install_active: setfiles returned error code 1.
semodule:  Failed!

2. setsebool -P httpd_setrlimit 1
libsemanage.dbase_llist_set: record not found in the database
libsemanage.dbase_llist_set: could not set record value
Could not change boolean httpd_setrlimit
Could not change policy booleans

3. The new boolean isn't documented in httpd_selinux(8).

Comment 5 Miroslav Grepl 2010-07-14 10:59:23 UTC
I am fixing this issue. Please run

# semodule -r telepathysofiasip

and then install selinux-policy-targeted package from Koji again. Thanks. Updated selinux-policy packages will be available today.

Comment 6 Joel Uckelman 2010-07-14 11:19:32 UTC
It seems to work now. Thanks.

Comment 7 Fedora Update System 2010-07-14 14:25:30 UTC
selinux-policy-3.7.19-37.fc13 has been submitted as an update for Fedora 13.

Comment 8 Joel Uckelman 2010-07-14 21:18:48 UTC
Hmm. Now that I've had time to test a bit more, I can see that turning on httpd_setrlimit causes a new problem: There's no SELinux denials now, but when ulimit4.sh calls convert, now it seg faults!

This is 100% repeatable with httpd_setrlimit turned on, and never happens with httpd_setrlimit turned off (that is, convert always makes the image thumbnail properly).

Here's what I see in my apache error_log:

/usr/share/mediawiki/bin/ulimit4.sh: line 4: 12339 Segmentation fault      (core dumped) '/usr/bin/convert' -quality 80 -background white -size 120 '/var/www/mediawiki/images/3/3f/Space_infantry_screenshot.jpg' -thumbnail '120x81!' -depth 8 -sharpen '0x0.4' '/var/www/mediawiki/images/thumb/3/3f/Space_infantry_screenshot.jpg/120px-Space_infantry_screenshot.jpg' 2>&1

Comment 9 Joel Uckelman 2010-07-14 21:27:37 UTC
The crash of convert is reported in Bug 614638.

Comment 10 Fedora Update System 2010-07-14 23:07:23 UTC
selinux-policy-3.7.19-37.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update selinux-policy'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/selinux-policy-3.7.19-37.fc13

Comment 11 Bug Zapper 2011-06-01 14:46:31 UTC
This message is a reminder that Fedora 13 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 13.  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 WONTFIX if it remains open with a Fedora 
'version' of '13'.

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 prior to Fedora 13's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 13 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 please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

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.

The process we are following is described here: 

Comment 12 Bug Zapper 2011-06-27 19:25:49 UTC
Fedora 13 changed to end-of-life (EOL) status on 2011-06-25. Fedora 13 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.

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.