Skip to contentSkip to conversation

security: selinux: allow changing labels for cgroupfs

PATCH Superseded Antonio Murdaca 3 participants 4 messages Feb 2, 2017 1 message not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 security: selinux: allow changing labels for cgroupfs

This patch allows changing labels for cgroup mounts. Previously, running chcon on cgroupfs would throw an "Operation not supported". This patch specifically whitelist cgroupfs.

The patch could also allow containers to write only to the systemd cgroup for instance, while the other cgroups are kept with cgroup_t label.

---
 security/selinux/hooks.c | 1 +
 1 file changed, 1 insertion(+)
security/selinux/hooks.c +1 -0
index 3b955c6..4e84211 100644
@@ -480,6 +480,7 @@ static int selinux_is_sblabel_mnt(struct super_block *sb)
 		sbsec->behavior == SECURITY_FS_USE_NATIVE ||
 		/* Special handling. Genfs but also in-core setxattr handler */
 		!strcmp(sb->s_type->name, "sysfs") ||
+		!strcmp(sb->s_type->name, "cgroup") ||
 		!strcmp(sb->s_type->name, "pstore") ||
 		!strcmp(sb->s_type->name, "debugfs") ||
 		!strcmp(sb->s_type->name, "tracefs") ||
Signature · 1 line
2.9.3
#1 lore raw
Quoted 17 lines · Antonio Murdaca

This patch allows changing labels for cgroup mounts. Previously, running chcon on cgroupfs would throw an "Operation not supported". This patch specifically whitelist cgroupfs.

The patch could also allow containers to write only to the systemd cgroup for instance, while the other cgroups are kept with cgroup_t label.

---
 security/selinux/hooks.c | 1 +
 1 file changed, 1 insertion(+)
security/selinux/hooks.c +0 -0
index 3b955c6..4e84211 100644

security/selinux/hooks.c static int selinux_is_sblabel_mnt(struct super_block *sb) · line 483

Quoted 4 lines
security/selinux/hooks.c +1 -0
@@ -480,6 +480,7 @@ static int selinux_is_sblabel_mnt(struct super_block *sb)
 		sbsec->behavior == SECURITY_FS_USE_NATIVE ||
 		/* Special handling. Genfs but also in-core setxattr handler */
 		!strcmp(sb->s_type->name, "sysfs") ||
+		!strcmp(sb->s_type->name, "cgroup") ||

Should we also include "cgroup2" here, since they are defined as 2
distinct filesystems? https://github.com/SELinuxProject/selinux-kernel/blob/master/kernel/cgroup.c#L2314-L2326

Quoted 11 lines
security/selinux/hooks.c +0 -0
 		!strcmp(sb->s_type->name, "pstore") ||
 		!strcmp(sb->s_type->name, "debugfs") ||
 		!strcmp(sb->s_type->name, "tracefs") ||
Signature · 7 lines
2.9.3

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]
To get help, send an email containing "help" to [email protected]
#3 lore raw
In reply to a message not in the archive
Quoted 21 lines · Gary Tierney

security/selinux/hooks.c static int selinux_is_sblabel_mnt(struct super_block

Quoted 17 lines · Antonio Murdaca

This patch allows changing labels for cgroup mounts. Previously, running chcon on cgroupfs would throw an "Operation not supported". This patch specifically whitelist cgroupfs.

The patch could also allow containers to write only to the systemd cgroup for instance, while the other cgroups are kept with cgroup_t label.

---
 security/selinux/hooks.c | 1 +
 1 file changed, 1 insertion(+)
security/selinux/hooks.c +0 -0
index 3b955c6..4e84211 100644
@@ -480,6 +480,7 @@ static int selinux_is_sblabel_mnt(struct super_block

*sb)

security/selinux/hooks.c static int selinux_is_sblabel_mnt(struct super_block · line 481

Quoted 2 lines
security/selinux/hooks.c +0 -0
              sbsec->behavior == SECURITY_FS_USE_NATIVE ||
              /* Special handling. Genfs but also in-core setxattr
Quoted 7 lines

handler */

security/selinux/hooks.c static int selinux_is_sblabel_mnt(struct super_block *sb) · line 483

Quoted 2 lines
security/selinux/hooks.c +1 -0
              !strcmp(sb->s_type->name, "sysfs") ||
+             !strcmp(sb->s_type->name, "cgroup") ||

Should we also include "cgroup2" here, since they are defined as 2 distinct filesystems? https://github.com/SELinuxProject/selinux-kernel/
blob/master/kernel/cgroup.c#L2314-L2326

likely yes

Quoted 15 lines
Quoted 8 lines
security/selinux/hooks.c +0 -1
              !strcmp(sb->s_type->name, "pstore") ||
              !strcmp(sb->s_type->name, "debugfs") ||
              !strcmp(sb->s_type->name, "tracefs") ||
--

2.9.3

Quoted 5 lines

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected] To get help, send an email containing "help" to

[email protected]

Signature · 4 lines
Antonio (runcom) Murdaca, RHCE
Senior Software Engineer - Containers
09B9 8F09 3E2D C310 E250 69B5 B2BE AD15 0DE9 36B9
<https://pgp.mit.edu/pks/lookup?op=get&search=0xB2BEAD150DE936B9>

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]
To get help, send an email containing "help" to [email protected]

#4 lore raw
In reply to Gary Tierney
Quoted 13 lines · Gary Tierney
Quoted 12 lines · Antonio Murdaca

This patch allows changing labels for cgroup mounts. Previously, running chcon on cgroupfs would throw an "Operation not supported". This patch specifically whitelist cgroupfs.

The patch could also allow containers to write only to the systemd cgroup for instance, while the other cgroups are kept with cgroup_t label.

---
 security/selinux/hooks.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 12 lines

security/selinux/hooks.c static int selinux_is_sblabel_mnt(struct super_block *sb) · line 483

Quoted 9 lines
security/selinux/hooks.c +1 -0
index 3b955c6..4e84211 100644
@@ -480,6 +480,7 @@ static int selinux_is_sblabel_mnt(struct super_block *sb)
              sbsec->behavior == SECURITY_FS_USE_NATIVE ||
              /* Special handling. Genfs but also in-core setxattr handler */
              !strcmp(sb->s_type->name, "sysfs") ||
+             !strcmp(sb->s_type->name, "cgroup") ||

Should we also include "cgroup2" here, since they are defined as 2
distinct filesystems? https://github.com/SELinuxProject/selinux-kernel/blob/master/kernel/cgroup.c#L2314-L2326

likely yes

Quoted 12 lines
Quoted 12 lines
security/selinux/hooks.c +0 -1
              !strcmp(sb->s_type->name, "pstore") ||
              !strcmp(sb->s_type->name, "debugfs") ||
              !strcmp(sb->s_type->name, "tracefs") ||
--

2.9.3

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected]
To get help, send an email containing "help" to [email protected]

Signature · 3 lines
Antonio (runcom) Murdaca, RHCE
Senior Software Engineer - Containers
09B9 8F09 3E2D C310 E250 69B5 B2BE AD15 0DE9 36B9