ichsid
I believe that we need a program "ichsid" to change the SID of a file by Inode instead of by name.
The reason for this is for the mount points of /dev, /proc, /usr, and other file systems that are not easily/conveniantly umountable.
Providing this functionality as part of the setfiles ability to change the context database directly when running on a non-SE kernel should not be difficult, and would provide the minimum functionality for getting SE Linux on a machine with a few reboots (boot into SE Linux, see messages such as the following, boot into non-SE Linux to run setfiles, then boot SE again) or with some debugfs work.
Providing it as part of the kernel interface would be even more useful.
avc: denied { mounton } for pid=217 exe=/bin/mount path=/var/cache dev=09:01 ino=144930 scontext=system_u:system_r:mount_t tcontext=system_u:object_r:var_t tclass=dir
Now if I want to change the SID of /var/cache I'll have to kill squid first...
Signature · 3 lines
I do not get viruses because I do not use MS software. If you use Outlook then please do not put my email address in your address-book so that WHEN you get a virus it won't use my address in the
Quoted 1 line
From field.
--
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 6 lines · Russell Coker
I believe that we need a program "ichsid" to change the SID of a file by Inode instead of by name.
The reason for this is for the mount points of /dev, /proc, /usr, and other file systems that are not easily/conveniantly umountable.
Quoted 8 lines
Providing this functionality as part of the setfiles ability to change the context database directly when running on a non-SE kernel should not be difficult, and would provide the minimum functionality for getting SE Linux on a machine with a few reboots (boot into SE Linux, see messages such as the following, boot into non-SE Linux to run setfiles, then boot SE again) or with some debugfs work.
Providing it as part of the kernel interface would be even more useful.
As you mention, providing the functionality in setfiles to directly update the persistent label mapping based on inode number should be straightforward, although I'm not sure about the right interface (e.g. just a command-line invocation or a new form of specification in file_contexts). You would need to specify the particular filesystem as well as the inode number, so you might specify the path of any file within the filesystem, like statfs, and the particular inode number.
A kernel interface to update the persistent label mapping for an inode number would likewise be straightforward, although it would bypass the typical search permission checks on the directories in the path that are performed by the existing chsid call. However, finding the in-core inode (if one exists) so that we can update it with the new SID might pose a problem for filesystems where the inode number is not sufficient for finding files, like reiserfs.
--
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 8 lines · Russell Coker
Providing this functionality as part of the setfiles ability to change the context database directly when running on a non-SE kernel should not be difficult, and would provide the minimum functionality for getting SE Linux on a machine with a few reboots (boot into SE Linux, see messages such as the following, boot into non-SE Linux to run setfiles, then boot SE again) or with some debugfs work.
Providing it as part of the kernel interface would be even more useful.
I've attached an experimental set of patches and new files for ichsid-style functionality. To apply _for experimentation purposes only_, save the patches and archive to your home directory and do the following:
cd lsm-2.4 patch -p0 < ~/lsm-2.4-ichsid.patch cd ../selinux patch -p0 < ~/selinux-ichsid.patch tar xvzf ~/selinux-ichsid.tgz
You will then need to build and install the modified kernel, install the updated header files (make install in selinux/module), build and install the updated libsecure, and build and install the updated setfiles program.
Afterward, 'setfiles -i pathname ino context' can be used to set the context of an inode, where pathname is the path of any file within the desired filesystem and ino is the inode number. If run on a SELinux kernel, it will use the new ichsid call; otherwise, it will directly mutate the persistent label mapping.
The ichsid call will only work if the filesystem type supports finding inodes by inode number. It appears to work with ext[23], but should fail on reiserfs.
--
Stephen D. Smalley, NAI Labs
[email protected]
Index: security/selinux/syscalls.c
===================================================================
RCS file: /cvs/lsm/lsm-2.4/security/selinux/syscalls.c,v retrieving revision 1.9
selinux/syscalls.c +46 -6
@@ -117,16 +117,23 @@return 0 ; } - -static int chsid_common (struct dentry * dentry,security_id_t newsid) +/* Only one of the dentry and inode arguments needs to +be specified. The other parameter should be NULL. +Use dentry if one is available to the caller. Otherwise, +use inode. */ +static int chsid_common (struct dentry *dentry, +struct inode * inode, +security_id_t newsid) { -struct inode *inode = dentry->d_inode;struct task_security_struct *tsec;struct inode_security_struct *isec;struct superblock_security_struct *sbsec;avc_audit_data_t ad;int rc =0 ; +if (dentry) + inode = dentry->d_inode; +if (!inode) {printk ("chsid_common: NULL inode\n" );return -ENOENT ;
@@ -144,7 +151,10 @@ isec = inode->i_security;AVC_AUDIT_DATA_INIT (&ad,FS ); - ad.u.fs.dentry = dentry; +if (dentry) + ad.u.fs.dentry = dentry; +else + ad.u.fs.inode = inode;down (&isec->sem);
@@ -195,7 +205,7 @@else error =user_path_walk_link (filename, &nd);if (!error) { - error =chsid_common (nd.dentry, sid); + error =chsid_common (nd.dentry,NULL , sid);path_release (&nd); }return error;
@@ -208,8 +218,38 @@ file =fget (fd);if (file) { - error =chsid_common (file->f_dentry, sid); + error =chsid_common (file->f_dentry,NULL , sid);fput (file); + } +return error; +} + +long sys_ichsid (const char *filename, +unsigned long ino, +security_id_t sid) +{ +struct nameidata nd; +struct super_block *sb; +struct inode *inode; +int error; + +if (!ino) +return -EINVAL ; + + error =user_path_walk (filename, &nd); +if (!error) { + error = -ENODEV ; + sb = nd.dentry->d_inode->i_sb; +if (sb) { + error = -ENOENT ; + inode =iget (sb, ino); +if (inode) { +if (!is_bad_inode (inode)) + error =chsid_common (NULL , inode, sid); +iput (inode); + } + } +path_release (&nd); }return error; }
Index: security/selinux/include/asm-i386/flask/syscalls.c
===================================================================
RCS file: /cvs/lsm/lsm-2.4/security/selinux/include/asm-i386/flask/syscalls.c,v retrieving revision 1.4
selinux/include/asm-i386/flask/syscalls.c +6 -2
@@ -166,8 +166,9 @@AL (8 ),/* recvfrom */ AL (5 ),/* recvmsg */ AL (5 ),/* sendmsg */ -AL (8 )/* sendto */ , - AL(0) /* mls */, +AL (8 ),/* sendto */ +AL (0 ),/* mls */ + AL(3) /* ichsid */ };#undef AL
@@ -380,6 +381,9 @@break ;case SELINUXCALL_MLS : err =sys_security_mls (); +break ; +case SELINUXCALL_ICHSID : + err =sys_ichsid ((const char *)a0, a1, a[2 ]);break ;default : err = -EINVAL ;
Index: security/selinux/include/linux/flask/syscalls.h
===================================================================
RCS file: /cvs/lsm/lsm-2.4/security/selinux/include/linux/flask/syscalls.h,v retrieving revision 1.5
selinux/include/linux/flask/syscalls.h +3 -1
@@ -70,7 +70,9 @@#define SELINUXCALL_MLS 51 -#define SELINUXCALL_NUM 51 +#define SELINUXCALL_ICHSID 52 + +#define SELINUXCALL_NUM 52/* Structure definitions for compute_av call */ struct security_query {
Index: libsecure/include/fs_secure.h
===================================================================
RCS file: /cvs/lsm/selinux/libsecure/include/fs_secure.h,v retrieving revision 1.4
include/fs_secure.h +4 -0
@@ -29,6 +29,10 @@extern int chsid (const char *pathname,security_id_t sid); +extern int ichsid (const char *pathname, +unsigned long ino, +security_id_t sid); +extern int lchsid (const char *pathname,security_id_t sid);
Index: setfiles/setfiles.c
===================================================================
RCS file: /cvs/lsm/selinux/setfiles/setfiles.c,v
retrieving revision 1.11
setfiles.c +55 -1
78 lines not on this page · raw message
Quoted 5 lines · Stephen Smalley
Afterward, 'setfiles -i pathname ino context' can be used to set the context of an inode, where pathname is the path of any file within the desired filesystem and ino is the inode number. If run on a SELinux kernel, it will use the new ichsid call; otherwise, it will directly mutate the persistent label mapping.
Sorry, I mis-spoke. pathname should be the path of the root of the desired filesystem, as with the typical setfiles usage. Otherwise, when run on a non-SELinux kernel, setfiles won't find the persistent label mapping properly. When run on a SELinux kernel, pathname can actually be any path within the filesystem, since the ichsid call merely extracts the superblock from the looked up inode.
--
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.