Skip to contentSkip to conversation

How to trace why MCS permissions granted?

DISCUSSION [email protected] 3 participants 7 messages Oct 2, 2009 – Oct 5, 2009 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hello, everyone.
I'm just playing with MCS and trying to understand the system's behavior.

As far as I have read the theory, categories can be used to limit unwanted user's access to your data. So, I am trying to create a file, mark it with a category, first time - the same as the process has. Then I write there some data and read it back. That works OK and is as expected.
But when I change file's category to some other, that my testing process don't have, to prevent the process from accessing that file, I discover that the process may read, but cannot write (append) to that file:

	root@selinux1:/tmp# id
	uid=0(root) gid=0(root) groups=0(root) context=root:sysadm_r:sysadm_t:s0:c0
	root@selinux1:/tmp# ls -laZ test
	-rw-r--r-- 1 root root system_u:object_r:sysadm_tmp_t:s0:c1   9 Oct  3 00:44 test
	root@selinux1:/tmp# cat test
	asfasdaf
	root@selinux1:/tmp# cat >> test
	bash: test: Permission denied
	root@selinux1:/tmp# setenforce 0
	root@selinux1:/tmp# cat >> test
	blabla
	root@selinux1:/tmp# cat test
	asfasdaf
	blabla

When the process is at s0:c0, the file is at s0:c1, and in enforcing mode I expect to have no access at all.

I can only guess, that sysadm_t is in some way marked as a special type for bypassing MCS constraints, but how can I proof/check that?
And if that is true, I still expect to have all access or no access at all, but not the read only access.
Please, if there is nothing wrong with what I am seeing, tell where can I read about that more?

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 29 lines · On Fri, 2009-10-02 at 20:40 +0500, [email protected] wrote:

Hello, everyone.
I'm just playing with MCS and trying to understand the system's behavior.

As far as I have read the theory, categories can be used to limit unwanted user's access to your data. So, I am trying to create a file, mark it with a category, first time - the same as the process has. Then I write there some data and read it back. That works OK and is as expected.
But when I change file's category to some other, that my testing process don't have, to prevent the process from accessing that file, I discover that the process may read, but cannot write (append) to that file:

	root@selinux1:/tmp# id
	uid=0(root) gid=0(root) groups=0(root) context=root:sysadm_r:sysadm_t:s0:c0
	root@selinux1:/tmp# ls -laZ test
	-rw-r--r-- 1 root root system_u:object_r:sysadm_tmp_t:s0:c1   9 Oct  3 00:44 test
	root@selinux1:/tmp# cat test
	asfasdaf
	root@selinux1:/tmp# cat >> test
	bash: test: Permission denied
	root@selinux1:/tmp# setenforce 0
	root@selinux1:/tmp# cat >> test
	blabla
	root@selinux1:/tmp# cat test
	asfasdaf
	blabla

When the process is at s0:c0, the file is at s0:c1, and in enforcing mode I expect to have no access at all.

Quoted 6 lines

I can only guess, that sysadm_t is in some way marked as a special type for bypassing MCS constraints, but how can I proof/check that?
And if that is true, I still expect to have all access or no access at all, but not the read only access.
Please, if there is nothing wrong with what I am seeing, tell where can I read about that more?

sysadm.te calls userdom_security_admin_template(). userdom_security_admin_template() calls mls_file_read_all_levels(). mls_file_read_all_levels() declares the type as having the mlsfileread type attribute.

policy/mcs says:
mlsconstrain file { read }

        (( h1 dom h2 ) or ( t2 == domain ) or ( t1 == mlsfileread ));
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
Quoted 37 lines · Stephen Smalley
Quoted 29 lines · On Fri, 2009-10-02 at 20:40 +0500, [email protected] wrote:

Hello, everyone.
I'm just playing with MCS and trying to understand the system's behavior.

As far as I have read the theory, categories can be used to limit unwanted user's access to your data. So, I am trying to create a file, mark it with a category, first time - the same as the process has. Then I write there some data and read it back. That works OK and is as expected.
But when I change file's category to some other, that my testing process don't have, to prevent the process from accessing that file, I discover that the process may read, but cannot write (append) to that file:

	root@selinux1:/tmp# id
	uid=0(root) gid=0(root) groups=0(root) context=root:sysadm_r:sysadm_t:s0:c0
	root@selinux1:/tmp# ls -laZ test
	-rw-r--r-- 1 root root system_u:object_r:sysadm_tmp_t:s0:c1   9 Oct  3 00:44 test
	root@selinux1:/tmp# cat test
	asfasdaf
	root@selinux1:/tmp# cat >> test
	bash: test: Permission denied
	root@selinux1:/tmp# setenforce 0
	root@selinux1:/tmp# cat >> test
	blabla
	root@selinux1:/tmp# cat test
	asfasdaf
	blabla

When the process is at s0:c0, the file is at s0:c1, and in enforcing mode I expect to have no access at all.

Quoted 6 lines

I can only guess, that sysadm_t is in some way marked as a special type for bypassing MCS constraints, but how can I proof/check that?
And if that is true, I still expect to have all access or no access at all, but not the read only access.
Please, if there is nothing wrong with what I am seeing, tell where can I read about that more?

Quoted 8 lines

sysadm.te calls userdom_security_admin_template(). userdom_security_admin_template() calls mls_file_read_all_levels(). mls_file_read_all_levels() declares the type as having the mlsfileread type attribute.

policy/mcs says:
mlsconstrain file { read }

        (( h1 dom h2 ) or ( t2 == domain ) or ( t1 == mlsfileread ));

So it is operating in accordance with the policy configuration. As to whether the policy configuration makes sense is another question, I think.

I don't think MCS and MLS should be reusing each other's attributes in constraints, as not everything that requires an exception under the one will need an exception under the other.

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.
#3 lore raw
Quoted 5 lines · Stephen Smalley
Quoted 4 lines · Stephen Smalley
Quoted 3 lines · On Fri, 2009-10-02 at 20:40 +0500, [email protected] wrote:

Hello, everyone.
I'm just playing with MCS and trying to understand the system's behavior.

...

Quoted 7 lines
Quoted 3 lines

policy/mcs says:
mlsconstrain file { read }

        (( h1 dom h2 ) or ( t2 == domain ) or ( t1 == mlsfileread ));

So it is operating in accordance with the policy configuration. As to whether the policy configuration makes sense is another question, I think.

Oh, thanks, I see now.

But is there any place, where I can read human definition
of reference policy? I suppose, there should be one, that describes every requirement, that the policy should meet (or guarantee) to be "correct" or "have sense".
So I (and everyone else) could know out whether there is a bug or a feature of a policy.

Quoted 8 lines

I don't think MCS and MLS should be reusing each other's attributes in constraints, as not everything that requires an exception under the one will need an exception under the other.

Signature · 2 lines
Stephen Smalley
National Security Agency

BTW, someone abuses yor email to distribute win32 PEs.

Quoted 6 lines

--
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.

--
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
Quoted 14 lines · On Mon, 2009-10-05 at 12:14 +0500, [email protected] wrote:
Quoted 5 lines · Stephen Smalley
Quoted 4 lines · Stephen Smalley
Quoted 3 lines · On Fri, 2009-10-02 at 20:40 +0500, [email protected] wrote:

Hello, everyone.
I'm just playing with MCS and trying to understand the system's behavior.

...

Quoted 7 lines
Quoted 3 lines

policy/mcs says:
mlsconstrain file { read }

        (( h1 dom h2 ) or ( t2 == domain ) or ( t1 == mlsfileread ));

So it is operating in accordance with the policy configuration. As to whether the policy configuration makes sense is another question, I think.

Quoted 8 lines

Oh, thanks, I see now.

But is there any place, where I can read human definition
of reference policy? I suppose, there should be one, that describes every requirement, that the policy should meet (or guarantee) to be "correct" or "have sense".
So I (and everyone else) could know out whether there is a bug or a feature of a policy.

Reference policy goals were stated in the paper referenced from:
http://oss.tresys.com/projects/refpolicy/wiki/Documentation

That's written primarily in terms of the RBAC/TE components, and is focused on least privilege and role separation.

MCS came later and was invented by James Morris, see:
http://fedoraproject.org/wiki/SELinux/MCS
http://marc.info/?l=selinux&m=124688422726897&w=2
http://marc.info/?l=selinux&m=125242426700964&w=2

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.
#5 lore raw
In reply to [email protected]
Quoted 29 lines · On Fri, Oct 02, 2009 at 08:40:12PM +0500, [email protected] wrote:

Hello, everyone.
I'm just playing with MCS and trying to understand the system's behavior.

As far as I have read the theory, categories can be used to limit unwanted user's access to your data. So, I am trying to create a file, mark it with a category, first time - the same as the process has. Then I write there some data and read it back. That works OK and is as expected.
But when I change file's category to some other, that my testing process don't have, to prevent the process from accessing that file, I discover that the process may read, but cannot write (append) to that file:

	root@selinux1:/tmp# id
	uid=0(root) gid=0(root) groups=0(root) context=root:sysadm_r:sysadm_t:s0:c0
	root@selinux1:/tmp# ls -laZ test
	-rw-r--r-- 1 root root system_u:object_r:sysadm_tmp_t:s0:c1   9 Oct  3 00:44 test
	root@selinux1:/tmp# cat test
	asfasdaf
	root@selinux1:/tmp# cat >> test
	bash: test: Permission denied
	root@selinux1:/tmp# setenforce 0
	root@selinux1:/tmp# cat >> test
	blabla
	root@selinux1:/tmp# cat test
	asfasdaf
	blabla

When the process is at s0:c0, the file is at s0:c1, and in enforcing mode I expect to have no access at all.

Quoted 8 lines

I can only guess, that sysadm_t is in some way marked as a special type for bypassing MCS constraints, but how can I proof/check that?
And if that is true, I still expect to have all access or no access at all, but not the read only access.
Please, if there is nothing wrong with what I am seeing, tell where can I read about that more?

Thanks.

The tresys reference policy maillist is better suited for this.

http://oss.tresys.com/mailman/listinfo/refpolicy

My guess is that "mls_process_read_up(sysadm_t)" in sysadm.te is responsible for the behaviour but i am not sure.

http://oss.tresys.com/projects/refpolicy/browser/policy/modules/roles/sysadm.te

line 31

looking in the mls module:

http://oss.tresys.com/projects/refpolicy/browser/policy/modules/kernel/mls.if

line 72

http://oss.tresys.com/projects/refpolicy/browser/policy/mcs

line 83

mlsconstrain file { read }
(( h1 dom h2 ) or ( t2 == domain ) or ( t1 == mlsfileread ));

Quoted 5 lines

--
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.

#6 lore raw
In reply to [email protected]
Quoted 29 lines · On Fri, Oct 02, 2009 at 08:40:12PM +0500, [email protected] wrote:

Hello, everyone.
I'm just playing with MCS and trying to understand the system's behavior.

As far as I have read the theory, categories can be used to limit unwanted user's access to your data. So, I am trying to create a file, mark it with a category, first time - the same as the process has. Then I write there some data and read it back. That works OK and is as expected.
But when I change file's category to some other, that my testing process don't have, to prevent the process from accessing that file, I discover that the process may read, but cannot write (append) to that file:

	root@selinux1:/tmp# id
	uid=0(root) gid=0(root) groups=0(root) context=root:sysadm_r:sysadm_t:s0:c0
	root@selinux1:/tmp# ls -laZ test
	-rw-r--r-- 1 root root system_u:object_r:sysadm_tmp_t:s0:c1   9 Oct  3 00:44 test
	root@selinux1:/tmp# cat test
	asfasdaf
	root@selinux1:/tmp# cat >> test
	bash: test: Permission denied
	root@selinux1:/tmp# setenforce 0
	root@selinux1:/tmp# cat >> test
	blabla
	root@selinux1:/tmp# cat test
	asfasdaf
	blabla

When the process is at s0:c0, the file is at s0:c1, and in enforcing mode I expect to have no access at all.

Quoted 8 lines

I can only guess, that sysadm_t is in some way marked as a special type for bypassing MCS constraints, but how can I proof/check that?
And if that is true, I still expect to have all access or no access at all, but not the read only access.
Please, if there is nothing wrong with what I am seeing, tell where can I read about that more?

Thanks.

Whoops i was wrong. That was process_read_up not file so i guess it is because

userdom_security_admin_template(sysadm_t, sysadm_r)

like ssmalley say's

i guess the policy is built with mls enabled.

Quoted 5 lines

--
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.