Start here
Single-page view · as markdown
Overview
Peios Kernel / Internals / KACS / Start here
The Kernel Access Control Subsystem is the security core of Peios: an LSM within PKM providing identity-based access control in the Linux kernel. It is the sole identity-based authorization mechanism for managed objects. Every identity-based decision — a file open, a registry read, an IPC connection, a signal, a token operation — passes through one evaluation function, AccessCheck.
This chapter covers tokens (The Token Model), the Process Security Block (The PSB Model), privileges (The Privilege Model), impersonation (Impersonation Levels), binary signature verification (Binary Signature Verification), Process Integrity Protection (Process Integrity Protection), the AccessCheck algorithm in full (AccessCheck Overview), file enforcement (The Handle Model), and how Peios identity is projected onto the Linux credential model (Credential Projection).
The kernel-private storage and call-site inventory is in LSM integration: the LSM security blobs, every registered KACS hook, and the direct metadata entry points used by patched file-descriptor operations.
Two bodies of material that KACS owns conceptually live elsewhere in the documentation. The binary structures — SIDs, security descriptors, ACLs, ACEs, access masks, conditional ACE bytecode — are specified in PCDS, because userspace tooling constructs and interprets them and has to agree with the kernel byte for byte. The signing format a third party would use to sign a binary with a PIP level is specified in PSPK; this chapter describes only the verification side. What remains here is the kernel's own behaviour: how it holds identity, and how it decides.
Terminology #
A token is a per-thread identity object held in the kernel's credential structure, carrying a user SID, group SIDs, a privilege bitmask, an integrity level, an impersonation level, and metadata. Identity fields — SIDs, type, integrity level — are immutable; policy fields — enabled privileges, enabled groups, default owner, group and DACL — are atomically adjustable. Every thread has a token, and there is no such thing as a null token.
A primary token defines a process's baseline identity and is
inherited on fork, reached through task->real_cred. An
impersonation token temporarily overrides it for access decisions
on one thread only, reached through task->cred.
A LogonSession is a kernel object representing one authentication event: a session ID, a logon type, a user SID, an authentication package, a logon time, and a logon SID. Tokens reference their session by ID.
A privilege is a system-wide right carried on a token. Some influence AccessCheck; others gate a standalone operation.
An impersonation level controls how far an identity can travel: Anonymous, Identification, Impersonation, or Delegation. It is a ratchet carried by every token, primary or impersonation, and only ever goes down (Impersonation Levels).
An integrity level is a vertical trust classification on tokens
and objects. Numerically it is the mandatory label SID's single
sub-authority compared as an unsigned integer, so any S-1-16-<n>
with exactly one sub-authority is valid. In practice five standard
levels form a strict total order — Untrusted (0), Low (4096), Medium
(8192), High (12288), System (16384) — and non-standard values such as
S-1-16-8448 appear only in SDs authored for Windows interop.
Mandatory Integrity Control is the constraint evaluated before the
DACL, blocking write access, and optionally read and execute, when the
caller's level is below the object's label.
Process Integrity Protection is a two-dimensional trust model — type against trust level — protecting processes and objects from insufficiently trusted callers. Unlike MIC, it revokes rights that a privilege would otherwise have granted.
The Process Security Block is a per-process structure carrying PIP identity, process mitigations, and process restrictions. It is never affected by impersonation, which is the point of keeping it separate from the token.
FACS, the File Access Control Shim, is the part of KACS that replaces Linux DAC with security-descriptor evaluation on files. It enforces the handle model: AccessCheck runs at open time and the granted mask is cached on the file description, with later operations checked against the cached mask.
An object type is the category of a protected resource. Each defines a GenericMapping table translating generic rights into object-specific ones.
The TCB — the components whose correct behaviour is necessary for system security — is the Linux kernel, PKM, and the core trusted userspace daemons: peinit, authd, and loregd.
Relationship to MS-DTYP #
KACS is not a port of another system's security model. Tokens, security descriptors, AccessCheck, structured SIDs, and per-thread impersonation were chosen because they solve what Peios needs solved: coherent identity, rich per-object access control, scoped delegation, and integrated audit.
Those same primitives are the ones Active Directory uses, and Peios is built to join AD domains as a first-class member — exchanging security data with domain controllers, authenticating through Kerberos, and enforcing policy distributed by Group Policy. That imposes binary format compatibility, which PCDS specifies: an SD written by a Windows domain controller and replicated through Samba is evaluated by KACS without translation.
Format compatibility does not imply evaluator compatibility in every corner. Given the same token, descriptor, and desired mask, KACS generally reaches the same decision MS-DTYP describes, which is what makes policy authored in an AD environment behave predictably here. Where it deliberately does not, Departures from MS-DTYP records every departure and why.
Build configuration #
CONFIG_SECURITY_PKM=y and CONFIG_RUST=y are required, as are
CONFIG_STRICT_DEVMEM=y and CONFIG_MODULE_SIG_FORCE=y. The last two,
and the absence of every other MAC LSM and of CONFIG_BPF_LSM, are
enforced at build time by BUILD_BUG_ON in pkm_init (Process Integrity Protection): a kernel
configured without them does not compile. They were once checked at
initialisation instead, which is no refusal at all -- the LSM framework
answers a failed init with a warning and boots with the hooks
uninstalled, the opposite of what the gate intends (PEI-487).
CONFIG_SECURITY_SELINUX, _APPARMOR, _SMACK and _TOMOYO are
additionally refused by Kconfig dependency. CONFIG_LSM is never
parsed.
Two further symbols gate large bodies of code:
CONFIG_SECURITY_PKM_KUNIT, which compiles in the test harness and, in the signing path, a different and publicly known verification key (Binary Signature Verification).CONFIG_STRATAFS_FS, without which the copy-up API of The StrataFS Copy-Up Context is inert.
Related explanations #
- ABI status and naming differences
- Descriptor and ACE semantics
- Token query semantics
- Socket ABI compatibility
Calling the subsystem #
The native KACS interface reference collects the caller contracts and generated ABI tables.
Topics #
Boot and trust invariants
Peios Kernel / Internals / KACS / Start here
KACS depends on a kernel configuration that protects the kernel trust boundary
and installs its enforcement hooks. The supported build records that
configuration in peios/config/pkm.fragment and checks it with
peios/verify-config.sh. Kconfig and compile-time assertions impose additional
constraints. These mechanisms have different failure behaviour; a build
requirement is not an init-time check.
The LSM stack invariant #
PKM implements KACS through the Linux Security Module framework and direct
integration points. The supported configuration uses
CONFIG_LSM="landlock,lockdown,integrity,pkm". Capability hooks are implicit in
the framework. See LSM hooks and object state
for the registered hooks and direct callers.
What the kernel verifies #
security/pkm/Kconfig requires security support, Rust, a 64-bit target,
STRICT_DEVMEM and MODULE_SIG_FORCE. It excludes SELinux, AppArmor, SMACK and
TOMOYO. In security/pkm/kacs/lsm.c, pkm_init() also has BUILD_BUG_ON
checks for those MAC LSMs, the BPF LSM, and the two hardening prerequisites.
An incompatible configuration fails to build; it is not a supported path
where the kernel boots and PKM merely declines to activate.
The required stack #
The supported build disables the conflicting MAC LSMs, BPF LSM and Yama and checks the exact LSM list. Yama's ptrace policy would introduce an independent attach decision ahead of KACS. Landlock, lockdown and integrity remain in the configured stack; their presence does not turn KACS into the authority for every Linux check. Native process and object policy must be understood alongside the particular interface's remaining checks.
Module signing #
CONFIG_MODULE_SIG_FORCE=y is a PKM build prerequisite. Module loading also
has authorization checks, but possession of a loading privilege does not
waive signature verification. The signature establishes trust in executable
kernel code; it does not prove the module is free of defects.
The authoritative operational explanation is Module signing, including Peios's supported signing mechanism and load failures. Kernel module signatures and executable PIP signatures must not be treated as an interchangeable format or key-selection mechanism.
The module-loading helper #
Kernel-initiated userspace helpers are subject to KACS executable verification and the helper integrity floor. That is separate from verification of the module subsequently requested by a helper. The executable must meet the helper rule, and the module must independently meet module-loading policy. See process integrity protection (Process Integrity Protection) and executable verification (Binary Signature Verification).
Memory access restrictions #
CONFIG_STRICT_DEVMEM=y is a build prerequisite and limits physical-memory
access according to the architecture's implementation. It must not be
described as a universal list of accessible physical regions or as the sole
defence against process-isolation bypasses. KACS also gates relevant device
and physical-memory operations; see process integrity protection (Process Integrity Protection).
The status of /dev/kmem follows the supported kernel's interfaces and
configuration, rather than being implied by STRICT_DEVMEM alone. A native
descriptor grant does not waive another check performed by the device path.
What the kernel will not have #
The supported configuration excludes SELinux, AppArmor, SMACK, TOMOYO, BPF LSM and Yama. The first five are also covered by PKM compile-time assertions. Keep the distinction between configuration validation and compile-time enforcement when changing the supported build; do not infer a universal runtime rejection mechanism from the configuration file.
What about user-space hardening #
Service signing and deployment policy are additional requirements. The kernel derives executable integrity from the verified executable and applies the rules for the particular exec path. A service being intended as part of the trusted computing base does not itself assign a PIP tier.
Kernel integrity requirements do not establish that a complete image has the right service binaries, signatures, descriptors or startup ordering. Those are properties of the assembled deployment and must be checked there.
The invariant verification #
Use the supported build entry points described in
Building Peios; they apply
and validate the Peios configuration. During PKM initialization,
pkm_init() initializes the Rust state, creates bootstrap tokens, constructs
the initial process security state and installs the hooks on success.
Allocation and initialization errors are separate from rejected build
configurations and are not evidence that all boot failures are fail-stop.
The initial userspace program is selected by the boot and init configuration. The kernel's bootstrap tokens do not by themselves specify the full prelude/peinit deployment sequence.
Failure modes #
A rejected configuration should fail the build or its verification step. A runtime initialization failure must be diagnosed from the actual init return path and kernel messages. Do not assume that an ordinary LSM init error necessarily halts the Linux boot process.
Disabling enforcement prerequisites or changing the LSM stack creates a different kernel configuration and requires a fresh review of its security properties. A successful boot alone does not establish that the intended policy is active. The supported configuration checker and the runtime LSM list exposed by securityfs provide distinct evidence.
Why these invariants #
Native access control assumes that kernel code and data retain their integrity. Restrictions on loading executable kernel code and accessing physical memory help protect that boundary. The LSM configuration ensures that the supported build includes the intended enforcement components.
These are necessary conditions for the intended system, not a proof that there are no kernel defects or other authority paths. Interface-specific checks and deployment validation remain relevant.
Where to go next #
Read Peios kernel behaviour for the Linux compatibility boundaries, KACS process integrity (Process Integrity Protection) for runtime protection, and Building Peios for configuration and build validation.