diff options
author | James Morris <jmorris@namei.org> | 2006-03-22 00:09:20 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-22 07:54:07 -0800 |
commit | edb20fb5be2ff6943920aca4ccab0f4fdacddb9c (patch) | |
tree | 6961017d5b02a6320b85826c33ccc81017c2e58f /security/selinux | |
parent | d6aafa65354cd2dbb089ab9e7dc618f22230fe32 (diff) | |
download | kernel_samsung_smdk4412-edb20fb5be2ff6943920aca4ccab0f4fdacddb9c.zip kernel_samsung_smdk4412-edb20fb5be2ff6943920aca4ccab0f4fdacddb9c.tar.gz kernel_samsung_smdk4412-edb20fb5be2ff6943920aca4ccab0f4fdacddb9c.tar.bz2 |
[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/selinux')
-rw-r--r-- | security/selinux/selinuxfs.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index f321c0c..f5d7836 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c @@ -1166,12 +1166,12 @@ out: return ret; } -static int sel_make_dir(struct super_block *sb, struct dentry *dentry) +static int sel_make_dir(struct inode *dir, struct dentry *dentry) { int ret = 0; struct inode *inode; - inode = sel_make_inode(sb, S_IFDIR | S_IRUGO | S_IXUGO); + inode = sel_make_inode(dir->i_sb, S_IFDIR | S_IRUGO | S_IXUGO); if (!inode) { ret = -ENOMEM; goto out; @@ -1181,6 +1181,8 @@ static int sel_make_dir(struct super_block *sb, struct dentry *dentry) /* directory inodes start off with i_nlink == 2 (for "." entry) */ inode->i_nlink++; d_add(dentry, inode); + /* bump link count on parent directory, too */ + dir->i_nlink++; out: return ret; } @@ -1189,7 +1191,7 @@ static int sel_fill_super(struct super_block * sb, void * data, int silent) { int ret; struct dentry *dentry; - struct inode *inode; + struct inode *inode, *root_inode; struct inode_security_struct *isec; static struct tree_descr selinux_files[] = { @@ -1212,13 +1214,15 @@ static int sel_fill_super(struct super_block * sb, void * data, int silent) if (ret) goto err; + root_inode = sb->s_root->d_inode; + dentry = d_alloc_name(sb->s_root, BOOL_DIR_NAME); if (!dentry) { ret = -ENOMEM; goto err; } - ret = sel_make_dir(sb, dentry); + ret = sel_make_dir(root_inode, dentry); if (ret) goto err; @@ -1250,7 +1254,7 @@ static int sel_fill_super(struct super_block * sb, void * data, int silent) goto err; } - ret = sel_make_dir(sb, dentry); + ret = sel_make_dir(root_inode, dentry); if (ret) goto err; |