Skip to content

Commit d5f3a5f

Browse files
salyzynpcmoore
authored andcommitted
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 Signed-off-by: Mark Salyzyn <salyzyn@android.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> [PM: tweaked the subject line prefix to "selinux"] Signed-off-by: Paul Moore <pmoore@redhat.com>
1 parent 2088d60 commit d5f3a5f

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

security/selinux/hooks.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -401,23 +401,14 @@ static int selinux_is_sblabel_mnt(struct super_block *sb)
401401
{
402402
struct superblock_security_struct *sbsec = sb->s_security;
403403

404-
if (sbsec->behavior == SECURITY_FS_USE_XATTR ||
405-
sbsec->behavior == SECURITY_FS_USE_TRANS ||
406-
sbsec->behavior == SECURITY_FS_USE_TASK)
407-
return 1;
408-
409-
/* Special handling for sysfs. Is genfs but also has setxattr handler*/
410-
if (strncmp(sb->s_type->name, "sysfs", sizeof("sysfs")) == 0)
411-
return 1;
412-
413-
/*
414-
* Special handling for rootfs. Is genfs but supports
415-
* setting SELinux context on in-core inodes.
416-
*/
417-
if (strncmp(sb->s_type->name, "rootfs", sizeof("rootfs")) == 0)
418-
return 1;
419-
420-
return 0;
404+
return sbsec->behavior == SECURITY_FS_USE_XATTR ||
405+
sbsec->behavior == SECURITY_FS_USE_TRANS ||
406+
sbsec->behavior == SECURITY_FS_USE_TASK ||
407+
/* Special handling. Genfs but also in-core setxattr handler */
408+
!strcmp(sb->s_type->name, "sysfs") ||
409+
!strcmp(sb->s_type->name, "pstore") ||
410+
!strcmp(sb->s_type->name, "debugfs") ||
411+
!strcmp(sb->s_type->name, "rootfs");
421412
}
422413

423414
static int sb_finish_set_opts(struct super_block *sb)

0 commit comments

Comments
 (0)