aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux
diff options
context:
space:
mode:
authorJames Carter <jwcart2@tycho.nsa.gov>2007-04-04 16:18:50 -0400
committerJames Morris <jmorris@namei.org>2007-04-26 01:36:11 -0400
commitbce34bc0eef03c68b5c49a3cc5bc77c84760cfe2 (patch)
tree2ef7c5fc9578fa2a7cdfac297681f6b6a6415a53 /security/selinux
parent68b00df9bb5f38e87c102b3179a18eba9c9937a8 (diff)
selinux: change numbering of boolean directory inodes in selinuxfs
Change the numbering of the booleans directory inodes in selinuxfs to provide more room for new inodes without a conflict in inode numbers and to be consistent with how inode numbering is done in the initial_contexts directory. Signed-off-by: James Carter <jwcart2@tycho.nsa.gov> Acked-by: Eric Paris <eparis@parisplace.org> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/selinux')
-rw-r--r--security/selinux/selinuxfs.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index 097bc0409553..aca099aa2ed3 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -105,6 +105,7 @@ enum sel_inos {
105static unsigned long sel_last_ino = SEL_INO_NEXT - 1; 105static unsigned long sel_last_ino = SEL_INO_NEXT - 1;
106 106
107#define SEL_INITCON_INO_OFFSET 0x01000000 107#define SEL_INITCON_INO_OFFSET 0x01000000
108#define SEL_BOOL_INO_OFFSET 0x02000000
108#define SEL_INO_MASK 0x00ffffff 109#define SEL_INO_MASK 0x00ffffff
109 110
110#define TMPBUFLEN 12 111#define TMPBUFLEN 12
@@ -782,8 +783,6 @@ static struct inode *sel_make_inode(struct super_block *sb, int mode)
782 return ret; 783 return ret;
783} 784}
784 785
785#define BOOL_INO_OFFSET 30
786
787static ssize_t sel_read_bool(struct file *filep, char __user *buf, 786static ssize_t sel_read_bool(struct file *filep, char __user *buf,
788 size_t count, loff_t *ppos) 787 size_t count, loff_t *ppos)
789{ 788{
@@ -811,14 +810,14 @@ static ssize_t sel_read_bool(struct file *filep, char __user *buf,
811 } 810 }
812 811
813 inode = filep->f_path.dentry->d_inode; 812 inode = filep->f_path.dentry->d_inode;
814 cur_enforcing = security_get_bool_value(inode->i_ino - BOOL_INO_OFFSET); 813 cur_enforcing = security_get_bool_value(inode->i_ino&SEL_INO_MASK);
815 if (cur_enforcing < 0) { 814 if (cur_enforcing < 0) {
816 ret = cur_enforcing; 815 ret = cur_enforcing;
817 goto out; 816 goto out;
818 } 817 }
819 818
820 length = scnprintf(page, PAGE_SIZE, "%d %d", cur_enforcing, 819 length = scnprintf(page, PAGE_SIZE, "%d %d", cur_enforcing,
821 bool_pending_values[inode->i_ino - BOOL_INO_OFFSET]); 820 bool_pending_values[inode->i_ino&SEL_INO_MASK]);
822 ret = simple_read_from_buffer(buf, count, ppos, page, length); 821 ret = simple_read_from_buffer(buf, count, ppos, page, length);
823out: 822out:
824 mutex_unlock(&sel_mutex); 823 mutex_unlock(&sel_mutex);
@@ -870,7 +869,7 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf,
870 new_value = 1; 869 new_value = 1;
871 870
872 inode = filep->f_path.dentry->d_inode; 871 inode = filep->f_path.dentry->d_inode;
873 bool_pending_values[inode->i_ino - BOOL_INO_OFFSET] = new_value; 872 bool_pending_values[inode->i_ino&SEL_INO_MASK] = new_value;
874 length = count; 873 length = count;
875 874
876out: 875out:
@@ -1034,7 +1033,7 @@ static int sel_make_bools(void)
1034 isec->sid = sid; 1033 isec->sid = sid;
1035 isec->initialized = 1; 1034 isec->initialized = 1;
1036 inode->i_fop = &sel_bool_ops; 1035 inode->i_fop = &sel_bool_ops;
1037 inode->i_ino = i + BOOL_INO_OFFSET; 1036 inode->i_ino = i|SEL_BOOL_INO_OFFSET;
1038 d_add(dentry, inode); 1037 d_add(dentry, inode);
1039 } 1038 }
1040 bool_num = num; 1039 bool_num = num;