[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250820212302.2325779-1-nkapron@google.com>
Date: Wed, 20 Aug 2025 21:23:01 +0000
From: Neill Kapron <nkapron@...gle.com>
To: Paul Moore <paul@...l-moore.com>, Stephen Smalley <stephen.smalley.work@...il.com>,
Ondrej Mosnacek <omosnace@...hat.com>
Cc: Neill Kapron <nkapron@...gle.com>, kernel-team@...roid.com, selinux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] selinux: enable per-file labeling for functionfs
This patch adds support for genfscon per-file labeling of functionfs
files as well as support for userspace to apply labels after new
functionfs endpoints are created.
This allows for separate labels and therefore access control on a
per-endpoint basis. An example use case would be for the default
endpoint EP0 used as a restricted control endpoint, and additional
usb endpoints to be used by other more permissive domains.
It should be noted that if there are multiple functionfs mounts on a
system, genfs file labels will apply to all mounts, and therefore will not
likely be as useful as the userspace relabeling portion of this patch -
the addition to selinux_is_genfs_special_handling().
Signed-off-by: Neill Kapron <nkapron@...gle.com>
---
security/selinux/hooks.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index e474cd7398ef..54b82c814b4d 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -474,6 +474,7 @@ static int selinux_is_genfs_special_handling(struct super_block *sb)
!strcmp(sb->s_type->name, "debugfs") ||
!strcmp(sb->s_type->name, "tracefs") ||
!strcmp(sb->s_type->name, "rootfs") ||
+ !strcmp(sb->s_type->name, "functionfs") ||
(selinux_policycap_cgroupseclabel() &&
(!strcmp(sb->s_type->name, "cgroup") ||
!strcmp(sb->s_type->name, "cgroup2")));
@@ -741,6 +742,7 @@ static int selinux_set_mnt_opts(struct super_block *sb,
!strcmp(sb->s_type->name, "binder") ||
!strcmp(sb->s_type->name, "bpf") ||
!strcmp(sb->s_type->name, "pstore") ||
+ !strcmp(sb->s_type->name, "functionfs") ||
!strcmp(sb->s_type->name, "securityfs"))
sbsec->flags |= SE_SBGENFS;
--
2.51.0.261.g7ce5a0a67e-goog
Powered by blists - more mailing lists