Skip to contentSkip to conversation

allow tomcat_t self:capability 0x80000000; ??

DISCUSSION Daniel Gil Mayol 2 participants 6 messages Oct 19, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hello, I'm trying to write a policy for Tomcat using RedHat Enterprise 4. I receive the next message:

Oct 19 09:04:36 cnsu kernel: audit(1161248676.103:4605): avc:  denied  

{ 0x80000000 } for pid=1223 comm="java" capability=31 scontext=root:system_r:tomcat_t tcontext=root:system_r:tomcat_t tclass=capability

Using the audit2allow tool, I become the next allow to add: "allow tomcat_t self:capability 0x80000000;" but this don't works, after the compiler shows the following error:

/usr/bin/checkpolicy: loading policy configuration from policy.conf domains/xxx/tomcat.te:117:ERROR 'syntax error' at token '0' on line 39415:
allow tomcat_t self:capability 0x80000000;

Somebody can help me to understand what I'm doing wrong?

Thanks

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 7 lines · Daniel Gil Mayol

Hello, I'm trying to write a policy for Tomcat using RedHat Enterprise 4. I receive the next message:

Oct 19 09:04:36 cnsu kernel: audit(1161248676.103:4605): avc:  denied  

{ 0x80000000 } for pid=1223 comm="java" capability=31 scontext=root:system_r:tomcat_t tcontext=root:system_r:tomcat_t tclass=capability

Capability 31 isn't defined, so this indicates a kernel bug. If SELinux cannot map the capability to a defined permission, it just displays the value rather than a string name to at least provide some information.

Start auditd and then reproduce the denial while it is running. Then run:
/sbin/ausearch -i -c java
and post the result.

Also, please identify your precise kernel (uname -r).

Quoted 9 lines

Using the audit2allow tool, I become the next allow to add: "allow tomcat_t self:capability 0x80000000;" but this don't works, after the compiler shows the following error:

/usr/bin/checkpolicy: loading policy configuration from policy.conf domains/xxx/tomcat.te:117:ERROR 'syntax error' at token '0' on line 39415:
allow tomcat_t self:capability 0x80000000;

Somebody can help me to understand what I'm doing wrong?

The above won't work because that isn't a defined permission.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw

My kernel is 2.6.16.9vs2.0.2rc16.

After start auditd and run "/sbin/ausearch -i -c java" I see the next

type=PATH msg=audit(10/19/2006 14:39:57.885:4742) : item=0 name=/proc/self/exe flags=none inode=1526923273 dev=00:03 mode=symlink,777 ouid=root ogid=root rdev=00:00
type=CWD msg=audit(10/19/2006 14:39:57.885:4742) : cwd=/work/dagi type=SYSCALL msg=audit(10/19/2006 14:39:57.885:4742) : arch=i386 syscall=readlink per=400000 success=yes exit=30 a0=80553c1 a1=bf82ba50 a2=fff a3=0 items=1 pid=23299 auid=unknown(4294967295) uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root comm=java exe=/usr/java/jre1.5.0_04/bin/java
type=AVC msg=audit(10/19/2006 14:39:57.885:4742) : avc: denied
{ 0x80000000 } for pid=23299 comm=java capability=31 scontext=root:system_r:tomcat_t tcontext=root:system_r:tomcat_t tclass=capability

Quoted 25 lines · Daniel Gil Mayol
Quoted 7 lines

Hello, I'm trying to write a policy for Tomcat using RedHat Enterprise 4. I receive the next message:

Oct 19 09:04:36 cnsu kernel: audit(1161248676.103:4605): avc:  denied

{ 0x80000000 } for pid=1223 comm="java" capability=31 scontext=root:system_r:tomcat_t tcontext=root:system_r:tomcat_t tclass=capability

Capability 31 isn't defined, so this indicates a kernel bug. If SELinux cannot map the capability to a defined permission, it just displays the value rather than a string name to at least provide some information.

Start auditd and then reproduce the denial while it is running. Then run:
/sbin/ausearch -i -c java
and post the result.

Also, please identify your precise kernel (uname -r).

Quoted 4 lines

Using the audit2allow tool, I become the next allow to add: "allow tomcat_t self:capability 0x80000000;" but this don't works, after the compiler shows the following error:

Quoted 7 lines
Quoted 5 lines

/usr/bin/checkpolicy: loading policy configuration from policy.conf domains/xxx/tomcat.te:117:ERROR 'syntax error' at token '0' on line 39415: allow tomcat_t self:capability 0x80000000;

Somebody can help me to understand what I'm doing wrong?

The above won't work because that isn't a defined permission.

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
Quoted 1 line · Daniel Gil Mayol

My kernel is 2.6.16.9vs2.0.2rc16.

That obviously isn't a Red Hat kernel. I'm guessing from the name that it is a Linux-VServer kernel? Linux-Vserver patches likely claim that capability for their own use, and don't update SELinux to know about it.

Quoted 15 lines

After start auditd and run "/sbin/ausearch -i -c java" I see the next

type=PATH msg=audit(10/19/2006 14:39:57.885:4742) : item=0 name=/proc/self/exe flags=none inode=1526923273 dev=00:03 mode=symlink,777 ouid=root ogid=root rdev=00:00
type=CWD msg=audit(10/19/2006 14:39:57.885:4742) : cwd=/work/dagi type=SYSCALL msg=audit(10/19/2006 14:39:57.885:4742) : arch=i386 syscall=readlink per=400000 success=yes exit=30 a0=80553c1 a1=bf82ba50 a2=fff a3=0 items=1 pid=23299 auid=unknown(4294967295) uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root comm=java exe=/usr/java/jre1.5.0_04/bin/java
type=AVC msg=audit(10/19/2006 14:39:57.885:4742) : avc: denied
{ 0x80000000 } for pid=23299 comm=java capability=31 scontext=root:system_r:tomcat_t tcontext=root:system_r:tomcat_t tclass=capability

Taking a quick glance at the vs patch, it appears to apply this new capability check on accesses to /proc to decide whether to skip certain other checks. Thus, everything that touches /proc will end up triggering these audit messages, but you almost never want to allow them (only to admin for the virtual server itself).

Normally, we'd deal with this via a dontaudit statement to silence the audit message without allowing it.

In order to reference this capability in such a statement, it needs to be defined in the policy/flask/access_vectors file. In that file, go to the "class capability" section, and at the end of the list of capabilities (after "audit_control" and before the closing "}") add something like "vs_context". Then you can write a policy statement like:

	dontaudit tomcat_t self:capability vs_context;

and it should compile and load ok.

If you want the kernel audit messages to use that name instead of the number, you have to regenerate the SELinux headers and rebuild your kernel. To do that, after adding the "vs_context" definition to access_vectors as above, you would run make in the policy/flask subdirectory, then copy the generated .h files in that directory to the security/selinux/include directory of your kernel tree (you can also do that by running make LINUXDIR=/path/to/kerneltree tokern).

If you want to avoid such headaches in the future, you should then submit a diff of the old and new headers back to the Linux-VServer project so that they can incorporate it into their patches and releases.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw

I have added "vs_context" in the class capability but don't seems enough, after a "make load" I have the next

flask/access_vectors:362:ERROR 'too many permissions to fit in an access vector' at token '}' on line 485:
vs_context
}

The problem is that currently I can't recompile the kernel. I have written the next (although is not very nice, is temporal until I become a re-compiled kernel):

dontaudit tomcat_t self:capability *;

Quoted 52 lines · Daniel Gil Mayol
Quoted 1 line

My kernel is 2.6.16.9vs2.0.2rc16.

That obviously isn't a Red Hat kernel. I'm guessing from the name that it is a Linux-VServer kernel? Linux-Vserver patches likely claim that capability for their own use, and don't update SELinux to know about it.

Quoted 15 lines

After start auditd and run "/sbin/ausearch -i -c java" I see the next

type=PATH msg=audit(10/19/2006 14:39:57.885:4742) : item=0 name=/proc/self/exe flags=none inode=1526923273 dev=00:03 mode=symlink,777 ouid=root ogid=root rdev=00:00
type=CWD msg=audit(10/19/2006 14:39:57.885:4742) : cwd=/work/dagi type=SYSCALL msg=audit(10/19/2006 14:39:57.885:4742) : arch=i386 syscall=readlink per=400000 success=yes exit=30 a0=80553c1 a1=bf82ba50 a2=fff a3=0 items=1 pid=23299 auid=unknown(4294967295) uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root comm=java exe=/usr/java/jre1.5.0_04/bin/java
type=AVC msg=audit(10/19/2006 14:39:57.885:4742) : avc: denied { 0x80000000 } for pid=23299 comm=java capability=31 scontext=root:system_r:tomcat_t tcontext=root:system_r:tomcat_t tclass=capability

Taking a quick glance at the vs patch, it appears to apply this new capability check on accesses to /proc to decide whether to skip certain other checks. Thus, everything that touches /proc will end up triggering these audit messages, but you almost never want to allow them (only to admin for the virtual server itself).

Normally, we'd deal with this via a dontaudit statement to silence the audit message without allowing it.

In order to reference this capability in such a statement, it needs to be defined in the policy/flask/access_vectors file. In that file, go to the "class capability" section, and at the end of the list of capabilities (after "audit_control" and before the closing "}") add something like "vs_context". Then you can write a policy statement like:

	dontaudit tomcat_t self:capability vs_context;

and it should compile and load ok.

If you want the kernel audit messages to use that name instead of the number, you have to regenerate the SELinux headers and rebuild your kernel. To do that, after adding the "vs_context" definition to access_vectors as above, you would run make in the policy/flask subdirectory, then copy the generated .h files in that directory to the security/selinux/include directory of your kernel tree (you can also do that by running make LINUXDIR=/path/to/kerneltree tokern).

If you want to avoid such headaches in the future, you should then submit a diff of the old and new headers back to the Linux-VServer project so that they can incorporate it into their patches and releases.

Signature · 15 lines
Mit freundlichen Grüßen / Best regards
Daniel Gil Mayol
------------------------------------------------------------------------------------
Brunel Communications
Daimlerring 9
31135 Hildesheim
Telefon	+49 5121 1760 839  
Fax 	+49 5121 1760 999
[email protected]


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#5 lore raw
Quoted 7 lines · Daniel Gil Mayol

I have added "vs_context" in the class capability but don't seems enough, after a "make load" I have the next

flask/access_vectors:362:ERROR 'too many permissions to fit in an access vector' at token '}' on line 485:
vs_context
}

Hmmm...that was a bug in checkpolicy, but has been fixed for a while, at least upstream.

Quoted 5 lines

The problem is that currently I can't recompile the kernel. I have written the next (although is not very nice, is temporal until I become a re-compiled kernel):

dontaudit tomcat_t self:capability *;

Yes, that works too. But if you can solve the policy problem above (via newer checkpolicy with that bug fixed), then you can just dontaudit the vs_context capability even without rebuilding the kernel. Rebuilding the kernel is only needed if you want audit messages it generates to include the string name rather than the numeric value (so that audit2allow works for you).

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.