selinux: enable per-file labeling for functionfs
authorNeill Kapron <nkapron@google.com>
Thu, 28 Aug 2025 17:03:15 +0000 (17:03 +0000)
committerPaul Moore <paul@paul-moore.com>
Sun, 7 Sep 2025 16:54:56 +0000 (12:54 -0400)
commit68e1e908cb7682db9fb7f79907f9352435a81c0f
tree17613d161517fe475086cd1c0dedea5eba4b620d
parent59ffc9beeb8b332940d36f4b9803352b7f893f5a
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().

This patch introduces the functionfs_seclabel policycap to maintain
existing functionfs genfscon behavior unless explicitly enabled.

Signed-off-by: Neill Kapron <nkapron@google.com>
Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
[PM: trim changelog, apply boolean logic fixup]
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/hooks.c
security/selinux/include/policycap.h
security/selinux/include/policycap_names.h
security/selinux/include/security.h