1.. SPDX-License-Identifier: GPL-2.0 2.. Copyright © 2025 Microsoft Corporation 3.. Copyright © 2026 Cloudflare, Inc. 4 5================================ 6Landlock: system-wide management 7================================ 8 9:Author: Mickaël Salaün 10:Date: October 2026 11 12Landlock can leverage the audit framework to log events. 13 14User space documentation can be found here: 15Documentation/userspace-api/landlock.rst. 16 17Audit 18===== 19 20Denied access requests are logged by default for a sandboxed program if `audit` 21is enabled. This default behavior can be changed with the 22sys_landlock_restrict_self() flags (cf. 23Documentation/userspace-api/landlock.rst), suppressed on a per-object 24basis by using ``LANDLOCK_ADD_RULE_QUIET`` (ABI 10+), or suppressed for 25specific capability or namespace members with the corresponding permission 26rule's ``quiet_*`` field (ABI 12+). Quiet rules only suppress audit submission; 27they do not suppress denial trace events. Landlock logs can also be masked 28thanks to audit rules. Landlock can generate two audit record types. 29 30Record types 31------------ 32 33AUDIT_LANDLOCK_ACCESS 34 This record type identifies a denied access request to a kernel resource. 35 The ``domain`` field indicates the ID of the domain that blocked the 36 request. The ``blockers`` field indicates the cause(s) of this denial 37 (separated by a comma), and the following fields identify the kernel object 38 (similar to SELinux). There may be more than one of this record type per 39 audit event. 40 41 Example with a file link request generating two records in the same event:: 42 43 domain=195ba459b blockers=fs.refer path="/usr/bin" dev="vda2" ino=351 44 domain=195ba459b blockers=fs.make_reg,fs.refer path="/usr/local" dev="vda2" ino=365 45 46 47 The ``blockers`` field uses dot-separated prefixes to indicate the type of 48 restriction that caused the denial: 49 50 **fs.*** - Filesystem access rights (ABI 1+): 51 - fs.execute, fs.write_file, fs.read_file, fs.read_dir 52 - fs.remove_dir, fs.remove_file 53 - fs.make_char, fs.make_dir, fs.make_reg, fs.make_sock 54 - fs.make_fifo, fs.make_block, fs.make_sym 55 - fs.refer (ABI 2+) 56 - fs.truncate (ABI 3+) 57 - fs.ioctl_dev (ABI 5+) 58 - fs.resolve_unix (ABI 9+) 59 60 **net.*** - Network access rights (ABI 4+): 61 - net.bind_tcp - TCP port binding was denied 62 - net.connect_tcp - TCP connection was denied 63 - net.bind_udp - UDP port binding was denied 64 - net.connect_send_udp - UDP connection and send was denied 65 66 **scope.*** - IPC scoping restrictions (ABI 6+): 67 - scope.abstract_unix_socket - Abstract UNIX socket connection denied 68 - scope.signal - Signal sending denied 69 70 **namespace.*** - Namespace restrictions (ABI 12+): 71 - namespace.use - Namespace use was denied (creation via 72 :manpage:`unshare(2)`, :manpage:`clone(2)`, :manpage:`clone3(2)`, 73 :manpage:`open_tree(2)`, or :manpage:`fsmount(2)`, or joining via 74 :manpage:`setns(2)`); 75 ``namespace_type`` indicates the type (hex ``CLONE_NEW*`` bitmask), 76 and ``namespace_id`` identifies the target namespace (for a denied 77 creation, the namespace never becomes reachable so its ID is not 78 directly visible from user space) 79 80 **capability.*** - Capability restrictions (ABI 12+): 81 - capability.use - Capability use was denied; 82 ``capability`` indicates the capability number 83 84 Multiple blockers can appear in a single event (comma-separated) when 85 multiple access rights are missing. For example, creating a regular file 86 in a directory that lacks both ``make_reg`` and ``refer`` rights would show 87 ``blockers=fs.make_reg,fs.refer``. 88 89 The object identification fields depend on the type of access being blocked: 90 ``path``, ``dev``, ``ino`` for filesystem; ``opid``, ``ocomm`` for signals; 91 ``namespace_type`` and ``namespace_id`` for namespace operations; 92 ``capability`` for capability use. 93 94 95AUDIT_LANDLOCK_DOMAIN 96 This record type describes the status of a Landlock domain. The ``status`` 97 field can be either ``allocated`` or ``deallocated``. 98 99 The ``allocated`` status is part of the same audit event and follows 100 the first logged ``AUDIT_LANDLOCK_ACCESS`` record of a domain. It identifies 101 Landlock domain information at the time of the sys_landlock_restrict_self() 102 call with the following fields: 103 104 - the ``domain`` ID 105 - the enforcement ``mode`` 106 - the domain creator's ``pid`` 107 - the domain creator's ``uid`` 108 - the domain creator's executable path (``exe``) 109 - the domain creator's command line (``comm``) 110 111 Example:: 112 113 domain=195ba459b status=allocated mode=enforcing pid=300 uid=0 exe="/root/sandboxer" comm="sandboxer" 114 115 The ``deallocated`` status is an event on its own and it identifies a 116 Landlock domain release. After such event, it is guarantee that the 117 related domain ID will never be reused during the lifetime of the system. 118 The ``domain`` field indicates the ID of the domain which is released, and 119 the ``denials`` field indicates the total number of denied access request, 120 which might not have been logged according to the audit rules and 121 sys_landlock_restrict_self()'s flags. 122 123 Example:: 124 125 domain=195ba459b status=deallocated denials=3 126 127 128Event samples 129-------------- 130 131Here are two examples of log events (see serial numbers). 132 133In this example a sandboxed program (``kill``) tries to send a signal to the 134init process, which is denied because of the signal scoping restriction 135(``LL_SCOPED=s``):: 136 137 $ LL_FS_RO=/ LL_FS_RW=/ LL_SCOPED=s LL_FORCE_LOG=1 ./sandboxer kill 1 138 139This command generates two events, each identified with a unique serial 140number following a timestamp (``msg=audit(1729738800.268:30)``). The first 141event (serial ``30``) contains 4 records. The first record 142(``type=LANDLOCK_ACCESS``) shows an access denied by the domain `1a6fdc66f`. 143The cause of this denial is signal scoping restriction 144(``blockers=scope.signal``). The process that would have receive this signal 145is the init process (``opid=1 ocomm="systemd"``). 146 147The second record (``type=LANDLOCK_DOMAIN``) describes (``status=allocated``) 148domain `1a6fdc66f`. This domain was created by process ``286`` executing the 149``/root/sandboxer`` program launched by the root user. 150 151The third record (``type=SYSCALL``) describes the syscall, its provided 152arguments, its result (``success=no exit=-1``), and the process that called it. 153 154The fourth record (``type=PROCTITLE``) shows the command's name as an 155hexadecimal value. This can be translated with ``python -c 156'print(bytes.fromhex("6B696C6C0031"))'``. 157 158Finally, the last record (``type=LANDLOCK_DOMAIN``) is also the only one from 159the second event (serial ``31``). It is not tied to a direct user space action 160but an asynchronous one to free resources tied to a Landlock domain 161(``status=deallocated``). This can be useful to know that the following logs 162will not concern the domain ``1a6fdc66f`` anymore. This record also summarize 163the number of requests this domain denied (``denials=1``), whether they were 164logged or not. 165 166.. code-block:: 167 168 type=LANDLOCK_ACCESS msg=audit(1729738800.268:30): domain=1a6fdc66f blockers=scope.signal opid=1 ocomm="systemd" 169 type=LANDLOCK_DOMAIN msg=audit(1729738800.268:30): domain=1a6fdc66f status=allocated mode=enforcing pid=286 uid=0 exe="/root/sandboxer" comm="sandboxer" 170 type=SYSCALL msg=audit(1729738800.268:30): arch=c000003e syscall=62 success=no exit=-1 [..] ppid=272 pid=286 auid=0 uid=0 gid=0 [...] comm="kill" [...] 171 type=PROCTITLE msg=audit(1729738800.268:30): proctitle=6B696C6C0031 172 type=LANDLOCK_DOMAIN msg=audit(1729738800.324:31): domain=1a6fdc66f status=deallocated denials=1 173 174Here is another example showcasing filesystem access control:: 175 176 $ LL_FS_RO=/ LL_FS_RW=/tmp LL_FORCE_LOG=1 ./sandboxer sh -c "echo > /etc/passwd" 177 178The related audit logs contains 8 records from 3 different events (serials 33, 17934 and 35) created by the same domain `1a6fdc679`:: 180 181 type=LANDLOCK_ACCESS msg=audit(1729738800.221:33): domain=1a6fdc679 blockers=fs.write_file path="/dev/tty" dev="devtmpfs" ino=9 182 type=LANDLOCK_DOMAIN msg=audit(1729738800.221:33): domain=1a6fdc679 status=allocated mode=enforcing pid=289 uid=0 exe="/root/sandboxer" comm="sandboxer" 183 type=SYSCALL msg=audit(1729738800.221:33): arch=c000003e syscall=257 success=no exit=-13 [...] ppid=272 pid=289 auid=0 uid=0 gid=0 [...] comm="sh" [...] 184 type=PROCTITLE msg=audit(1729738800.221:33): proctitle=7368002D63006563686F203E202F6574632F706173737764 185 type=LANDLOCK_ACCESS msg=audit(1729738800.221:34): domain=1a6fdc679 blockers=fs.write_file path="/etc/passwd" dev="vda2" ino=143821 186 type=SYSCALL msg=audit(1729738800.221:34): arch=c000003e syscall=257 success=no exit=-13 [...] ppid=272 pid=289 auid=0 uid=0 gid=0 [...] comm="sh" [...] 187 type=PROCTITLE msg=audit(1729738800.221:34): proctitle=7368002D63006563686F203E202F6574632F706173737764 188 type=LANDLOCK_DOMAIN msg=audit(1729738800.261:35): domain=1a6fdc679 status=deallocated denials=2 189 190 191Event filtering 192--------------- 193 194If you get spammed with audit logs related to Landlock, this is either an 195attack attempt or a bug in the security policy. We can put in place some 196filters to limit noise with two complementary ways: 197 198- with sys_landlock_restrict_self()'s flags, 199 ``LANDLOCK_ADD_RULE_QUIET`` (ABI 10+), or the permission rules' 200 per-member ``quiet_*`` fields (ABI 12+) if we can fix the sandboxed 201 programs, 202- or with audit rules (see :manpage:`auditctl(8)`). 203 204Tracepoints 205=========== 206 207Landlock also provides tracepoints as an alternative to audit for 208debugging and observability. Tracepoints fire unconditionally, 209independent of audit configuration, ``audit_enabled``, and domain log 210flags. This makes them suitable for always-on monitoring with eBPF or 211for ad-hoc debugging with ``trace-pipe``. 212 213See Documentation/trace/events-landlock.rst for the complete event 214reference: the full event list, how to enable events and read their 215output, the field formats, the ``check_rule`` interpretation guide, 216worked event samples, ftrace filtering, and eBPF access. 217 218.. _landlock_observability: 219 220When to use tracing vs audit 221----------------------------- 222 223Audit and tracing both help diagnose Landlock policy issues: 224 225**Audit** records denied accesses with the blockers, domain, and object 226identification (path, port). Audit is the standard Linux mechanism for 227security events, with a stable record format that is well established 228and already supported by log management systems, SIEM platforms, and EDR 229solutions. Audit is always active when the kernel is built with audit 230support, filtered by the Landlock log flags to reduce noise in 231production, and designed for long-term security monitoring and 232compliance. 233 234**Tracing** provides deeper introspection for policy debugging. In 235addition to denied accesses, trace events cover the complete lifecycle 236of Landlock objects (rulesets, domains) and intermediate rule matching 237during access checks. Trace events are disabled by default (zero 238overhead) and fire unconditionally. eBPF 239programs attached to trace events can access the full kernel context 240(ruleset rules, domain hierarchy, process credentials) via BTF, enabling 241richer analysis than the flat fields in audit records. For example, an 242eBPF-based live monitoring tool can correlate creation, rule-addition, 243and denial events to build a real-time view of all active Landlock 244domains and their policies. However, BTF-based access depends on 245internal kernel struct layouts which have no stability guarantee. CO-RE 246(Compile Once, Run Everywhere) provides best-effort field relocation. 247The ftrace printk format is also not a stable ABI, but is 248self-describing via the per-event ``format`` file, allowing tools to 249adapt dynamically. 250 251Observability guarantees and limitations 252----------------------------------------- 253 254Both audit records and trace events are emitted for every denied access, 255with these exceptions: 256 257- **Landlock log flags** (audit only): ``LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF``, 258 ``LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON``, and 259 ``LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF`` control which denials 260 generate audit records. Trace events fire regardless of these flags. 261 262- **NOAUDIT hooks**: Some LSM hooks suppress logging for speculative 263 permission probes (e.g., reading ``/proc/<pid>/status`` uses 264 ``PTRACE_MODE_NOAUDIT``, and :manpage:`listxattr(2)` probes 265 ``CAP_SYS_ADMIN`` with ``CAP_OPT_NOAUDIT`` to decide whether to list 266 ``trusted.*`` extended attributes). When NOAUDIT is set, neither audit 267 records nor trace events are emitted, and the denial is not counted in 268 ``denials``. The denial is still enforced. This avoids performance 269 overhead and noise from speculative probes that test permissions 270 without performing an actual access. 271 272- **Audit rate limiting**: The audit subsystem may silently drop records 273 when the audit queue is full. Trace events are not rate-limited. 274 275- **Tracepoint disabled**: When a trace event is disabled (the default 276 state), the tracepoint is a no-op with zero overhead. 277 278When both audit and tracing are active, every denial emits a trace event, 279and a denial that the domain's log policy selects additionally produces an 280audit record (subject to the Landlock log flags). The ``denials`` count in 281``free_domain`` events is incremented for every denial regardless of the 282log flags, so it can exceed the number of audit records (which the log 283flags and audit-side rate-limiting or exclude rules may suppress). 284 285.. _landlock_observability_security: 286 287Observability security considerations 288--------------------------------------- 289 290Both audit records and trace events expose information about all 291Landlock-sandboxed processes on the system, including filesystem paths 292being accessed, network ports, capability numbers, namespace types and IDs, 293and process identities. System 294administrators must ensure that access to audit logs (controlled by the 295audit subsystem configuration) and to trace events (requiring 296``CAP_SYS_ADMIN`` or ``CAP_BPF`` + ``CAP_PERFMON``) is restricted to 297trusted users. 298 299eBPF programs attached to Landlock trace events have access to the full 300kernel context of each event (ruleset rules, domain hierarchy, process 301credentials) via BTF, exposing sensitive state about every sandboxed 302process. Restrict this access to trusted users, as for the audit logs. 303 304Audit logs and kernel trace events require elevated privileges and are 305system-wide; they are not designed for per-sandbox unprivileged 306monitoring. 307 308Additional documentation 309======================== 310 311* `Linux Audit Documentation`_ 312* Documentation/userspace-api/landlock.rst 313* Documentation/trace/events-landlock.rst 314* Documentation/security/landlock.rst 315* https://landlock.io 316 317.. Links 318.. _Linux Audit Documentation: 319 https://github.com/linux-audit/audit-documentation/wiki 320