devfs_contexts
How exactly is devfs_contexts supposed to work, when is it applied?
The default settings in the file appear to be applied, here is a sample:
root@test:/etc/flask# stat /dev/null /dev/random File: "/dev/null" Size: 0 Blocks: 0 IO Block: 1024 Character Device Device: 7h/7d Inode: 9 Links: 1 Device type: 1,3 Access: (0666/crw-rw-rw-) Uid: ( 0/ root) Gid: ( 0/ root) Access: Thu Jan 1 01:00:00 1970 Modify: Thu Jan 1 01:00:00 1970 Change: Thu Jan 1 01:00:00 1970
SID: 33
S_context: system_u:object_r:null_device_t
File: "/dev/random"
Size: 0 Blocks: 0 IO Block: 1024 Character Device
Device: 7h/7d Inode: 13 Links: 1 Device type: 1,8
Access: (0666/crw-rw-rw-) Uid: ( 0/ root) Gid: ( 0/ root)
Access: Thu Jan 1 01:00:00 1970
Modify: Thu Jan 1 01:00:00 1970
Change: Fri Jan 18 03:38:15 2002
SID: 130
S_context: system_u:object_r:random_device_t
However I added the following line to the file:
/vc/0 system_u:object_r:devtty_t
But then after loading the new policy it's still not there!
root@test:/etc/flask# make load install -m 644 -o root -g root policy /ss_policy /usr/bin/load_policy /ss_policy
Success
root@test:/etc/flask# stat /dev/vc/0 File: "/dev/vc/0" Size: 0 Blocks: 0 IO Block: 1024 Character Device Device: 7h/7d Inode: 83 Links: 1 Device type: 4,0 Access: (0666/crw-rw-rw-) Uid: ( 0/ root) Gid: ( 5/ tty) Access: Thu Jan 1 01:00:00 1970 Modify: Thu Jan 1 01:00:00 1970 Change: Fri Jan 18 03:38:15 2002
SID: 34
S_context: system_u:object_r:device_t
root@test:/etc/flask#
PS I'm running 2.4.17 with the latest patch for the utilities (thanks Stephen).
Signature · 9 lines
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/projects.html Projects I am working on http://www.coker.com.au/~russell/ My home page -- You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 1 line · Russell Coker
How exactly is
devfs_contextssupposed to work, when is it applied?
The devfs_contexts file is consulted for each devfs inode when that inode is first caught by a LSM hook. So subsequent updates to devfs_contexts won't be propagated to existing inodes. Try using chcon on existing nodes.
--
Stephen D. Smalley, NAI Labs
[email protected]
--
You have received this message because you are subscribed to the selinux 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 · Stephen Smalley
Quoted 1 line · Russell Coker
How exactly is
devfs_contextssupposed to work, when is it applied?The
devfs_contextsfile is consulted for each devfs inode when that inode is first caught by a LSM hook. So subsequent updates todevfs_contextswon't be propagated to existing inodes. Try using chcon on existing nodes.
OK. I've just used chsid as I can't find chcon. Is chcon still in the source distribution? If so where?
Signature · 9 lines
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/projects.html Projects I am working on http://www.coker.com.au/~russell/ My home page -- You have received this message because you are subscribed to the selinux 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 · Russell Coker
OK. I've just used chsid as I can't find chcon. Is chcon still in the source distribution? If so where?
chcon is in the modified fileutils package. But you can also use chsid or setfiles to label existing devfs nodes - all three programs invoke the chsid system call to set the label on a file when run on a SELinux kernel. chcon is merely a nicer interface than chsid that is derived from the existing chmod/chown programs in fileutils.
For filesystems that use the persistent label mapping (e.g. ext2, ext3, reiserfs), the label will set by the chsid call be retained across reboots since it is stored in that mapping. For pseudo filesystems like devfs, the label won't be retained across reboots unless you also add it to devfs_contexts, because there is no persistent storage of the label. So, if you want the labels to persist, you'll need to update devfs_contexts and then reboot.
--
Stephen D. Smalley, NAI Labs
[email protected]
--
You have received this message because you are subscribed to the selinux 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 · Stephen Smalley
For filesystems that use the persistent label mapping (e.g. ext2, ext3, reiserfs), the label will set by the chsid call be retained across reboots since it is stored in that mapping. For pseudo filesystems like devfs, the label won't be retained across reboots unless you also add it to
devfs_contexts, because there is no persistent storage of the label. So, if you want the labels to persist, you'll need to updatedevfs_contextsand then reboot.
Do you think it would make sense to have a SE version of devfsd that applied SE SID's at the same time as applying regular permissions to devfs managed device nodes? It makes sense to me to have both regular file system permissions and SE sids applied at the same time.
I could do the devfsd patch in a small amount of time if desired (I've written plenty of patches for devfsd already so I know the code reasonably well).
NB I've CC'd Richard Gooch to get his opinions on this matter.
Signature · 9 lines
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/projects.html Projects I am working on http://www.coker.com.au/~russell/ My home page -- You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 4 lines · Russell Coker
Do you think it would make sense to have a SE version of devfsd that applied SE SID's at the same time as applying regular permissions to devfs managed device nodes? It makes sense to me to have both regular file system permissions and SE sids applied at the same time.
Yes, this would make sense. You would also need to define a domain for devfsd.
--
Stephen D. Smalley, NAI Labs
[email protected]
--
You have received this message because you are subscribed to the selinux list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Richard Gooch
Quoted 10 lines
Do you think it would make sense to have a SE version of devfsd that applied SE SID's at the same time as applying regular permissions to devfs managed device nodes? It makes sense to me to have both regular file system permissions and SE sids applied at the same time.
I could do the devfsd patch in a small amount of time if desired (I've written plenty of patches for devfsd already so I know the code reasonably well).
Quoted 5 lines
Quoted 1 line
NB I've CC'd Richard Gooch to get his opinions on this matter.
First, can someone answer these questions:
- how much code is required to support this
I have attached the source to chsid.c, the source for the chsid program. It operates in a similar fashion to chown(1). As you can see there isn't much code. All I have to do is to parse the config file for an extra parameter.
At this stage I wouldn't be volunteering to write it if I though it would take a lot of code. ;)
Quoted 1 line
- will it break compilation of devfsd on non-SELinux systems
I was thinking of putting #ifdef SELINUX around it all.
Quoted 1 line
- will an SELinux-enabled devfsd run on normal systems
Yes. It can detect that there is no SE code running, log a warning message and just run with regular functionality.
Quoted 1 line
- what are these
devfs_contextsand where are they kept
Currently devfs_contexts is compiled and stored in the database /ss_policy , the kernel loads that file and then processes it accordingly.
Quoted 1 line
- where are the SELinux SID's kept? In the VFS inode?
It appears to be in the inode in the VFS.
For regular file systems such as Ext2 and ReiserFS the inode number is used as an index to a per-file-system database of security permissions which is then consulted as necessary.
Signature · 4 lines
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/projects.html Projects I am working on http://www.coker.com.au/~russell/ My home page
#include <fs_secure.h>
#include <ss.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
security_id_t sid;
int rc, i;
if (argc < 3) {
printf("usage: %s sid/context pathname...\n", argv[0]);
exit(1);
}
sid = atoi(argv[1]);
if (!sid) {
rc = security_context_to_sid(argv[1], strlen(argv[1]) + 1,
&sid);
if (rc) {
perror(argv[1]);
exit(1);
}
}
for (i = 2; i < argc; i++) {
if (chsid(argv[i], sid) < 0) {
perror(argv[i]);
exit(2);
}
}
exit(0);
}