These docs are under active development and cover the v0.20 Kobicha security model.
§1.1 1 Introduction

Scope

This specification defines the Layered Configuration Subsystem (LCS) for the Peios operating system. LCS is the configuration subsystem within the Peios Kernel Module (PKM), peer to KACS. It provides a kernel-mediated, access-controlled, hierarchical configuration store modelled on the Windows registry.

LCS is the primary structured configuration authority in Peios. All registry operations -- opening keys, reading values, writing configuration, watching for changes -- pass through LCS syscalls. Userspace processes never communicate with backing stores directly.

This specification covers:

  • The data model -- hives, keys, values, layers, path entries, and their relationships
  • The syscall and ioctl interface exposed to userspace
  • The Registry Source Interface (RSI) -- the binary protocol and contract between LCS and its backing stores
  • The security model -- KACS AccessCheck integration, SD inheritance delegation, per-key access control, and registry-specific access rights
  • Watches -- persistent change observation with subtree semantics, event types, dispatch, and queue management
  • Transactions -- hive-scoped atomic multi-key writes
  • The layer system -- precedence-ordered configuration overlays with tombstones, key hiding, and layer resolution
  • The backup format -- binary stream format for bulk subtree export/import
  • LCS bootstrap behaviour -- compiled-in defaults, self-configuration, and hot-swap sequencing
  • Self-configuration -- operational parameters read from the registry with validated hot-swap
  • Failure modes -- source crash, request timeout, transaction timeout, data validation

This specification does not cover:

  • loregd internals (SQLite schema, storage engine, caching, connection management)
  • Specific registry key schemas (those belong to the subsystems that own them)
  • KACS (covered by the KACS v0.20 specification)
  • peinit boot decisions (first-boot detection, seed restore triggering, service start ordering)
  • authd, lpsd, eventd, or any other userspace daemon
  • Future GOQL query language
  • Network-level registry access or replication
§1.2 1 Introduction

Terminology

This section defines terms used throughout the specification. Terms defined inline in later sections (path entries, tombstones, the base layer, effective values, etc.) are not duplicated here.

  • PKM (Peios Kernel Module): The single loadable kernel module (pkm.ko) containing all Peios kernel extensions. LCS and KACS are peer subsystems within PKM.

  • KACS (Kernel-based Access Control System): The access control subsystem within PKM. Implements per-thread tokens, Security Descriptors, and AccessCheck. LCS depends on KACS for all access control decisions. KACS has no dependency on LCS. Specified separately in the KACS v0.20 specification.

  • LCS (Layered Configuration Subsystem): The configuration subsystem within PKM, peer to KACS. Implements the kernel-side registry: syscall dispatch, hive routing, access control enforcement (via KACS AccessCheck), layer resolution, watch dispatch, transaction coordination, and enforcement of the Registry Source Interface. Userspace processes interact with LCS exclusively through syscalls. "LCS" refers specifically to the kernel-side code.

  • Registry: The user-facing configuration system provided by LCS and its sources working together. When precision matters, use "LCS" for the kernel subsystem and the relevant source name (e.g., "loregd") for the userspace component. When the distinction does not matter, "the Registry" covers the whole thing.

  • Source: A userspace process that implements the Registry Source Interface (RSI) for one or more hives. Sources handle storage -- reads, writes, enumeration, transactions. They do not make access control decisions, see caller identity, manage watches, or interpret paths beyond the key hierarchy they store. A source registers its hives with the kernel at startup and communicates via the RSI binary protocol. loregd is the first source.

  • RSI (Registry Source Interface): The binary protocol and contract between LCS and its sources. Defines the operations LCS can request, the response format, and the error model. Any process implementing the RSI can back a hive -- LCS is source-agnostic.

  • Hive: A top-level namespace in the registry. Each hive is an independent tree of keys and values, backed by exactly one source. A source may back multiple hives. Hive names are the first component of every registry path and are resolved by LCS's routing table. Examples: Machine\, Users\.

  • Key: A node in the registry hierarchy. Keys are containers -- they hold subkeys (forming a tree) and values (holding data). Every key has a GUID (its identity), a Security Descriptor (controlling access), and metadata. Keys are analogous to directories in a filesystem.

  • Value: A named, typed datum stored within a key. Each value has a name (string), a type (REG_SZ, REG_DWORD, etc.), and data. A key can hold multiple values, each with a distinct name. One unnamed value per key is permitted (the default value). Values are analogous to files.

  • Layer: A named, precedence-ordered collection of registry writes. Every write is tagged with a layer. Reads resolve across layers: the highest-precedence entry wins. Removing a layer removes its entries and lower-precedence values surface automatically.

  • SD (Security Descriptor): A KACS structure controlling access to a registry key. Contains a DACL (who can access, and how) and optionally a SACL (audit policy). LCS retrieves a key's SD from the source and passes it to KACS AccessCheck at key open time.

  • AccessCheck: The KACS evaluation function that determines whether a caller's token grants the requested access against an object's SD. LCS calls AccessCheck at key open time. Single code path for all access control decisions across all Peios subsystems.

  • Token: A per-thread identity object maintained by KACS. Contains a user SID, group SIDs, a privilege bitmask, an integrity level, and metadata. When a thread makes a registry syscall, LCS captures the thread's effective token (including impersonation tokens) for AccessCheck evaluation.

  • SID (Security Identifier): A unique principal identifier (e.g., S-1-5-18 for SYSTEM, S-1-5-32-544 for Administrators). SIDs appear in tokens, in SDs, and in registry paths (Users\<SID>\).

  • GUID: A 128-bit identifier assigned by the kernel at key creation time and persisted by the source. A key's GUID is its identity -- immutable, never reused. Paths are the user-facing interface; GUIDs are the internal identity.

  • Watch: A persistent subscription for changes on a key fd. Armed via ioctl, pollable via epoll. Watches can cover a single key or an entire subtree. Events are delivered as structured records read from the fd.

  • TCB (Trusted Computing Base): The set of components whose correct behaviour is necessary for security. In the registry context, the TCB includes the kernel, KACS, LCS, and sources. Sources are TCB because LCS trusts the data they return -- SDs, values, symlink targets, key metadata.

§1.3 1 Introduction

Conventions

§1.3.1 Normative keywords

The key words MUST, MUST NOT, SHOULD, SHOULD NOT, and MAY in this specification are to be interpreted as described in RFC 2119.

§1.3.2 Pseudocode

Pseudocode in this specification uses the following conventions, matching the KACS v0.20 specification:

  • | bitwise OR, & bitwise AND, ~ bitwise NOT.
  • |= and &= augmented assignment.
  • -> field access on a pointer/reference.
  • // single-line comments.
  • denotes return type in function signatures.

SID comparison is binary (byte-for-byte equality). Two SIDs match if and only if every field is identical.

Access mask comparison is bitwise. "Mask A includes right R" means (A & R) == R.

§1.3.3 Ioctl encoding

Ioctl numbers are constructed using the standard Linux _IOC macro: _IOC(direction, type, number, size). The type byte, direction, and number for each ioctl are listed in the Constants appendix. The size is the total byte count of the ioctl's argument struct as defined in the Struct Layouts appendix. The final 32-bit ioctl number is derived from these four components per the Linux kernel ioctl encoding convention.

§1.3.4 Byte order

All multi-byte integers in LCS data structures, the RSI wire protocol, and the backup format are little-endian unless explicitly stated otherwise.

§1.3.5 String encoding

All strings in the LCS interface (key names, value names, hive names, layer names, paths) are UTF-8 encoded. Case folding for case-insensitive comparison is applied at the Unicode codepoint level after decoding from UTF-8, not on raw bytes. The case folding algorithm is defined in the data model Keys section.

§1.3.6 Registry paths

Registry paths use the backslash (\) as the canonical separator. LCS accepts forward slash (/) on input and normalises it to backslash before processing. Paths in this specification always use the canonical backslash form.

Paths are case-preserving and case-insensitive. The comparison algorithm is defined in the data model Keys section.

§1.4 1 Introduction

Compatibility

§1.4.1 Format compatibility

LCS has one hard external format compatibility requirement: registry.pol. The registry MUST support every data type, path semantic, and operation that registry.pol can express -- the binary format used by Active Directory Group Policy to deliver configuration to domain-joined machines. registry.pol compatibility is the reason the registry exists.

LCS is not responsible for parsing registry.pol files. Parsing is a userspace concern -- the Group Policy client reads registry.pol and translates its contents into registry syscalls. LCS provides the data model and operations necessary to faithfully represent everything registry.pol can express.

registry.pol drives the following format decisions:

  • Value types. The full Windows registry value type set (REG_SZ, REG_EXPAND_SZ, REG_BINARY, REG_DWORD, REG_DWORD_BIG_ENDIAN, REG_LINK, REG_MULTI_SZ, REG_QWORD, REG_NONE) MUST be supported. LCS treats values as opaque typed blobs -- it stores the type tag but does not interpret the data, except REG_LINK which triggers symlink resolution.

  • Path format. Registry paths use backslash separators and are case-preserving, case-insensitive. registry.pol paths follow this convention.

  • Access right bit positions. Registry-specific access rights (KEY_QUERY_VALUE, KEY_SET_VALUE, KEY_CREATE_SUB_KEY, etc.) occupy the same bit positions as Windows registry access rights. This ensures Security Descriptors containing registry ACEs are binary-compatible. The bit positions are defined in the Access Rights section of this specification; the SD binary format itself is specified by KACS.

No other format parity with Windows is claimed or required by LCS. SD binary format compatibility is a KACS guarantee, not an LCS one.

§1.4.2 Architectural divergences

LCS is modelled on the Windows Configuration Manager but diverges in several areas. These are intentional design decisions, not compatibility gaps.

Divergence Windows LCS Rationale
Backing store Kernel-internal hive files Userspace sources via RSI Enables different storage backends without kernel changes. Storage is a source concern, not a kernel concern.
Hive routing Fixed set of predefined hives Extensible -- any source can register any hive name at runtime Supports role installation, testing, and future hive types without kernel changes.
Layer system No equivalent. registry.pol is applied by flattening values. Precedence-ordered layers with tombstones. Reads resolve at query time. Automatic revert on layer deletion (no-tattoo semantics). Role uninstall and GP removal are layer deletion.
Change observation RegNotifyChangeKeyValue is single-shot (must re-register after each event) Persistent watches (remain armed until fd closes) Eliminates the race window between notification and re-registration where changes can be missed. Matches the inotify model.
Key identity Hive cell offsets (internal) GUIDs (128-bit, kernel-assigned, source-persisted) Stable across storage reorganisation. Consistent with Peios's identifier model.
Forward slash Not accepted in registry paths Accepted on input, normalised to backslash Convenience for Linux users. The canonical form is always backslash.
Case comparison RtlCompareUnicodeString Unicode Simple Case Folding (CaseFolding.txt, status S and C entries) Practical compatibility with Windows behaviour, not byte-identical in all edge cases. Fixed one-to-one codepoint mapping with no locale dependency.

§1.4.3 Excluded Windows features

The following Windows registry features have been evaluated and excluded from LCS.

Feature Why excluded
Key classes The "class" parameter in RegCreateKeyEx is documented as reserved by Microsoft. No known consumer.
RegOverridePredefKey Per-process key redirection. COM-specific. Would require unbounded per-process state in the kernel. Private hives and private layers cover the legitimate use cases.
WoW64 redirection 32/64-bit registry key splitting. Peios has no 32-bit compatibility concern.
HKEY_CLASSES_ROOT merged overlay Merges HKLM and HKCU Software\Classes. COM-specific. No Peios equivalent.