aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorJames Morris <jmorris@namei.org>2006-03-22 03:09:20 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-22 10:54:07 -0500
commitedb20fb5be2ff6943920aca4ccab0f4fdacddb9c (patch)
tree6961017d5b02a6320b85826c33ccc81017c2e58f /security
parentd6aafa65354cd2dbb089ab9e7dc618f22230fe32 (diff)
[PATCH] SELinux: fix hard link count for selinuxfs root directory
A further fix is needed for selinuxfs link count management, to ensure that the count is correct for the parent directory when a subdirectory is created. This is only required for the root directory currently, but the code has been updated for the general case. Signed-off-by: James Morris <jmorris@namei.org> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'security')
-rw-r--r--security/selinux/selinuxfs.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index f321c0c49f46..f5d78365488f 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1166,12 +1166,12 @@ out:
1166 return ret; 1166 return ret;
1167} 1167}
1168 1168
1169static int sel_make_dir(struct super_block *sb, struct dentry *dentry) 1169static int sel_make_dir(struct inode *dir, struct dentry *dentry)
1170{ 1170{
1171 int ret = 0; 1171 int ret = 0;
1172 struct inode *inode; 1172 struct inode *inode;
1173 1173
1174 inode = sel_make_inode(sb, S_IFDIR | S_IRUGO | S_IXUGO); 1174 inode = sel_make_inode(dir->i_sb, S_IFDIR | S_IRUGO | S_IXUGO);
1175 if (!inode) { 1175 if (!inode) {
1176 ret = -ENOMEM; 1176 ret = -ENOMEM;
1177 goto out; 1177 goto out;
@@ -1181,6 +1181,8 @@ static int sel_make_dir(struct super_block *sb, struct dentry *dentry)
1181 /* directory inodes start off with i_nlink == 2 (for "." entry) */ 1181 /* directory inodes start off with i_nlink == 2 (for "." entry) */
1182 inode->i_nlink++; 1182 inode->i_nlink++;
1183 d_add(dentry, inode); 1183 d_add(dentry, inode);
1184 /* bump link count on parent directory, too */
1185 dir->i_nlink++;
1184out: 1186out:
1185 return ret; 1187 return ret;
1186} 1188}
@@ -1189,7 +1191,7 @@ static int sel_fill_super(struct super_block * sb, void * data, int silent)
1189{ 1191{
1190 int ret; 1192 int ret;
1191 struct dentry *dentry; 1193 struct dentry *dentry;
1192 struct inode *inode; 1194 struct inode *inode, *root_inode;
1193 struct inode_security_struct *isec; 1195 struct inode_security_struct *isec;
1194 1196
1195 static struct tree_descr selinux_files[] = { 1197 static struct tree_descr selinux_files[] = {
@@ -1212,13 +1214,15 @@ static int sel_fill_super(struct super_block * sb, void * data, int silent)
1212 if (ret) 1214 if (ret)
1213 goto err; 1215 goto err;
1214 1216
1217 root_inode = sb->s_root->d_inode;
1218
1215 dentry = d_alloc_name(sb->s_root, BOOL_DIR_NAME); 1219 dentry = d_alloc_name(sb->s_root, BOOL_DIR_NAME);
1216 if (!dentry) { 1220 if (!dentry) {
1217 ret = -ENOMEM; 1221 ret = -ENOMEM;
1218 goto err; 1222 goto err;
1219 } 1223 }
1220 1224
1221 ret = sel_make_dir(sb, dentry); 1225 ret = sel_make_dir(root_inode, dentry);
1222 if (ret) 1226 if (ret)
1223 goto err; 1227 goto err;
1224 1228
@@ -1250,7 +1254,7 @@ static int sel_fill_super(struct super_block * sb, void * data, int silent)
1250 goto err; 1254 goto err;
1251 } 1255 }
1252 1256
1253 ret = sel_make_dir(sb, dentry); 1257 ret = sel_make_dir(root_inode, dentry);
1254 if (ret) 1258 if (ret)
1255 goto err; 1259 goto err;
1256 1260