Skip to contentSkip to conversation

security: selinux: allow per-file labeling for bpffs

PATCH Superseded Steven Moreland 2 participants 2 messages Feb 6, 2020 – Feb 7, 2020 SELinux security module

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 security: selinux: allow per-file labeling for bpffs

From: Connor O'Brien <[email protected]>

Add support for genfscon per-file labeling of bpffs files. This allows for separate permissions for different pinned bpf objects, which may be completely unrelated to each other.

---
 security/selinux/hooks.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
security/selinux/hooks.c +2 -1
index 116b4d644f68..d7b11188dc8d 100644
@@ -750,7 +750,8 @@ 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") ||
+	if (!strcmp(sb->s_type->name, "bpf") ||
+	    !strcmp(sb->s_type->name, "debugfs") ||
 	    !strcmp(sb->s_type->name, "tracefs") ||
 	    !strcmp(sb->s_type->name, "pstore"))
 		sbsec->flags |= SE_SBGENFS;
Signature · 5 lines
2.25.0.341.g760bfbb309-goog

v1 -> v2
- Rebased to be on upstream selinux tree
- Removed Android specific 'Change-Id'
#1 lore raw
Quoted 8 lines · Steven Moreland

From: Connor O'Brien <[email protected]>

Add support for genfscon per-file labeling of bpffs files. This allows for separate permissions for different pinned bpf objects, which may be completely unrelated to each other.

Is this relative to the next branch of the selinux git tree? Doesn't apply for me.

Quoted 19 lines
---
  security/selinux/hooks.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
security/selinux/hooks.c +2 -1
index 116b4d644f68..d7b11188dc8d 100644
@@ -750,7 +750,8 @@ 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") ||
+	if (!strcmp(sb->s_type->name, "bpf") ||
+	    !strcmp(sb->s_type->name, "debugfs") ||
  	    !strcmp(sb->s_type->name, "tracefs") ||
  	    !strcmp(sb->s_type->name, "pstore"))
  		sbsec->flags |= SE_SBGENFS;