# Start here

---

# Overview

_Peios Kernel / Internals / KACS / Start here_

> KACS is the security core of Peios — an LSM inside PKM providing identity-based access control — and how it relates to MS-DTYP.

<a id="trm-3-1"></a>

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](</kernel/internals/kacs/tokens/the-token-model.md#trm-3-2-1>)), the Process Security Block ([The PSB Model](</kernel/internals/kacs/process-security/state-and-lifetime.md#trm-3-3-1>)),
privileges ([The Privilege Model](</kernel/internals/kacs/privileges/the-privilege-model.md#trm-3-4-1>)), impersonation ([Impersonation Levels](</kernel/internals/kacs/impersonation/levels-and-admission.md#trm-3-5-1>)), binary signature verification
([Binary Signature Verification](</kernel/internals/kacs/executable-trust/signature-verification.md#trm-3-6>)), Process Integrity Protection ([Process Integrity Protection](</kernel/internals/kacs/executable-trust/process-integrity-protection.md#trm-3-7>)), the AccessCheck algorithm
in full ([AccessCheck Overview](</kernel/internals/kacs/access-check/accesscheck-overview.md#trm-3-8-1>)), file enforcement ([The Handle Model](</kernel/internals/kacs/file-security/the-handle-model.md#trm-3-9-1>)), and how Peios identity is
projected onto the Linux credential model ([Credential Projection](</kernel/internals/security/credentials.md#trm-3-10-1>)).

The kernel-private storage and call-site inventory is in [LSM integration](</kernel/internals/kacs/integration/lsm-hooks-and-object-state.md#trm-3-e>): 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.

<a id="trm-3-1-1"></a>

## 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](</kernel/internals/kacs/impersonation/levels-and-admission.md#trm-3-5-1>)).

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.

<a id="trm-3-1-2"></a>

## 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](</kernel/userspace/native/kacs/ms-dtyp-compatibility-and-divergences.md#trm-3-b>) records every departure and why.

<a id="trm-3-d-8"></a>

## 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](</kernel/internals/kacs/executable-trust/process-integrity-protection.md#trm-3-7>)): 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). <a id="cite-abi-notes.build.configs-enforced-at-build"></a>
`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](</kernel/internals/kacs/executable-trust/signature-verification.md#trm-3-6>)). <a id="cite-abi-notes.build.kunit-test-key"></a>
- `CONFIG_STRATAFS_FS`, without which the copy-up API of [The StrataFS Copy-Up Context](</kernel/internals/stratafs/security/kacs-admission-and-object-phases.md#trm-3-9-7>) is
  inert. <a id="cite-abi-notes.build.stratafs-gates-copy-up"></a>

## Related explanations

- [ABI status and naming differences](</kernel/userspace/native/kacs/abi-status-and-naming-differences.md>)
- [Descriptor and ACE semantics](</kernel/userspace/native/kacs/descriptor-and-ace-semantics.md>)
- [Token query semantics](</kernel/userspace/native/kacs/token-query-semantics.md>)
- [Socket ABI compatibility](</kernel/userspace/native/kacs/socket-abi-compatibility.md>)

## Calling the subsystem

The [native KACS interface reference](</kernel/userspace/native/kacs/overview.md>) collects the caller contracts and generated ABI tables.

## Topics

- [Tokens](</kernel/internals/kacs/tokens/overview.md>)
- [Process security](</kernel/internals/kacs/process-security/overview.md>)
- [Privileges](</kernel/internals/kacs/privileges/overview.md>)
- [Impersonation](</kernel/internals/kacs/impersonation/overview.md>)
- [Executable trust](</kernel/internals/kacs/executable-trust/overview.md>)
- [Access check](</kernel/internals/kacs/access-check/overview.md>)
- [File security](</kernel/internals/kacs/file-security/overview.md>)
- [Linux credentials](</kernel/internals/kacs/linux-credentials/overview.md>)
- [System V IPC](</kernel/internals/kacs/system-v-ipc/overview.md>)
- [Network objects](</kernel/internals/kacs/network-objects/overview.md>)
- [Mount namespaces](</kernel/internals/kacs/mount-namespaces/overview.md>)
- [Auditing](</kernel/internals/kacs/auditing/overview.md>)
- [Integration](</kernel/internals/kacs/integration/overview.md>)

---

# Boot and trust invariants

_Peios Kernel / Internals / KACS / Start here_

> Boot and trust invariants: behaviour and implementation of the Peios kernel.

<a id="trm-1-2"></a>

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.

<a id="trm-1-2-1"></a>

## 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](</kernel/internals/kacs/integration/lsm-hooks-and-object-state.md>)
for the registered hooks and direct callers.

<a id="trm-1-2-1-1"></a>

### 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.

<a id="trm-1-2-1-2"></a>

### 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.

<a id="trm-1-2-2"></a>

## 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](</kernel/administration/admin-guide/boot/module-signing.md>),
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.

<a id="trm-1-2-3"></a>

## 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](</kernel/internals/kacs/executable-trust/process-integrity-protection.md#trm-3-7>)) and executable verification ([Binary Signature Verification](</kernel/internals/kacs/executable-trust/signature-verification.md#trm-3-6>)).

<a id="trm-1-2-4"></a>

## 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](</kernel/internals/kacs/executable-trust/process-integrity-protection.md#trm-3-7>)).

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.

<a id="trm-1-2-5"></a>

## 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.

<a id="trm-1-2-6"></a>

## 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.

<a id="trm-1-2-7"></a>

## The invariant verification

Use the supported build entry points described in
[Building Peios](</kernel/development/start-here/building-peios.md>); 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.

<a id="trm-1-2-8"></a>

## 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.

<a id="trm-1-2-9"></a>

## 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.

<a id="trm-1-2-10"></a>

## Where to go next

Read [Peios kernel behaviour](</kernel/introduction/peios-behaviour.md>) for the
Linux compatibility boundaries, KACS process integrity ([Process Integrity Protection](</kernel/internals/kacs/executable-trust/process-integrity-protection.md#trm-3-7>)) for runtime
protection, and [Building Peios](</kernel/development/start-here/building-peios.md>)
for configuration and build validation.
