Skip to content

Commit eb982cb

Browse files
committed
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>
1 parent 417c6c8 commit eb982cb

3 files changed

Lines changed: 2 additions & 8 deletions

File tree

‎security/smack/smack.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ struct superblock_smack {
4343
char *smk_hat;
4444
char *smk_default;
4545
int smk_initialized;
46-
spinlock_t smk_sblock; /* for initialization */
4746
};
4847

4948
struct socket_smack {

‎security/smack/smack_lsm.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ static int smack_sb_alloc_security(struct super_block *sb)
251251
sbsp->smk_floor = smack_known_floor.smk_known;
252252
sbsp->smk_hat = smack_known_hat.smk_known;
253253
sbsp->smk_initialized = 0;
254-
spin_lock_init(&sbsp->smk_sblock);
255254

256255
sb->s_security = sbsp;
257256

@@ -332,13 +331,10 @@ static int smack_sb_kern_mount(struct super_block *sb, int flags, void *data)
332331
char *commap;
333332
char *nsp;
334333

335-
spin_lock(&sp->smk_sblock);
336-
if (sp->smk_initialized != 0) {
337-
spin_unlock(&sp->smk_sblock);
334+
if (sp->smk_initialized != 0)
338335
return 0;
339-
}
336+
340337
sp->smk_initialized = 1;
341-
spin_unlock(&sp->smk_sblock);
342338

343339
for (op = data; op != NULL; op = commap) {
344340
commap = strchr(op, ',');

‎security/smack/smackfs.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2051,7 +2051,6 @@ static int smk_fill_super(struct super_block *sb, void *data, int silent)
20512051
}
20522052

20532053
root_inode = sb->s_root->d_inode;
2054-
root_inode->i_security = new_inode_smack(smack_known_floor.smk_known);
20552054

20562055
return 0;
20572056
}

0 commit comments

Comments
 (0)