aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorCasey Schaufler <casey@schaufler-ca.com>2012-05-23 20:46:58 -0400
committerCasey Schaufler <casey@schaufler-ca.com>2012-07-13 18:49:23 -0400
commiteb982cb4cf6405b97ea1f9e1d10864981f269d46 (patch)
tree8d89448e0ef96d587ea8052021a721e632b4b318 /security
parent417c6c8ee2eb6975f357d8975af94ba5fbeaf82d (diff)
Smack: fix smack_new_inode bogosities
In January of 2012 Al Viro pointed out three bits of code that he titled "new_inode_smack bogosities". This patch repairs these errors. 1. smack_sb_kern_mount() included a NULL check that is impossible. The check and NULL case are removed. 2. smack_kb_kern_mount() included pointless locking. The locking is removed. Since this is the only place that lock was used the lock is removed from the superblock_smack structure. 3. smk_fill_super() incorrectly and unnecessarily set the Smack label for the smackfs root inode. The assignment has been removed. Targeted for git://gitorious.org/smack-next/kernel.git Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Diffstat (limited to 'security')
-rw-r--r--security/smack/smack.h1
-rw-r--r--security/smack/smack_lsm.c8
-rw-r--r--security/smack/smackfs.c1
3 files changed, 2 insertions, 8 deletions
diff --git a/security/smack/smack.h b/security/smack/smack.h
index cc361b8f3d1..76feb31eb82 100644
--- a/security/smack/smack.h
+++ b/security/smack/smack.h
@@ -43,7 +43,6 @@ struct superblock_smack {
43 char *smk_hat; 43 char *smk_hat;
44 char *smk_default; 44 char *smk_default;
45 int smk_initialized; 45 int smk_initialized;
46 spinlock_t smk_sblock; /* for initialization */
47}; 46};
48 47
49struct socket_smack { 48struct socket_smack {
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index ee0bb5735f3..29bb4e7fa5e 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -251,7 +251,6 @@ static int smack_sb_alloc_security(struct super_block *sb)
251 sbsp->smk_floor = smack_known_floor.smk_known; 251 sbsp->smk_floor = smack_known_floor.smk_known;
252 sbsp->smk_hat = smack_known_hat.smk_known; 252 sbsp->smk_hat = smack_known_hat.smk_known;
253 sbsp->smk_initialized = 0; 253 sbsp->smk_initialized = 0;
254 spin_lock_init(&sbsp->smk_sblock);
255 254
256 sb->s_security = sbsp; 255 sb->s_security = sbsp;
257 256
@@ -332,13 +331,10 @@ static int smack_sb_kern_mount(struct super_block *sb, int flags, void *data)
332 char *commap; 331 char *commap;
333 char *nsp; 332 char *nsp;
334 333
335 spin_lock(&sp->smk_sblock); 334 if (sp->smk_initialized != 0)
336 if (sp->smk_initialized != 0) {
337 spin_unlock(&sp->smk_sblock);
338 return 0; 335 return 0;
339 } 336
340 sp->smk_initialized = 1; 337 sp->smk_initialized = 1;
341 spin_unlock(&sp->smk_sblock);
342 338
343 for (op = data; op != NULL; op = commap) { 339 for (op = data; op != NULL; op = commap) {
344 commap = strchr(op, ','); 340 commap = strchr(op, ',');
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 1810c9a4ed4..3686db7e2c6 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -2051,7 +2051,6 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
2051 } 2051 }
2052 2052
2053 root_inode = sb->s_root->d_inode; 2053 root_inode = sb->s_root->d_inode;
2054 root_inode->i_security = new_inode_smack(smack_known_floor.smk_known);
2055 2054
2056 return 0; 2055 return 0;
2057} 2056}