unlabeled_t and assert.te
type unlabeled_t, fs_type, file_type, root_dir_type, sysadmfile;
Currently unlabeled_t is defined as above. I have been experimenting with the below assertions to fix some instances of stupidity in policy writing (I have found two mistakes in policy I wrote already).
The problem is that as unlabeled_t has attribute file_type I can't assert that file_type may not be a tcontext of a process operation. I believe that although unlabeled_t often refers to files (probably it mostly refers to files) it has a special status and therefore does not deserve the file_type attribute. So I have defined it as only having the sysadmfile attribute (to allow the administrator to fix problems), and I am considering giving it the "domain" attribute as well.
But it occurs to me that this may be a symptom of an error in design. An unlabeled process is quite a different thing from an unlabeled file. Allowing read access to unlabeled files and directories on a file system has different implications than allowing "ps" to show unlabeled processes. I think that the correct solution to this requires a kernel change to have unlabeled_process_t and unlabeled_file_t (or other names as considered appropriate).
#
# for gross mistakes in policy
neverallow * domain:dir ~r_dir_perms;
neverallow * domain:file_class_set ~rw_file_perms;
neverallow * file_type:process *;
neverallow ~{ domain unlabeled_t } *:process *;Signature · 10 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- 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.
Quoted 5 lines · Russell Coker
I believe that although
unlabeled_toften refers to files (probably it mostly refers to files) it has a special status and therefore does not deserve thefile_typeattribute. So I have defined it as only having the sysadmfile attribute (to allow the administrator to fix problems), and I am considering giving it the "domain" attribute as well.
While I agree that it would be beneficial to have assertions to catch stupid policy, I think your current solution has a serious drawback. By removing file_type from unlabeled_t you break the notion that file_type includes all types on persistent media. This means that existing rules such as
# Relabel all files.
allow $1_t file_type:dir { getattr read search relabelfrom relabelto }; allow $1_t file_type:file_class_set { getattr relabelfrom relabelto };
are no longer useful. While you could change those to
allow $1_t sysadmfile:dir { getattr read search relabelfrom relabelto }; allow $1_t sysadmfile:file_class_set { getattr relabelfrom relabelto };
as you suggest, not all files on persistent media are labeled with sysadmfile. In particular, I believe a number of devices, the shadow file, etc. don't have the sysadmfile attribute. While sysadmfile may be sufficient for relabeling most mistakes, it isn't sufficient to relabel files when policy updates make dramatic changes or when switching to a dramatically different policy. It's true that doesn't happen often, and such dramatic changes are usually made with enforcing (at least) off. Still, I don't think redefining the definition of file_type is the right answer. Maybe, as you suggest more fundamental changes are needed, but that will require a lot more thought.
Signature · 9 lines
Howard Holm <[email protected]> Office of Defensive Computing Research 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.
Quoted 2 lines · Howard Holm
While I agree that it would be beneficial to have assertions to catch stupid policy, I think your current solution has a serious drawback. By
I agree that my current solution has some issues, which is why I think that a kernel change is required.
Quoted 2 lines
removing
file_typefromunlabeled_tyou break the notion thatfile_typeincludes all types on persistent media.
It changes that notion to "all types that are correctly labeled on persistent media".
Quoted 7 lines
This means that existing rules
such as# Relabel all files.
allow $1_t file_type:dir { getattr read search relabelfrom relabelto }; allow $1_t file_type:file_class_set { getattr relabelfrom relabelto };
Quoted 6 lines
are no longer useful. While you could change those to
allow $1_t sysadmfile:dir { getattr read search relabelfrom relabelto }; allow $1_t sysadmfile:file_class_set { getattr relabelfrom relabelto };
as you suggest, not all files on persistent media are labeled with
I think you may have confused two of my messages here. I changed my policy to not allow sysadm_t to relabel file_type as that would allow relabelling shadow_t and thus require the "auth" attribute for sysadm_t (and I want to limit that attribute to as few domains as possible). The administrator can run setfiles to relabel to/from shadow_t in the default policy (which should be enough). I want to add a number of new attributes for domains that can do dangerous things, then we can easily track which domains need to be audited, and we can have assertions to avoid accidentally giving unnecessary and dangerous privs when we don't need to.
In terms of unlabeled_t, if we remove the file_type attribute from it then we can always replace "file_type" with { file_type unlabeled_t } when we want to refer to unlabeled_t too. It can be a bit painful while we track down the loose ends in the policy, but it's doable.
Quoted 2 lines
sysadmfile. In particular, I believe a number of devices, the shadow file, etc. don't have the sysadmfile attribute. While sysadmfile may be
The devices are another issue. I have been meaning to create a new attribute for them, then I can have an assertion that device nodes can only have suitable device types. Allowing a device node to be relabeled to have (for example) shadow_t does no good.
I am not sure whether I should even put in policy allowing relabeling chr_file or blk_file classes from invalid types. For some of these things I'm thinking of putting ifdef's around them, so on a small machine such as an iPaQ you can skip some of that (if your iPaQ gets messed you then you just wipe it).
Quoted 4 lines
sufficient for relabeling most mistakes, it isn't sufficient to relabel files when policy updates make dramatic changes or when switching to a dramatically different policy. It's true that doesn't happen often, and such dramatic changes are usually made with enforcing (at least) off.
That's a good point to raise. Currently we don't permit relabelling from domain to file_type at all. Also we have some problems when a process gets the type of a file. If through gross manipulation of policy you get a process running as root:sysadm_r:sbin_t and a sane policy loaded then you'll find that init can't reap the process.
Quoted 3 lines
Still, I don't think redefining the definition of
file_typeis the right answer. Maybe, as you suggest more fundamental changes are needed, but that will require a lot more thought.
True, we don't want to rush in to having a new revision of the binary policy (and if it's back-ported to the old SE Linux it'll take one of the last two binary policy revision numbers available).
Signature · 10 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- 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.
Quoted 7 lines · Russell Coker
But it occurs to me that this may be a symptom of an error in design. An unlabeled process is quite a different thing from an unlabeled file. Allowing read access to unlabeled files and directories on a file system has different implications than allowing "ps" to show unlabeled processes. I think that the correct solution to this requires a kernel change to have
unlabeled_process_tandunlabeled_file_t(or other names as considered appropriate).
Ordinarily, this distinction is handled by the security class, and does not require a different type. However, /proc/pid is a special case, as it exports process state via files and is labeled with the same label as the corresponding process (and hence its domain).
One possibility would be to define derived types for the /proc/pid files for each domain and label these inodes with these derived types rather than the domains (by calling security_transition_sid in security_task_to_inode, and defining type transition rules in the policy). This would eliminate the use of domains as types for files from the policy entirely, so you would never have a domain associated with a file security class in the policy.
I doubt we really want to introduce separate initial SIDs for unlabeled instances of each class of object. However, as a separate issue, it would be desirable to rework the initial SID support to allow easier extension.
Signature · 8 lines
Stephen Smalley <[email protected]> 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.