Skip to content

Commit

Permalink
selinux: enable genfscon labeling for sysfs and pstore files
Browse files Browse the repository at this point in the history
Support per-file labeling of sysfs and pstore files based on
genfscon policy entries.  This is safe because the sysfs
and pstore directory tree cannot be manipulated by userspace,
except to unlink pstore entries.
This provides an alternative method of assigning per-file labeling
to sysfs or pstore files without needing to set the labels from
userspace on each boot.  The advantages of this approach are that
the labels are assigned as soon as the dentry is first instantiated
and userspace does not need to walk the sysfs or pstore tree and
set the labels on each boot.  The limitations of this approach are
that the labels can only be assigned based on pathname prefix matching.
You can initially assign labels using this mechanism and then change
them at runtime via setxattr if allowed to do so by policy.

Signed-off-by: Stephen Smalley <[email protected]>
Suggested-by: Dominick Grift <[email protected]>
Acked-by: Jeff Vander Stoep <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
  • Loading branch information
stephensmalley authored and pcmoore committed Jun 4, 2015
1 parent 134509d commit 8e01472
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,9 @@ static int selinux_set_mnt_opts(struct super_block *sb,
if (strcmp(sb->s_type->name, "proc") == 0)
sbsec->flags |= SE_SBPROC | SE_SBGENFS;

if (strcmp(sb->s_type->name, "debugfs") == 0)
if (!strcmp(sb->s_type->name, "debugfs") ||
!strcmp(sb->s_type->name, "sysfs") ||
!strcmp(sb->s_type->name, "pstore"))
sbsec->flags |= SE_SBGENFS;

if (!sbsec->behavior) {
Expand Down

0 comments on commit 8e01472

Please sign in to comment.