# The Handle Model

_Peios Kernel / Internals / KACS / File security_

> FACS is the file-specific enforcement surface of KACS — mount policy, scope, how a handle is acquired, and stacked backing files.

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

FACS, the File Access Control Shim, is the file-specific enforcement
surface of KACS. It replaces Linux DAC — UID, GID and mode-bit checks
— with security-descriptor evaluation on files.

Enforcement follows the handle pattern. AccessCheck runs once at open
time, the granted mask is cached on the file description, and later
operations test the cached mask:

```
(fd.granted & required) == required ? allow : deny
```

The mask is set once and never modified, and it is immutable for the
descriptor's whole lifetime regardless of any later descriptor change. <a id="cite-facs.handle.mask-immutable"></a>
A file's DACL can be rewritten while a process holds it open, and that
process keeps the rights it was granted. A few operations use a live
AccessCheck instead; [Use-Time Semantics](</kernel/internals/kacs/file-security/use-time-semantics.md#trm-3-9-4>) lists them.

A second immutable mask is stamped alongside it: the **continuous
audit mask** ([Auditing in AccessCheck](</kernel/internals/kacs/access-check/auditing-in-accesscheck.md#trm-3-8-9>)), which every use-time operation consults to
decide whether to emit a per-operation audit event. It travels with
the granted mask through every path described below. <a id="cite-facs.handle.audit-mask-stamped"></a>

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

## Mount policy

Every mounted filesystem exposes exactly one FACS mount-policy class,
scoped to the kernel superblock object rather than to a pathname or a
bind mount — several paths or bind mounts over one superblock all
observe the same class. <a id="cite-facs.handle.policy-per-superblock"></a>

**`unmanaged`** puts the mount outside the handle model entirely: no
granted mask is stamped on its file descriptions. <a id="cite-facs.handle.unmanaged-no-mask"></a> **`facs_deny_missing`**
is FACS-managed and denies access where a descriptor is missing.
**`facs_synthesize_ephemeral`** synthesises missing descriptors and
caches them in memory only. **`facs_synthesize_persistent`**
synthesises them and writes them back immediately. The three `facs_*`
classes are the only managed ones.

The default classifier is conservative. Hardcoded pseudo-filesystems —
`/proc`, `/sys`, nullfs — are `unmanaged`. Filesystems that cannot
reliably store the canonical descriptor xattr are
`facs_synthesize_ephemeral`: ramfs, FAT, exFAT, NFS client mounts,
ISO9660, and cgroup2. StrataFS is fixed at `facs_deny_missing`. Everything else
— tmpfs, squashfs, ext4, btrfs — defaults to `facs_deny_missing`
unless a trusted policy agent adopts it.

Userspace cannot set a superblock to `unmanaged` through the public
ABI; the class is reserved for the kernel classifier and the hardcoded
rules. Attempting to set a policy on a magic-derived `unmanaged`
superblock fails with `EOPNOTSUPP`, and so does attempting to change
StrataFS's. <a id="cite-facs.handle.unmanaged-not-settable"></a>

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

## Scope

The sole-authority claim covers local FACS-managed filesystems. It
does not cover:

- `O_PATH` descriptors, which are not managed;
- NFS client mounts, which are ephemeral-synthesising and retain dual
  authority with the server;
- `/proc`, which is unmanaged and PIP-protected; or
- `/sys`, which is unmanaged and carries a hardcoded rule instead —
  writes there require Administrators or SYSTEM, enforced against a
  built-in descriptor. <a id="cite-facs.handle.sysfs-write-builtin-descriptor"></a>

Descriptors for processes obtained through `pidfd` bypass FACS at open
as well. <a id="cite-facs.handle.pidfd-bypasses-open"></a>

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

## Handle acquisition

A descriptor carries its granted mask through every acquisition path,
and transfer is an intentional capability-delegation mechanism.

- `dup`/`dup3` and `fork` produce the same open file description and
  therefore the same rights; <a id="cite-facs.handle.dup-fork-same-rights"></a>
- descriptors without `FD_CLOEXEC` survive exec unchanged; <a id="cite-facs.handle.exec-preserves-mask"></a>
- `SCM_RIGHTS` transfers the descriptor as a capability token, with
  possession as authorization and no re-check of the receiver's
  identity; and <a id="cite-facs.handle.scm-rights-capability"></a>
- `pidfd_getfd()` is gated by an AccessCheck for `PROCESS_DUP_HANDLE`
  against the target process, after which the caller receives the
  descriptor with its full mask. <a id="cite-facs.handle.pidfd-getfd-gate"></a>

The security boundary is at open time. Every subsequent transfer
carries the mask unchanged.

This means mandatory subject policy — MIC and PIP — is evaluated once,
at open, against the opener. <a id="cite-facs.handle.mic-pip-at-open"></a> A high-integrity process that opens a
file and passes the descriptor to a low-integrity one has effectively
delegated its access. That is the handle model: authority is on the
handle, not on the holder.

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

## Stacked backing files

When a stacking filesystem creates a kernel-private backing file for a
managed user-visible file, the outer file's granted and continuous
audit masks are captured into the backing-file blob, and the backing
file's ordinary blob receives that exact snapshot when the provider is
opened. <a id="cite-facs.handle.backing-snapshot-captured"></a> No new AccessCheck runs against the task executing the
stacking filesystem. <a id="cite-facs.handle.backing-no-new-accesscheck"></a>

The inheritance is deliberately narrow. It is admitted only through
the kernel's typed backing-file allocation path, only from a managed
non-`O_PATH` outer file, and it retains no reference to that outer
file — only the values. <a id="cite-facs.handle.backing-admission-narrow"></a> It is not a general snapshot-cloning
mechanism.

An active StrataFS copy-up context takes precedence: a backing open
that does not match its exact object and phase does not fall back to
inherited authority. <a id="cite-facs.handle.copy-up-context-precedence"></a> When an exactly-bound copy-up backing file is
adopted by the outer descriptor, the outer snapshot is installed into
both blobs as a single transition, after which the backing file
behaves like any other stacked open.

For an OverlayFS provider, this handoff also reaches the exact private
backing files opened beneath the staged file. KACS validates the bounded
chain before changing any snapshot, then copies the original outer handle's
granted and continuous-audit masks into both blobs of every admitted file.
The handoff runs after the staged open and before publication. It does not
relax the active copy-up context's object and phase checks.

The user-visible operation is checked and continuously audited once,
against the outer handle. Immediate provider re-entry through
`security_file_permission` or `security_mmap_file` neither repeats the
caller authorization nor emits a second caller audit event. <a id="cite-facs.handle.no-duplicate-provider-check"></a> The
backing file keeps the snapshot for later descriptor-local
enforcement, including `mprotect()` after a stacked mmap, and the
`mmap_backing_file` handoff verifies that the outer, backing and
captured snapshots still agree before the provider mapping is
installed. <a id="cite-facs.handle.mmap-backing-verifies-agreement"></a>

This suppresses duplicate *KACS* authorization only. It bypasses
nothing else — not another LSM, not filesystem errors, not read-only
mounts, immutable state, quota, space, I/O, or format validation. <a id="cite-facs.handle.backing-suppresses-kacs-only"></a>

## Operational consequences

Treat a transferred descriptor as a capability carrying its established
rights. Passing it to a less privileged process does not rerun the original
open against the receiver's token. Fork can retain those open descriptions;
exec retains descriptors without close-on-exec. Review descriptor inheritance
as part of a launcher or request broker's authority design.

Changing a descriptor, token, or central policy does not retrospectively
revoke that cached file-handle grant. Conversely, losing a token privilege
does not prove an old descriptor lost its usable rights. Test changed policy
with fresh opens. Mappings have their own creation-time checks and page
permissions, not a fresh policy decision for every memory access.

An `O_PATH` handle does not carry ordinary data-access authority; descriptor
management uses its documented live checks. Append-only authority does not
authorize truncation or shared writable mapping. A remote filesystem can also
apply server-side authority after the local check. These boundaries belong
to [use-time semantics](/kernel/internals/kacs/file-security/use-time-semantics.md)
and [legacy-open compatibility](/kernel/internals/kacs/file-security/legacy-open-compatibility.md),
not a general promise that every operation consults only one immutable mask.
