Generated token and session ABI

struct kacs_query_args #

Total size 16 bytes.

OffsetSizeTypeField
04__u32token_class
44__u32buf_len
88__u64buf_ptr

struct kacs_adjust_privs_args #

Total size 24 bytes.

OffsetSizeTypeField
04__u32count
44__u32_pad
88__u64data_ptr
168__u64previous_enabled

struct kacs_priv_entry #

Total size 8 bytes.

OffsetSizeTypeField
04__u32luid
44__u32attributes

struct kacs_adjust_groups_args #

Total size 144 bytes.

OffsetSizeTypeField
04__u32count
44__u32_pad
88__u64data_ptr
16128__u64``[16]previous_state

struct kacs_duplicate_args #

Total size 16 bytes.

OffsetSizeTypeField
04__u32access_mask
44__u32token_type
84__u32impersonation_level
124__s32result_fd

struct kacs_group_entry #

Total size 8 bytes.

OffsetSizeTypeField
04__u32index
44__u32enable

struct kacs_adjust_default_args #

Total size 16 bytes.

OffsetSizeTypeField
08__u64dacl_ptr
84__u32dacl_len
122__u16owner_index
142__u16group_index

struct kacs_restrict_args #

Total size 40 bytes.

OffsetSizeTypeField
08__u64privs_to_delete
84__u32num_deny_indices
124__u32num_restrict_sids
164__u32data_len
204__u32flags
248__u64data_ptr
324__s32result_fd
364__u32_pad

Total size 16 bytes.

OffsetSizeTypeField
04__s32elevated_fd
44__s32filtered_fd
88__u64logon_session_id

struct kacs_get_linked_token_args #

Total size 4 bytes.

OffsetSizeTypeField
04__s32result_fd

Token constants #

From uapi/pkm/token.h.

kacs_open_self_token (SYS_KACS_OPEN_SELF_TOKEN) flags.

ConstantValue
KACS_TOKEN_OPEN_REAL0x01 (1)

Per-handle token rights (the low 16 bits of a token access mask).

ConstantValue
KACS_TOKEN_ASSIGN_PRIMARY0x0001 (1)
KACS_TOKEN_DUPLICATE0x0002 (2)
KACS_TOKEN_IMPERSONATE0x0004 (4)
KACS_TOKEN_QUERY0x0008 (8)
KACS_TOKEN_QUERY_SOURCE0x0010 (16)
KACS_TOKEN_ADJUST_PRIVS0x0020 (32)
KACS_TOKEN_ADJUST_GROUPS0x0040 (64)
KACS_TOKEN_ADJUST_DEFAULT0x0080 (128)
KACS_TOKEN_ADJUST_INTERACTIVITY_SCOPE0x0100 (256)
KACS_TOKEN_ALL_ACCESS0x000F01FF

Token ioctl interface identifier.

ConstantValue
KACS_IOC_MAGIC0x4B (75)

kacs_priv_entry.attributes bits.

ConstantValue
KACS_PRIVILEGE_ATTR_ENABLED0x00000002 (2)
KACS_PRIVILEGE_ATTR_REMOVED0x00000004 (4)

kacs_adjust_privs bulk-reset flag (not a per-entry attribute).

ConstantValue
KACS_PRIVILEGE_RESET_ALL_DEFAULTS0x80000000

kacs_restrict_args.flags bits.

ConstantValue
KACS_TOKEN_RESTRICT_WRITE_RESTRICTED0x00000001 (1)

Token type (KACS_TOKEN_CLASS_TYPE).

ConstantValue
KACS_TOKEN_TYPE_PRIMARY0x01 (1)
KACS_TOKEN_TYPE_IMPERSONATION0x02 (2)

Impersonation level (KACS_TOKEN_CLASS_IMPERSONATION_LEVEL).

ConstantValue
KACS_IMLEVEL_ANONYMOUS0x00 (0)
KACS_IMLEVEL_IDENTIFICATION0x01 (1)
KACS_IMLEVEL_IMPERSONATION0x02 (2)
KACS_IMLEVEL_DELEGATION0x03 (3)

Elevation type (KACS_TOKEN_CLASS_ELEVATION_TYPE).

ConstantValue
KACS_ELEVATION_DEFAULT0x01 (1)
KACS_ELEVATION_FULL0x02 (2)
KACS_ELEVATION_LIMITED0x03 (3)

Mandatory-policy bits (KACS_TOKEN_CLASS_MANDATORY_POLICY).

ConstantValue
KACS_TOKEN_MANDATORY_POLICY_NO_WRITE_UP0x00000001 (1)
KACS_TOKEN_MANDATORY_POLICY_NEW_PROCESS_MIN0x00000002 (2)

Per-token audit-policy bits — the create-token spec audit_policy field (KACS_TOKEN_SPEC_OFF_AUDIT_POLICY). They select which access-check outcomes the token's object accesses generate audit events for.

ConstantValue
KACS_AUDIT_POLICY_OBJECT_ACCESS_SUCCESS0x00000001 (1)
KACS_AUDIT_POLICY_OBJECT_ACCESS_FAILURE0x00000002 (2)
KACS_AUDIT_POLICY_PRIVILEGE_USE_SUCCESS0x00000004 (4)
KACS_AUDIT_POLICY_PRIVILEGE_USE_FAILURE0x00000008 (8)

Logon type (KACS_TOKEN_CLASS_LOGON_TYPE).

ConstantValue
KACS_LOGON_TYPE_INTERACTIVE2
KACS_LOGON_TYPE_NETWORK3
KACS_LOGON_TYPE_BATCH4
KACS_LOGON_TYPE_SERVICE5
KACS_LOGON_TYPE_NETWORK_CLEARTEXT8
KACS_LOGON_TYPE_NEW_CREDENTIALS9
KACS_LOGON_TYPE_REMOTE_INTERACTIVE10

Maximum number of groups a token may carry.

ConstantValue
KACS_TOKEN_MAX_GROUPS1024

Number of 64-bit words in a group enabled-state bitmask (KACS_TOKEN_MAX_GROUPS / 64).

ConstantValue
KACS_TOKEN_GROUP_MASK_WORDS16

kacs_create_token (SYS_KACS_CREATE_TOKEN) spec wire format.

The (spec, len) buffer the syscall consumes is a fixed KACS_TOKEN_SPEC_HEADER_BYTES-byte header followed by variable-length sections at header-specified byte offsets. An offset/length (or offset/count) pair that is both zero means the section is absent. Sections may appear in any order; every offset+length is validated to fall within the buffer. The header is not a C struct (it carries packed mixed-width fields and crosses the syscall boundary as raw bytes); read each field at its KACS_TOKEN_SPEC_OFF_* offset. Its fields, in order: __u32 version must be KACS_TOKEN_SPEC_VERSION _u8 token_type KACS_TOKEN_TYPE _u8 impersonation_level KACS_IMLEVEL __u8 _reserved0[2] must be 0 __u32 integrity_rid integrity-level RID _u32 mandatory_policy KACS_TOKEN_MANDATORY_POLICY* bits _u64 privs_present privilege bitmask (KACS_SE*_PRIVILEGE) __u64 privs_enabled initially enabled privileges (subset) __u32 _reserved1 must be 0 (elevation set only by LINK_TOKENS) __u32 projected_uid Linux UID for credential projection __u32 projected_gid Linux GID for credential projection __u32 audit_policy per-token audit flags __u64 expiration expiry timestamp (0 = none) __u64 logon_session_id logon session ID (auth_id) __u32 owner_sid_index 0 = user SID, 1..N = caller group __u32 primary_group_index 0 = user SID, 1..N = caller group __u8 source_name[8] token source name __u64 source_id token source LUID __u32 user_sid_offset byte offset to the user SID __u32 groups_offset byte offset to the groups array __u32 groups_count number of group entries __u32 default_dacl_offset byte offset to the default DACL (0 = none) __u32 default_dacl_len default DACL byte length (0 = none) __u32 user_claims_offset byte offset to user claims (0 = none) __u32 user_claims_len user claims byte length (0 = none) __u32 device_claims_offset byte offset to device claims (0 = none) __u32 device_claims_len device claims byte length (0 = none) __u32 device_groups_offset byte offset to device groups (0 = none) __u32 device_groups_count number of device-group entries (0 = none) __u32 restricted_sids_offset byte offset to restricted SIDs (0 = none) __u32 restricted_sids_count number of restricted-SID entries (0 = none) __u32 confinement_sid_offset byte offset to confinement SID (0 = none) __u32 confinement_sid_len confinement SID byte length (0 = none) __u32 confinement_caps_offset byte offset to confinement caps (0 = none) __u32 confinement_caps_count number of confinement-cap entries (0 = none) __u8 confinement_exempt 1 = exempt from confinement __u8 write_restricted 1 = write-restricted mode __u8 user_deny_only 1 = user SID matches deny ACEs only __u8 isolation_boundary 1 = enable namespace filtering __u32 supp_gids_offset byte offset to supplementary GIDs (0 = none) __u32 supp_gids_count number of supplementary-GID entries (0 = none) __u32 restricted_device_groups_offset byte offset (0 = none) __u32 restricted_device_groups_count entry count (0 = none) __u64 origin originating logon-session LUID (0 = none) __u32 interactivity_scope interactive session number __u32 lcs_credentials_offset byte offset to the LCS extension (0 = none) A group/device-group/restricted- SID/confinement-cap/restricted-device-group entry is [__u32 sid_len][__u8 sid[sid_len]][__u32 attributes]. A supplementary-GIDs section is supp_gids_count little-endian __u32 GIDs. All multi-byte header and section scalars are little-endian.

ConstantValue
KACS_TOKEN_SPEC_VERSION2
KACS_TOKEN_SPEC_HEADER_BYTES192
KACS_TOKEN_SPEC_MIN_BYTES192
KACS_TOKEN_SPEC_MAX_BYTES65536

Byte offsets of the fixed token-spec header fields.

ConstantValue
KACS_TOKEN_SPEC_OFF_VERSION0
KACS_TOKEN_SPEC_OFF_TOKEN_TYPE4
KACS_TOKEN_SPEC_OFF_IMPERSONATION_LEVEL5
KACS_TOKEN_SPEC_OFF_RESERVED06
KACS_TOKEN_SPEC_OFF_INTEGRITY_RID8
KACS_TOKEN_SPEC_OFF_MANDATORY_POLICY12
KACS_TOKEN_SPEC_OFF_PRIVS_PRESENT16
KACS_TOKEN_SPEC_OFF_PRIVS_ENABLED24
KACS_TOKEN_SPEC_OFF_RESERVED132
KACS_TOKEN_SPEC_OFF_PROJECTED_UID36
KACS_TOKEN_SPEC_OFF_PROJECTED_GID40
KACS_TOKEN_SPEC_OFF_AUDIT_POLICY44
KACS_TOKEN_SPEC_OFF_EXPIRATION48
KACS_TOKEN_SPEC_OFF_LOGON_SESSION_ID56
KACS_TOKEN_SPEC_OFF_OWNER_SID_INDEX64
KACS_TOKEN_SPEC_OFF_PRIMARY_GROUP_INDEX68
KACS_TOKEN_SPEC_OFF_SOURCE_NAME72
KACS_TOKEN_SPEC_OFF_SOURCE_ID80
KACS_TOKEN_SPEC_OFF_USER_SID_OFFSET88
KACS_TOKEN_SPEC_OFF_GROUPS_OFFSET92
KACS_TOKEN_SPEC_OFF_GROUPS_COUNT96
KACS_TOKEN_SPEC_OFF_DEFAULT_DACL_OFFSET100
KACS_TOKEN_SPEC_OFF_DEFAULT_DACL_LEN104
KACS_TOKEN_SPEC_OFF_USER_CLAIMS_OFFSET108
KACS_TOKEN_SPEC_OFF_USER_CLAIMS_LEN112
KACS_TOKEN_SPEC_OFF_DEVICE_CLAIMS_OFFSET116
KACS_TOKEN_SPEC_OFF_DEVICE_CLAIMS_LEN120
KACS_TOKEN_SPEC_OFF_DEVICE_GROUPS_OFFSET124
KACS_TOKEN_SPEC_OFF_DEVICE_GROUPS_COUNT128
KACS_TOKEN_SPEC_OFF_RESTRICTED_SIDS_OFFSET132
KACS_TOKEN_SPEC_OFF_RESTRICTED_SIDS_COUNT136
KACS_TOKEN_SPEC_OFF_CONFINEMENT_SID_OFFSET140
KACS_TOKEN_SPEC_OFF_CONFINEMENT_SID_LEN144
KACS_TOKEN_SPEC_OFF_CONFINEMENT_CAPS_OFFSET148
KACS_TOKEN_SPEC_OFF_CONFINEMENT_CAPS_COUNT152
KACS_TOKEN_SPEC_OFF_CONFINEMENT_EXEMPT156
KACS_TOKEN_SPEC_OFF_WRITE_RESTRICTED157
KACS_TOKEN_SPEC_OFF_USER_DENY_ONLY158
KACS_TOKEN_SPEC_OFF_ISOLATION_BOUNDARY159
KACS_TOKEN_SPEC_OFF_SUPP_GIDS_OFFSET160
KACS_TOKEN_SPEC_OFF_SUPP_GIDS_COUNT164
KACS_TOKEN_SPEC_OFF_RESTRICTED_DEVICE_GROUPS_OFFSET168
KACS_TOKEN_SPEC_OFF_RESTRICTED_DEVICE_GROUPS_COUNT172
KACS_TOKEN_SPEC_OFF_ORIGIN176
KACS_TOKEN_SPEC_OFF_INTERACTIVITY_SCOPE184
KACS_TOKEN_SPEC_OFF_LCS_CREDENTIALS_OFFSET188

Byte length of the fixed token-source-name field.

ConstantValue
KACS_TOKEN_SPEC_SOURCE_NAME_BYTES8

Optional LCS registry-credentials extension, located at the token-spec header's lcs_credentials_offset. The section is a fixed KACS_TOKEN_LCS_EXT_HEADER_BYTES-byte header bounded by the next active variable-section offset or the end of the spec; it is consumed exactly (trailing bytes are malformed). Header fields, in order: __u32 version must be KACS_TOKEN_LCS_EXT_VERSION __u32 _reserved must be 0 __u32 scope_count private hive scope GUIDs (<= max) __u32 private_layer_count private layer names (<= max) Payload: scope_count raw 16-byte GUIDs, then private_layer_count little-endian __u32 name byte lengths, then the concatenated UTF-8 layer names. Scope GUIDs must be non-nil and unique; layer names must be 1.. KACS_TOKEN_LCS_MAX_LAYER_NAME_BYTES bytes, must not contain '\', '/', or NUL, and must be unique under case-insensitive matching.

ConstantValue
KACS_TOKEN_LCS_EXT_VERSION1
KACS_TOKEN_LCS_EXT_HEADER_BYTES16
KACS_TOKEN_LCS_SCOPE_GUID_BYTES16
KACS_TOKEN_LCS_MAX_SCOPE_GUIDS256
KACS_TOKEN_LCS_MAX_PRIVATE_LAYERS256
KACS_TOKEN_LCS_MAX_LAYER_NAME_BYTES255

Byte offsets of the fixed LCS-extension header fields.

ConstantValue
KACS_TOKEN_LCS_EXT_OFF_VERSION0
KACS_TOKEN_LCS_EXT_OFF_RESERVED4
KACS_TOKEN_LCS_EXT_OFF_SCOPE_COUNT8
KACS_TOKEN_LCS_EXT_OFF_PRIVATE_LAYER_COUNT12

kacs_create_logon_session (SYS_KACS_CREATE_LOGON_SESSION) spec wire format.

The (spec, len) buffer the syscall consumes is, in order: _u8 logon_type one of KACS_LOGON_TYPE* above __le16 auth_pkg_len byte length of the auth-package name __u8 auth_pkg[auth_pkg_len] auth-package name (valid UTF-8) __le32 user_sid_len byte length of the user SID __u8 user_sid[user_sid_len] binary SID of the authenticated user The buffer is consumed exactly: 7 + auth_pkg_len + user_sid_len must equal len. The kernel assigns the session ID and derives the logon SID from it.

ConstantValue
KACS_LOGON_SESSION_SPEC_MIN_BYTES15
KACS_LOGON_SESSION_SPEC_MAX_BYTES4096

Byte offsets of the fixed-position session-spec fields.

ConstantValue
KACS_LOGON_SESSION_SPEC_OFF_LOGON_TYPE0
KACS_LOGON_SESSION_SPEC_OFF_AUTH_PKG_LEN1
KACS_LOGON_SESSION_SPEC_OFF_AUTH_PKG3

Token-handle ioctls.

ConstantValue
KACS_IOC_QUERY0xC0104B00
KACS_IOC_ADJUST_PRIVS0x40184B01
KACS_IOC_DUPLICATE0xC0104B02
KACS_IOC_INSTALL0x00004B03
KACS_IOC_RESTRICT0xC0284B04
KACS_IOC_LINK_TOKENS0x40104B05
KACS_IOC_GET_LINKED_TOKEN0xC0044B06
KACS_IOC_ADJUST_GROUPS0x40904B07
KACS_IOC_IMPERSONATE0x00004B08
KACS_IOC_ADJUST_DEFAULT0x40104B09
KACS_IOC_ADJUST_INTERACTIVITY_SCOPE0x40044B0A

Token information classes (kacs_query_args.token_class).

GUID returns 16 immutable raw bytes in the same order as KMES headers.

ConstantValue
KACS_TOKEN_CLASS_USER0x01 (1)
KACS_TOKEN_CLASS_GROUPS0x02 (2)
KACS_TOKEN_CLASS_PRIVILEGES0x03 (3)
KACS_TOKEN_CLASS_TYPE0x04 (4)
KACS_TOKEN_CLASS_INTEGRITY_LEVEL0x05 (5)
KACS_TOKEN_CLASS_OWNER0x06 (6)
KACS_TOKEN_CLASS_PRIMARY_GROUP0x07 (7)
KACS_TOKEN_CLASS_INTERACTIVITY_SCOPE0x08 (8)
KACS_TOKEN_CLASS_RESTRICTED_SIDS0x09 (9)
KACS_TOKEN_CLASS_SOURCE0x0A (10)
KACS_TOKEN_CLASS_STATISTICS0x0B (11)
KACS_TOKEN_CLASS_ORIGIN0x0C (12)
KACS_TOKEN_CLASS_ELEVATION_TYPE0x0D (13)
KACS_TOKEN_CLASS_DEVICE_GROUPS0x0E (14)
KACS_TOKEN_CLASS_APPCONTAINER_SID0x0F (15)
KACS_TOKEN_CLASS_CAPABILITIES0x10 (16)
KACS_TOKEN_CLASS_MANDATORY_POLICY0x11 (17)
KACS_TOKEN_CLASS_LOGON_TYPE0x12 (18)
KACS_TOKEN_CLASS_LOGON_SID0x13 (19)
KACS_TOKEN_CLASS_DEFAULT_DACL0x14 (20)
KACS_TOKEN_CLASS_IMPERSONATION_LEVEL0x15 (21)
KACS_TOKEN_CLASS_USER_CLAIMS0x16 (22)
KACS_TOKEN_CLASS_DEVICE_CLAIMS0x17 (23)
KACS_TOKEN_CLASS_PROJECTED_SUPPLEMENTARY_GIDS0x18 (24)
KACS_TOKEN_CLASS_GUID0x19 (25)

Privileges, as single-bit masks within a token's 64-bit privilege word (present / enabled / enabled-by-default / used are each one such word). Named for the Windows privilege identifiers (SeTcbPrivilege, …).

ConstantValue
KACS_SE_CREATE_TOKEN_PRIVILEGE4
KACS_SE_ASSIGN_PRIMARY_TOKEN_PRIVILEGE8
KACS_SE_LOCK_MEMORY_PRIVILEGE16
KACS_SE_INCREASE_QUOTA_PRIVILEGE32
KACS_SE_TCB_PRIVILEGE128
KACS_SE_SECURITY_PRIVILEGE256
KACS_SE_TAKE_OWNERSHIP_PRIVILEGE512
KACS_SE_LOAD_DRIVER_PRIVILEGE1024
KACS_SE_SYSTEM_PROFILE_PRIVILEGE2048
KACS_SE_SYSTEMTIME_PRIVILEGE4096
KACS_SE_PROFILE_SINGLE_PROCESS_PRIVILEGE8192
KACS_SE_INCREASE_BASE_PRIORITY_PRIVILEGE16384
KACS_SE_BACKUP_PRIVILEGE131072
KACS_SE_RESTORE_PRIVILEGE262144
KACS_SE_SHUTDOWN_PRIVILEGE524288
KACS_SE_DEBUG_PRIVILEGE0x100000 (1048576)
KACS_SE_AUDIT_PRIVILEGE0x200000 (2097152)
KACS_SE_CHANGE_NOTIFY_PRIVILEGE0x800000 (8388608)
KACS_SE_REMOTE_SHUTDOWN_PRIVILEGE0x1000000 (16777216)
KACS_SE_MANAGE_VOLUME_PRIVILEGE0x10000000 (268435456)
KACS_SE_IMPERSONATE_PRIVILEGE0x20000000 (536870912)
KACS_SE_RELABEL_PRIVILEGE0x100000000 (4294967296)
KACS_SE_CREATE_SYMBOLIC_LINK_PRIVILEGE0x800000000 (34359738368)
KACS_SE_LOCK_PARENTAGE_PRIVILEGE0x2000000000000000 (2305843009213693952)

Edit this page