All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 00/44] SELinux namespace support
@ 2025-01-02 16:44 Stephen Smalley
  2025-01-02 16:44 ` [RFC PATCH 01/44] selinux: restore passing of selinux_state Stephen Smalley
                   ` (44 more replies)
  0 siblings, 45 replies; 52+ messages in thread
From: Stephen Smalley @ 2025-01-02 16:44 UTC (permalink / raw)
  To: selinux; +Cc: paul, omosnace, Stephen Smalley

This is an RFC-only for the SELinux namespace support, just to
encourage early review and identification of any show-stoppers
with respect to the design and implementation to date.
Patches 0001 through 0009 are just re-based versions of the original
SELinux namespace series that predated COVID. The remaining patches
are all new relative to mid-2024 when work on the namespace
support restarted.

If you actually want to try running it, I'd recommend instead using
my branch which has an additional cherry-picked fix from upstream
needed to avoid crashing the kernel. This can be cloned via
    git clone -b working-selinuxns \
	https://github.com/stephensmalley/selinux-kernel

Configure the kernel as usual but add CONFIG_SECURITY_SELINUX_NS=y
to enable the support. More detailed instructions on building, booting,
and testing the SELinux namespace support available upon request. I
have been running the SELinux testsuite and booting Fedora,
Rocky 9, and Rocky 8 containers with SELinux enforcing within
the container on a Fedora SELinux-enforcing host OS, a Fedora
SELinux-disabled (no policy) host, and an Ubuntu SELinux-disabled
(no policy) host.

Known remaining issues include:
- Per-namespace checking of all relevant policy capabilities (currently
  done for the open_perms capability),
- Proper handling of peer/packet labels when they cross SELinux namespaces,
- Optimizing the implementation for the single SELinux namespace case,
- Review, and if desired, change the kernel interface for unsharing the
  SELinux namespace (currently via /sys/fs/selinux/unshare with a
  libselinux wrapper),
- Namespace-aware context mount options for sVirt-like setups,
- Namespace support for certain residual networking hooks that lack it
- Anything else noted in the patches themselves.

It is an open question as to whether some or all of the changes could
be merged before all of the above issues are resolved, given that
the support is only exposed to userspace if CONFIG_SECURITY_SELINUX_NS=y
and even then only to privileged userspace. I think at a minimum we
would likely need to optimize the implementation for the single SELinux
namespace case so that it does not introduce any significant overhead
prior to merging, or extend CONFIG_SECURITY_SELINUX_NS to actually
compile away the extra storage and runtime overheads introduced by
the infrastructure. Open to suggestions.

Stephen Smalley (44):
  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: support per-task/cred selinux namespace
  selinux: introduce cred_selinux_state() and use it
  selinux: add a selinuxfs interface to unshare 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: 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: fix selinux_lsm_getattr() check
  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: 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: add limits for SELinux namespaces
  selinux: fix namespace creation
  selinux: limit selinux netlink notifications to init namespace
  selinux: refactor selinux_state_create()
  selinux: make open_perms namespace-aware
  selinux: split cred_ssid_has_perm() into two cases
  selinux: set initial SID context for init to "kernel" in global SID
    table
  selinux: disallow writes to /sys/fs/selinux/user in non-init
    namespaces
  selinux: convert nlmsg_sock_has_extended_perms() to namespace-aware
  selinux: defer inode init on current selinux state
  selinux: init inode from nearest initialized namespace
  selinux: allow userspace to detect non-init SELinux namespace
  selinux: exempt creation of init SELinux namespace from limits
  selinux: introduce a Kconfig option for SELinux namespaces
  selinux: fix inode initialization when no namespace is initialized

 include/net/net_namespace.h                   |    3 +
 security/selinux/Kconfig                      |   54 +
 security/selinux/Makefile                     |    2 +-
 security/selinux/avc.c                        |  743 ++++++++--
 security/selinux/global_sidtab.c              |  758 ++++++++++
 security/selinux/hooks.c                      | 1309 ++++++++++-------
 security/selinux/ibpkey.c                     |    2 +-
 security/selinux/ima.c                        |   37 +-
 security/selinux/include/avc.h                |   78 +-
 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      |   22 +
 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             |   29 +-
 security/selinux/{ss => include}/policydb.h   |    0
 security/selinux/include/security.h           |  249 ++--
 security/selinux/include/selinux_ss.h         |  115 ++
 security/selinux/{ss => include}/sidtab.h     |    5 +
 security/selinux/{ss => include}/symtab.h     |    0
 security/selinux/include/xfrm.h               |    4 +-
 security/selinux/netif.c                      |   31 +-
 security/selinux/netlabel.c                   |   32 +-
 security/selinux/netlink.c                    |   42 +-
 security/selinux/netnode.c                    |   25 +-
 security/selinux/netport.c                    |    2 +-
 security/selinux/selinuxfs.c                  |  548 +++++--
 security/selinux/ss/services.c                |  421 +++---
 security/selinux/ss/services.h                |    1 +
 security/selinux/ss/sidtab.c                  |   14 +-
 security/selinux/status.c                     |   44 +-
 security/selinux/xfrm.c                       |   47 +-
 42 files changed, 3570 insertions(+), 1089 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 (95%)
 rename security/selinux/{ss => include}/symtab.h (100%)

-- 
2.47.1


^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2025-02-07 19:56 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-02 16:44 [RFC PATCH 00/44] SELinux namespace support Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 01/44] selinux: restore passing of selinux_state Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 02/44] selinux: introduce current_selinux_state Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 03/44] selinux: support multiple selinuxfs instances Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 04/44] selinux: dynamically allocate selinux namespace Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 05/44] netstate,selinux: create the selinux netlink socket per network namespace Stephen Smalley
2025-01-27  3:30   ` sergeh
2025-01-27 15:00     ` Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 06/44] selinux: support per-task/cred selinux namespace Stephen Smalley
2025-01-27  3:41   ` sergeh
2025-01-27 15:07     ` Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 07/44] selinux: introduce cred_selinux_state() and use it Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 08/44] selinux: add a selinuxfs interface to unshare selinux namespace Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 09/44] selinuxfs: restrict write operations to the same " Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 10/44] selinux: introduce a global SID table Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 11/44] selinux: wrap security server interfaces to use the " Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 12/44] selinux: update hook functions to use correct selinux namespace Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 13/44] selinux: introduce cred_task_has_perm() Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 14/44] selinux: introduce cred_has_extended_perms() Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 15/44] selinux: introduce cred_self_has_perm() Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 16/44] selinux: introduce cred_has_perm() Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 17/44] selinux: introduce cred_ssid_has_perm() and cred_other_has_perm() Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 18/44] selinux: introduce task_obj_perm() Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 19/44] selinux: fix selinux_lsm_getattr() check Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 20/44] selinux: update bprm hooks for selinux namespaces Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 21/44] selinux: add kerneldoc to new permission checking functions Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 22/44] selinux: convert selinux_file_send_sigiotask() to namespace-aware helper Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 23/44] selinux: rename cred_has_perm*() to cred_tsid_has_perm*() Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 24/44] selinux: convert additional checks to cred_ssid_has_perm() Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 25/44] selinux: introduce selinux_state_has_perm() Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 26/44] selinux: annotate selinuxfs permission checks Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 27/44] selinux: annotate process transition " Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 28/44] selinux: convert xfrm and netlabel " Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 29/44] selinux: switch selinux_lsm_setattr() checks to current namespace Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 30/44] selinux: add limits for SELinux namespaces Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 31/44] selinux: fix namespace creation Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 32/44] selinux: limit selinux netlink notifications to init namespace Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 33/44] selinux: refactor selinux_state_create() Stephen Smalley
2025-01-02 16:44 ` [RFC PATCH 34/44] selinux: make open_perms namespace-aware Stephen Smalley
2025-01-02 16:45 ` [RFC PATCH 35/44] selinux: split cred_ssid_has_perm() into two cases Stephen Smalley
2025-01-02 16:45 ` [RFC PATCH 36/44] selinux: set initial SID context for init to "kernel" in global SID table Stephen Smalley
2025-01-02 16:45 ` [RFC PATCH 37/44] selinux: disallow writes to /sys/fs/selinux/user in non-init namespaces Stephen Smalley
2025-01-02 16:45 ` [RFC PATCH 38/44] selinux: convert nlmsg_sock_has_extended_perms() to namespace-aware Stephen Smalley
2025-01-02 16:45 ` [RFC PATCH 39/44] selinux: defer inode init on current selinux state Stephen Smalley
2025-01-02 16:45 ` [RFC PATCH 40/44] selinux: init inode from nearest initialized namespace Stephen Smalley
2025-01-02 16:45 ` [RFC PATCH 41/44] selinux: allow userspace to detect non-init SELinux namespace Stephen Smalley
2025-01-02 16:45 ` [RFC PATCH 42/44] selinux: exempt creation of init SELinux namespace from limits Stephen Smalley
2025-01-02 16:45 ` [RFC PATCH 43/44] selinux: introduce a Kconfig option for SELinux namespaces Stephen Smalley
2025-01-02 16:45 ` [RFC PATCH 44/44] selinux: fix inode initialization when no namespace is initialized Stephen Smalley
2025-01-07 18:31   ` Stephen Smalley
2025-02-07 18:07 ` [RFC PATCH 00/44] SELinux namespace support Stephen Smalley
2025-02-07 19:56   ` Paul Moore

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.