Bug 1625678

Summary: SELinux prevents remove_name for Tomcat
Product: Red Hat Enterprise Linux 7 Reporter: David Mulford <dmulford>
Component: selinux-policyAssignee: Lukas Vrabec <lvrabec>
Status: CLOSED ERRATA QA Contact: Milos Malik <mmalik>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.5CC: csutherl, dmulford, lmiksik, lvrabec, mgrepl, mmalik, plautrba, ssekidde, vmojzis
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: selinux-policy-3.13.1-226.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 10:09:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description David Mulford 2018-09-05 14:10:53 UTC
Description of problem:

SELinux denies remove_name when Tomcat attempts to delete a temporary file used when compiling class files for JSPs.

Here is an example of the AVC denial:

----
type=PROCTITLE msg=audit(09/04/2018 16:17:26.432:399533) : proctitle=/usr/lib/jvm/jre/bin/java 
type=SYSCALL msg=audit(09/04/2018 16:17:26.432:399533) : arch=x86_64 syscall=unlink success=no exit=-13(Permission denied) a0=0x7f1814763bb0 a1=0x7f17fc0016e8 a2=0x0 a3=0x2f70736a2f656863 items=0 ppid=1 pid=63959 auid=unset uid=unknown(53) gid=unknown(53) euid=unknown(53) suid=unknown(53) fsuid=unknown(53) egid=unknown(53) sgid=unknown(53) fsgid=unknown(53) tty=(none) ses=unset comm=java exe=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/bin/java subj=system_u:system_r:tomcat_t:s0 key=(null) 
type=AVC msg=audit(09/04/2018 16:17:26.432:399533) : avc:  denied  { remove_name } for  pid=63959 comm=java name=code_jsp.class dev="dm-3" ino=396278 scontext=system_u:system_r:tomcat_t:s0 tcontext=system_u:object_r:usr_t:s0 tclass=dir

This manifests in the Tomcat logs as thrown exceptions and an http 500 response code.

ERROR [http-bio-8080-exec-8][VirtualHostFilter:361] org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to compile class for JSP
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to compile class for JSP
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:378)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
...

Caused by: org.apache.jasper.JasperException: Unable to compile class for JSP
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:672)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
... 205 more

Caused by: java.io.IOException: classFile.delete() failed
at org.apache.jasper.compiler.SmapUtil$SDEInstaller.install(SmapUtil.java:201)
at org.apache.jasper.compiler.SmapUtil.installSmap(SmapUtil.java:163)
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:491)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
... 206 more



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

- RHEL 7.5 (kernel-3.10.0-862.9.1.el7.x86_64)
- tomcat-7.0.76-6.el7.noarch
- selinux-policy-3.13.1-192.el7_5.4.noarch
- selinux-policy-targeted-3.13.1-192.el7_5.4.noarch

Comment 14 errata-xmlrpc 2018-10-30 10:09:41 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:3111