浏览代码

SELinux: do all flags twiddling in one place

Currently we set the initialize and seclabel flag in one place.  Do some
unrelated printk then we unset the seclabel flag.  Eww.  Instead do the flag
twiddling in one place in the code not seperated by unrelated printk.  Also
don't set and unset the seclabel flag.  Only set it if we need to.

Signed-off-by: Eric Paris <eparis@redhat.com>
Eric Paris 13 年之前
父节点
当前提交
eadcabc697
共有 1 个文件被更改,包括 5 次插入7 次删除
  1. 5 7
      security/selinux/hooks.c

+ 5 - 7
security/selinux/hooks.c

@@ -387,8 +387,6 @@ static int sb_finish_set_opts(struct super_block *sb)
 		}
 		}
 	}
 	}
 
 
-	sbsec->flags |= (SE_SBINITIALIZED | SBLABEL_MNT);
-
 	if (sbsec->behavior > ARRAY_SIZE(labeling_behaviors))
 	if (sbsec->behavior > ARRAY_SIZE(labeling_behaviors))
 		printk(KERN_ERR "SELinux: initialized (dev %s, type %s), unknown behavior\n",
 		printk(KERN_ERR "SELinux: initialized (dev %s, type %s), unknown behavior\n",
 		       sb->s_id, sb->s_type->name);
 		       sb->s_id, sb->s_type->name);
@@ -397,11 +395,11 @@ static int sb_finish_set_opts(struct super_block *sb)
 		       sb->s_id, sb->s_type->name,
 		       sb->s_id, sb->s_type->name,
 		       labeling_behaviors[sbsec->behavior-1]);
 		       labeling_behaviors[sbsec->behavior-1]);
 
 
-	if (sbsec->behavior == SECURITY_FS_USE_GENFS ||
-	    sbsec->behavior == SECURITY_FS_USE_MNTPOINT ||
-	    sbsec->behavior == SECURITY_FS_USE_NONE ||
-	    sbsec->behavior > ARRAY_SIZE(labeling_behaviors))
-		sbsec->flags &= ~SBLABEL_MNT;
+	sbsec->flags |= SE_SBINITIALIZED;
+	if (sbsec->behavior == SECURITY_FS_USE_XATTR ||
+	    sbsec->behavior == SECURITY_FS_USE_TRANS ||
+	    sbsec->behavior == SECURITY_FS_USE_TASK)
+		sbsec->flags |= SBLABEL_MNT;
 
 
 	/* Special handling for sysfs. Is genfs but also has setxattr handler*/
 	/* Special handling for sysfs. Is genfs but also has setxattr handler*/
 	if (strncmp(sb->s_type->name, "sysfs", sizeof("sysfs")) == 0)
 	if (strncmp(sb->s_type->name, "sysfs", sizeof("sysfs")) == 0)