6.5 Operations

A store keeper issues every operation as an ioctl on the device descriptor. Each takes a pointer to one structure. Reserved fields MUST be zero, and the kernel fails EINVAL if one is not.

IoctlPurpose
KTRUST_ADDAdd one object to the store
KTRUST_REMOVERemove one object from the store
KTRUST_LISTList the objects of one kind
KTRUST_SEEN_LISTList the seen certificates
KTRUST_SEEN_GETFetch one seen certificate

6.5.1 Generation #

The kernel holds a u64 generation, which starts at 1 once the store image is read and rises by one for each KTRUST_ADD or KTRUST_REMOVE that changes the store. Every operation that reads or changes the store returns the generation as it stands when the operation completes.

6.5.2 KTRUST_ADD #

The argument is a ktrust_add_args.

FieldTypeDescription
object_ptru64Address of the object
object_lenu32Length of the object
_padu32Reserved
generationu64Out: the generation

The object is a top-level certificate, a revocation, or a distrust entry. The kernel treats it exactly as it treats an entry of the store image (§6.3).

Adding an object the store already holds succeeds and changes nothing.

ErrorMeaning
EINVALThe object is malformed, or is not one of the three kinds
EKEYREJECTEDA top-level's signature does not verify
ENOSPCThe store is at a limit (§6.A)

The kernel does not require proof that a revocation applies to anything. It keeps the revocation and applies it to a chain when PGSS §7.12 says it applies. Showing that a revocation is worth keeping is the store keeper's (PGSS §7.12).

6.5.3 KTRUST_REMOVE #

The argument is a ktrust_remove_args.

FieldTypeDescription
kindu80x01 for a top-level, 0x05 for a distrust entry
_padu8[7]Reserved
hashu8[64]The top-level's object hash, or the hash a distrust entry distrusts
generationu64Out: the generation
ErrorMeaning
EINVALkind is neither value
EPERMkind is 0x04: a revocation is never removed
ENOENTThe store holds no such object

6.5.4 KTRUST_LIST #

The argument is a ktrust_list_args.

FieldTypeDescription
kindu80x01, 0x04, or 0x05
_padu8[7]Reserved
cursoru64In: 0 to start, or the value last returned. Out: the value to continue with
buf_ptru64Address of a buffer for entries
buf_lenu32Length of the buffer
countu32Out: the number of entries written
generationu64Out: the generation

The kernel writes whole ktrust_entry structures, as many as fit. A count of 0 means the list is complete.

FieldTypeDescription
hashu8[64]A top-level's or revocation's object hash, or the hash a distrust entry distrusts
detailu8For a top-level, 0x01 rooted or 0x02 unrooted. Otherwise the entry's target_type
_padu8[7]Reserved

If the generation changes between two calls of one listing, the listing might repeat or miss an entry. A store keeper that needs a consistent view MUST start again.

6.5.5 KTRUST_SEEN_LIST #

The kernel records every certificate it verifies as part of a chain, whether the certificate came from a bundle, from a directory of intermediaries, or from the store. The record lasts until the system restarts. Leaves are not recorded.

The argument is a ktrust_seen_list_args.

FieldTypeDescription
cursoru64As for KTRUST_LIST
buf_ptru64Address of a buffer for entries
buf_lenu32Length of the buffer
countu32Out: the number of entries written

Each entry is a ktrust_seen_entry.

FieldTypeDescription
hashu8[64]The certificate's object hash
issueru8[64]The certificate's issuer field
top_levelu8[64]The object hash of the top-level it was last verified under
use_countu64Verifications that passed through it
first_seenu64Nanoseconds since boot at the first
last_seenu64Nanoseconds since boot at the most recent
liveu32Processes running under a chain that passes through it
_padu32Reserved

6.5.6 KTRUST_SEEN_GET #

The argument is a ktrust_seen_get_args.

FieldTypeDescription
hashu8[64]The certificate's object hash
buf_ptru64Address of a buffer for the certificate
buf_lenu32Length of the buffer
object_lenu32Out: the certificate's length
ErrorMeaning
ENOENTNo such certificate has been seen
ERANGEThe buffer is too small. object_len holds the length needed

6.5.7 Reconciling after attaching #

The kernel's store at the moment a store keeper attaches is whatever the image held at boot, plus whatever earlier store keepers added. A store keeper MUST then make it match the trust store it reads from disk:

  1. List each kind.
  2. Add every top-level, revocation, and distrust entry the trust store holds and the kernel does not.
  3. Remove every top-level and distrust entry the kernel holds and the trust store does not.

A store keeper MUST NOT treat a revocation the kernel holds and the trust store does not as an error. It adds that revocation to the trust store (PGSS §7.12).

Edit this page