Socket ABI compatibility

Socket options and retired syscall numbers #

Peer identity on AF_UNIX sockets is read and bounded through socket options rather than syscalls. include/uapi/pkm/socket.h defines the option level SOL_KACS (4096), its options KACS_SO_PEER_TOKEN, KACS_SO_IMPERSONATION_LEVEL, KACS_SO_PASS_TOKEN and KACS_SO_RESTAMP, and the ancillary message type KACS_SCM_TOKEN, which travels at cmsg_level SOL_KACS (KACS ABI Reference). The kernel dispatches the option level in net/socket.c ahead of the protocol's own handlers (patch net/socket.c), so the options reach KACS on every socket family and KACS decides which it supports. The ancillary message is carried per skb on AF_UNIX: net/core/scm.c gives struct scm_cookie a counted token reference and parses SOL_KACS control messages; net/unix/af_unix.c carries the reference on struct unix_skb_parms, stops a stream read at an identity boundary, and advances the register at the point of consumption. Everything KACS-specific behind those hooks lives in security/pkm/kacs/socket.c. The semantics and error codes are in Impersonation Lifecycle.

System V IPC objects carry descriptors of their own (Objects and Their Descriptors); their rights are include/uapi/pkm/ipc.h, and the same header defines the KACS_SD_AT_SYSV_* flags that let kacs_get_sd and kacs_set_sd address such an object by kind and id (dirfd carries the id, the path is NULL). The lookup is ipc_lsm_with_object, exported from ipc/util.c by ipc/util-lsm-with-object.patch; the hooks themselves are the LSM's own IPC hooks and need no patch.

Three syscall numbers are retired and left as permanent holes: 1010 (kacs_open_peer_token), 1011 (kacs_impersonate_peer) and 1013 (kacs_set_impersonation_level). A binary built against them gets ENOSYS. The first became getsockopt(SOL_KACS, KACS_SO_PEER_TOKEN), the third setsockopt(SOL_KACS, KACS_SO_IMPERSONATION_LEVEL), and the second was a fusion of the first with KACS_IOC_IMPERSONATE that now lives in libpeios as peios_token_impersonate_peer.

Edit this page