Appendix 4.A Constants

Every value below is generated from the source by pkm/tools/gen-stratafs-constants.py. Nothing here is transcribed by hand, and the generator's --check mode fails if the two drift apart.

4.A.1 Filesystem identity #

ConstantValueMeaning
STRATAFS_MAGIC0x53545241Superblock magic, reported by statfs (§4.2.2)
STRATAFS_NAME"stratafs"The name the filesystem registers under
STRATAFS_MAX_STRATA16Longest stratum stack accepted (§4.2.1)

STRATAFS_MAGIC is an alias for STRATAFS_SUPER_MAGIC, which is declared in the header stratafs shares with KACS so that the mount policy class keyed on it cannot drift (§4.6.4).

4.A.2 Stratum flags #

ConstantValueMeaning
STRATAFS_F_CREATE0x1The create flag (§4.2.1)
STRATAFS_F_RO0x2The ro flag
STRATAFS_F_AM0x4The am flag

4.A.3 Extended attributes #

ConstantValueMeaning
STRATAFS_XATTR_PREFIX"system.stratafs."Reserved namespace; never forwarded to a provider (§4.7)
STRATAFS_XATTR_ORIGIN"system.stratafs.origin"Synthetic, read-only, hidden from listings (§4.7)
STRATAFS_XATTR_STAGING"security.peios.stratafs_staging"Copy-up staging marker; also reserved (§4.5.2)

STRATAFS_XATTR_STAGING is an alias for STRATAFS_STAGING_XATTR, declared in the shared header. Note the name it resolves to lies outside the reserved system.stratafs. namespace, yet receives the same treatment (§4.7).

The canonical security-descriptor attribute is KACS's, not stratafs's; stratafs only detects it in order to exclude it from copy-up replication (§4.6.3).

4.A.4 Copy-up and staging #

ConstantValueMeaning
STRATAFS_STAGE_MARKER_MAGIC0x53544731Marker magic
STRATAFS_STAGE_MARKER_VERSION1Marker version
STRATAFS_COPY_BUFFER_SIZE65536Copy-up read/write chunk, in bytes (§4.5.2)
STRATAFS_STAGE_PREFIX".stratafs-stage-"Staged-name prefix
STRATAFS_RECOVERY_BATCH128Names scanned per staging-recovery pass

4.A.4.1 The staging marker #

struct stratafs_stage_marker is packed and 24 bytes, all fields little-endian. It is the value of the staging attribute above.

OffsetSizeFieldType
04magic__le32
42version__le16
62size__le16
88boot_cookie__le64
168mount_cookie__le64

4.A.5 Routing #

The value route_existing returns (§4.5.1), as the Rust decision core names it and as the C glue mirrors it. The discriminants match.

C enumeratorValueRust
STRATAFS_ROUTE_IN_PLACE0InPlace
STRATAFS_ROUTE_COPY_UP1CopyUp
STRATAFS_ROUTE_READ_ONLY2ReadOnly

4.A.6 The decision core #

stratafs-core holds the stack-wide flag rules, provider selection, and routing. Its flag bits match the C ones above exactly.

ConstantValue
MAX_STRATA16
FLAG_CREATE0x1
FLAG_READ_ONLY0x2
FLAG_ABSENT_MAY0x4
FLAG_MASK0x7

The crate distinguishes these configuration errors. The C boundary collapses all of them to EINVAL, so the distinction is not observable to a caller (§4.2.1).

ErrorDiscriminant
Empty1
TooMany2
UnknownFlag3
RepeatedCreate4
CreateReadOnly5

4.A.7 Build configuration #

stratafs is built by CONFIG_STRATAFS_FS, a boolean option, so what it builds is linked into vmlinux rather than loaded. It depends on CONFIG_SECURITY_PKM and selects FS_STACK. Its sources are staged into the kernel tree as fs/stratafs, separate from PKM's own security/pkm. CONFIG_STRATAFS_KUNIT_TEST builds the in-kernel unit tests.

The translation units are:

  • super.o
  • lookup.o
  • inode.o
  • file.o
  • dir.o
  • xattr.o
  • copy_up.o

Edit this page