* [PATCH v2] selinux: enable genfscon labeling for sysfs and pstore files
@ 2015-05-22 12:33 Stephen Smalley
2015-05-22 14:51 ` Jeffrey Vander Stoep
2015-05-29 21:12 ` Paul Moore
0 siblings, 2 replies; 3+ messages in thread
From: Stephen Smalley @ 2015-05-22 12:33 UTC (permalink / raw)
To: selinux; +Cc: Stephen Smalley
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 <sds@tycho.nsa.gov>
Suggested-by: Dominick Grift <dac.override@gmail.com>
---
This version adds support for pstore as well as sysfs.
security/selinux/hooks.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 2c616f6..070ab05 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -727,7 +727,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) {
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] selinux: enable genfscon labeling for sysfs and pstore files
2015-05-22 12:33 [PATCH v2] selinux: enable genfscon labeling for sysfs and pstore files Stephen Smalley
@ 2015-05-22 14:51 ` Jeffrey Vander Stoep
2015-05-29 21:12 ` Paul Moore
1 sibling, 0 replies; 3+ messages in thread
From: Jeffrey Vander Stoep @ 2015-05-22 14:51 UTC (permalink / raw)
To: Stephen Smalley; +Cc: SELinux
Acked-by: Jeff Vander Stoep <jeffv@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] selinux: enable genfscon labeling for sysfs and pstore files
2015-05-22 12:33 [PATCH v2] selinux: enable genfscon labeling for sysfs and pstore files Stephen Smalley
2015-05-22 14:51 ` Jeffrey Vander Stoep
@ 2015-05-29 21:12 ` Paul Moore
1 sibling, 0 replies; 3+ messages in thread
From: Paul Moore @ 2015-05-29 21:12 UTC (permalink / raw)
To: Stephen Smalley; +Cc: selinux
On Friday, May 22, 2015 08:33:47 AM Stephen Smalley wrote:
> 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 <sds@tycho.nsa.gov>
> Suggested-by: Dominick Grift <dac.override@gmail.com>
> ---
> This version adds support for pstore as well as sysfs.
>
> security/selinux/hooks.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Applied, thanks.
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 2c616f6..070ab05 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -727,7 +727,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) {
--
paul moore
www.paul-moore.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-29 21:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-22 12:33 [PATCH v2] selinux: enable genfscon labeling for sysfs and pstore files Stephen Smalley
2015-05-22 14:51 ` Jeffrey Vander Stoep
2015-05-29 21:12 ` Paul Moore
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.