[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250520120000.25501-2-stephen.smalley.work@gmail.com>
Date: Tue, 20 May 2025 07:58:58 -0400
From: Stephen Smalley <stephen.smalley.work@...il.com>
To: selinux@...r.kernel.org
Cc: paul@...l-moore.com,
omosnace@...hat.com,
netdev@...r.kernel.org,
Stephen Smalley <stephen.smalley.work@...il.com>
Subject: [PATCH v3 00/42] SELinux namespace support
This series introduces support for SELinux namespaces, i.e. the ability to
create multiple SELinux namespaces each with its own policy, AVC, and
enforcing mode. This support can be leveraged by Linux container runtimes
to establish a private SELinux namespace for each container, enabling the
container to load and enforce its own policy while still remaining bound by
the host OS policy (if any). Documentation and open issues can be found at
https://github.com/stephensmalley/selinuxns.
Performance data:
Baseline = v6.15-rc1+selinux/dev@...1a939225ec8
No NS = this patch series with SECURITY_SELINUX_NS=n
Init NS = Same but with SECURITY_SELINUX_NS=y from init SELinux namespace
Child NS = Same but from a child SELinux namespace
kcbench (automated kernel compilation benchmark packaged by Fedora, run
with -s 6.13 for 10 runs, computing average and standard deviation):
|CPUs|Baseline (sec)|StdDev|No NS (sec)|Init NS (sec)|Child NS (sec)|
| 16 | 122.56 | 0.68 | 122.94 | 122.86 | 122.76 |
| 19 | 123.61 | 0.34 | 124.11 | 124.15 | 123.65 |
perf record make –jN on fully built allmodconfig kernel tree as per
Linus' description:
|Function |Baseline|NoNS |InitNS|ChildNS|
| __d_lookup_rcu | 1.68% | 1.79%| 1.63%| 1.69% |
| selinux_inode_permission | 0.59% | 0.53%| 0.46%| 0.47% |
| selinux_inode_getattr | 0.37% | 0.42%| 0.39%| 0.40% |
| avc_lookup | 0.20% | 0.09%| 0.11%| 0.22% |
| avc_has_perm/_noaudit | 0.10% | 0.04%| 0.04%| 0.09% |
| avc_policy_seqno | 0.02% | 0.15%| 0.14%| 0.14% |
| cred_tsid_has_perm | N/A | 0.07%| 0.06%| 0.11% |
| Total SELinux | 1.28% | 1.30%| 1.20%| 1.43% |
| SELinux/d_lookup_rcu | 0.762 | 0.726| 0.736| 0.846 |
ApacheBench, packaged by Fedora, run ten times computing average and stddev:
ab –n 100000 –c 1000 http://localhost/
|Metric |Baseline|StdDev|No NS |Init NS |Child NS|
|Time taken (sec) | 7.7115| 0.805| 7.3128| 7.5505| 7.6774 |
|Reqs / sec | 13112.2|1394.9|13731.8| 13443.5| 13155 |
|Time per req (ms) | 77.1154|8.0497|73.1283| 75.505|76.7726 |
|Transfer rate (KB/sec) | 112069| 11922| 117364| 114900| 112434 |
|Connect time median (ms)| 30.4| 5.95| 28.5| 28.2| 31.3 |
|Total time median (ms) | 75.5| 11.5| 69.0| 70.4| 73.7 |
Stephen Smalley (42):
selinux: restore passing of selinux_state
selinux: introduce current_selinux_state
selinux: support multiple selinuxfs instances
selinux: dynamically allocate selinux namespace
netstate,selinux: create the selinux netlink socket per network
namespace
selinux: limit selinux netlink notifications to init namespace
selinux: support per-task/cred selinux namespace
selinux: introduce cred_selinux_state() and use it
selinux: add a selinuxfs interface to unshare selinux namespace
selinux: add limits for SELinux namespaces
selinux: exempt creation of init SELinux namespace from limits
selinux: refactor selinux_state_create()
selinux: allow userspace to detect non-init SELinux namespace
selinuxfs: restrict write operations to the same selinux namespace
selinux: introduce a global SID table
selinux: wrap security server interfaces to use the global SID table
selinux: introduce a Kconfig option for SELinux namespaces
selinux: eliminate global SID table if !CONFIG_SECURITY_SELINUX_NS
selinux: maintain a small cache in the global SID table
selinux: update hook functions to use correct selinux namespace
selinux: introduce cred_task_has_perm()
selinux: introduce cred_has_extended_perms()
selinux: introduce cred_self_has_perm()
selinux: introduce cred_has_perm()
selinux: introduce cred_ssid_has_perm() and cred_other_has_perm()
selinux: introduce task_obj_perm()
selinux: update bprm hooks for selinux namespaces
selinux: add kerneldoc to new permission checking functions
selinux: convert selinux_file_send_sigiotask() to namespace-aware
helper
selinux: rename cred_has_perm*() to cred_tsid_has_perm*()
selinux: update cred_tsid_has_perm_noaudit() to return the combined
avd
selinux: convert additional checks to cred_ssid_has_perm()
selinux: introduce selinux_state_has_perm()
selinux: annotate selinuxfs permission checks
selinux: annotate process transition permission checks
selinux: convert xfrm and netlabel permission checks
selinux: switch selinux_lsm_setattr() checks to current namespace
selinux: make open_perms namespace-aware
selinux: split cred_ssid_has_perm() into two cases
selinux: disallow writes to /sys/fs/selinux/user in non-init
namespaces
selinux: convert nlmsg_sock_has_extended_perms() to namespace-aware
selinux: init inode from nearest initialized namespace
include/net/net_namespace.h | 3 +
security/selinux/Kconfig | 65 +
security/selinux/Makefile | 1 +
security/selinux/avc.c | 782 ++++++++--
security/selinux/global_sidtab.c | 810 ++++++++++
security/selinux/hooks.c | 1339 +++++++++++------
security/selinux/ibpkey.c | 2 +-
security/selinux/ima.c | 37 +-
security/selinux/include/audit.h | 8 +
security/selinux/include/avc.h | 76 +-
security/selinux/include/avc_ss.h | 3 +-
security/selinux/{ss => include}/avtab.h | 0
security/selinux/include/classmap.h | 2 +-
security/selinux/include/conditional.h | 4 +-
security/selinux/{ss => include}/constraint.h | 0
security/selinux/{ss => include}/context.h | 0
security/selinux/{ss => include}/ebitmap.h | 0
security/selinux/include/global_sidtab.h | 26 +
security/selinux/{ss => include}/hashtab.h | 0
security/selinux/include/ima.h | 11 +-
security/selinux/{ss => include}/mls.h | 0
security/selinux/{ss => include}/mls_types.h | 0
security/selinux/include/netif.h | 4 +-
security/selinux/include/netlabel.h | 14 +-
security/selinux/include/netnode.h | 4 +-
security/selinux/include/objsec.h | 43 +-
security/selinux/{ss => include}/policydb.h | 0
security/selinux/include/security.h | 473 +++++-
security/selinux/include/selinux_ss.h | 119 ++
security/selinux/{ss => include}/sidtab.h | 34 +
security/selinux/{ss => include}/symtab.h | 0
security/selinux/include/xfrm.h | 8 +-
security/selinux/netif.c | 31 +-
security/selinux/netlabel.c | 32 +-
security/selinux/netlink.c | 42 +-
security/selinux/netnode.c | 26 +-
security/selinux/netport.c | 2 +-
security/selinux/selinuxfs.c | 551 ++++++-
security/selinux/ss/services.c | 453 +++---
security/selinux/ss/services.h | 1 +
security/selinux/ss/sidtab.c | 105 +-
security/selinux/status.c | 44 +-
security/selinux/xfrm.c | 47 +-
43 files changed, 4070 insertions(+), 1132 deletions(-)
create mode 100644 security/selinux/global_sidtab.c
rename security/selinux/{ss => include}/avtab.h (100%)
rename security/selinux/{ss => include}/constraint.h (100%)
rename security/selinux/{ss => include}/context.h (100%)
rename security/selinux/{ss => include}/ebitmap.h (100%)
create mode 100644 security/selinux/include/global_sidtab.h
rename security/selinux/{ss => include}/hashtab.h (100%)
rename security/selinux/{ss => include}/mls.h (100%)
rename security/selinux/{ss => include}/mls_types.h (100%)
rename security/selinux/{ss => include}/policydb.h (100%)
create mode 100644 security/selinux/include/selinux_ss.h
rename security/selinux/{ss => include}/sidtab.h (81%)
rename security/selinux/{ss => include}/symtab.h (100%)
--
2.49.0
Powered by blists - more mailing lists