Skip to contentSkip to conversation

pstore: selinux: add security in-core xattr support for pstore and debugfs

PATCH In review Mark Salyzyn 3 participants 3 messages Jan 13, 2015 – Jan 14, 2015 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 5/5 pstore: selinux: add security in-core xattr support for pstore and debugfs

- add "pstore" and "debugfs" to list of in-core exceptions
- change fstype checks to boolean equation
- change from strncmp to strcmp for checking

---
 security/selinux/hooks.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)
security/selinux/hooks.c +8 -17
index 6da7532..789a7e1 100644
@@ -401,23 +401,14 @@ static int selinux_is_sblabel_mnt(struct super_block *sb)
 {
 	struct superblock_security_struct *sbsec = sb->s_security;
 
-	if (sbsec->behavior == SECURITY_FS_USE_XATTR ||
-	    sbsec->behavior == SECURITY_FS_USE_TRANS ||
-	    sbsec->behavior == SECURITY_FS_USE_TASK)
-		return 1;
-
-	/* Special handling for sysfs. Is genfs but also has setxattr handler*/
-	if (strncmp(sb->s_type->name, "sysfs", sizeof("sysfs")) == 0)
-		return 1;
-
-	/*
-	 * Special handling for rootfs. Is genfs but supports
-	 * setting SELinux context on in-core inodes.
-	 */
-	if (strncmp(sb->s_type->name, "rootfs", sizeof("rootfs")) == 0)
-		return 1;
-
-	return 0;
+	return sbsec->behavior == SECURITY_FS_USE_XATTR ||
+		sbsec->behavior == SECURITY_FS_USE_TRANS ||
+		sbsec->behavior == SECURITY_FS_USE_TASK ||
+		/* Special handling. Genfs but also in-core setxattr handler */
+		!strcmp(sb->s_type->name, "sysfs") ||
+		!strcmp(sb->s_type->name, "pstore") ||
+		!strcmp(sb->s_type->name, "debugfs") ||
+		!strcmp(sb->s_type->name, "rootfs");
 }
 
 static int sb_finish_set_opts(struct super_block *sb)
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Acked-by on v1 5/5
#1 lore raw
Quoted 5 lines · Mark Salyzyn

- add "pstore" and "debugfs" to list of in-core exceptions
- change fstype checks to boolean equation
- change from strncmp to strcmp for checking

Quoted 47 lines
---
 security/selinux/hooks.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)
security/selinux/hooks.c +8 -18
index 6da7532..789a7e1 100644
@@ -401,23 +401,14 @@ static int selinux_is_sblabel_mnt(struct super_block *sb)
 {
        struct superblock_security_struct *sbsec = sb->s_security;
 
-       if (sbsec->behavior == SECURITY_FS_USE_XATTR ||
-           sbsec->behavior == SECURITY_FS_USE_TRANS ||
-           sbsec->behavior == SECURITY_FS_USE_TASK)
-               return 1;
-
-       /* Special handling for sysfs. Is genfs but also has setxattr handler*/
-       if (strncmp(sb->s_type->name, "sysfs", sizeof("sysfs")) == 0)
-               return 1;
-
-       /*
-        * Special handling for rootfs. Is genfs but supports
-        * setting SELinux context on in-core inodes.
-        */
-       if (strncmp(sb->s_type->name, "rootfs", sizeof("rootfs")) == 0)
-               return 1;
-
-       return 0;
+       return sbsec->behavior == SECURITY_FS_USE_XATTR ||
+               sbsec->behavior == SECURITY_FS_USE_TRANS ||
+               sbsec->behavior == SECURITY_FS_USE_TASK ||
+               /* Special handling. Genfs but also in-core setxattr handler */
+               !strcmp(sb->s_type->name, "sysfs") ||
+               !strcmp(sb->s_type->name, "pstore") ||
+               !strcmp(sb->s_type->name, "debugfs") ||
+               !strcmp(sb->s_type->name, "rootfs");
 }
 
 static int sb_finish_set_opts(struct super_block *sb)
--

2.2.0.rc0.207.ga3a616c

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#2 lore raw
In reply to Mark Salyzyn
Quoted 8 lines · Mark Salyzyn

- add "pstore" and "debugfs" to list of in-core exceptions
- change fstype checks to boolean equation
- change from strncmp to strcmp for checking

---
 security/selinux/hooks.c | 25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)

Not a huge fan of the coding style, but merged into the next branch regardless.

Thanks.

Quoted 36 lines
security/selinux/hooks.c +8 -17
index 6da7532..789a7e1 100644
@@ -401,23 +401,14 @@ static int selinux_is_sblabel_mnt(struct super_block
 *sb) {
 	struct superblock_security_struct *sbsec = sb->s_security;
 
-	if (sbsec->behavior == SECURITY_FS_USE_XATTR ||
-	    sbsec->behavior == SECURITY_FS_USE_TRANS ||
-	    sbsec->behavior == SECURITY_FS_USE_TASK)
-		return 1;
-
-	/* Special handling for sysfs. Is genfs but also has setxattr handler*/
-	if (strncmp(sb->s_type->name, "sysfs", sizeof("sysfs")) == 0)
-		return 1;
-
-	/*
-	 * Special handling for rootfs. Is genfs but supports
-	 * setting SELinux context on in-core inodes.
-	 */
-	if (strncmp(sb->s_type->name, "rootfs", sizeof("rootfs")) == 0)
-		return 1;
-
-	return 0;
+	return sbsec->behavior == SECURITY_FS_USE_XATTR ||
+		sbsec->behavior == SECURITY_FS_USE_TRANS ||
+		sbsec->behavior == SECURITY_FS_USE_TASK ||
+		/* Special handling. Genfs but also in-core setxattr handler */
+		!strcmp(sb->s_type->name, "sysfs") ||
+		!strcmp(sb->s_type->name, "pstore") ||
+		!strcmp(sb->s_type->name, "debugfs") ||
+		!strcmp(sb->s_type->name, "rootfs");
 }
 
 static int sb_finish_set_opts(struct super_block *sb)
Signature · 2 lines
paul moore
www.paul-moore.com