1.. SPDX-License-Identifier: GPL-2.0 2.. Copyright © 2025 Microsoft Corporation 3 4================================ 5Landlock: system-wide management 6================================ 7 8:Author: Mickaël Salaün 9:Date: January 2026 10 11Landlock can leverage the audit framework to log events. 12 13User space documentation can be found here: 14Documentation/userspace-api/landlock.rst. 15 16Audit 17===== 18 19Denied access requests are logged by default for a sandboxed program if `audit` 20is enabled. This default behavior can be changed with the 21sys_landlock_restrict_self() flags (cf. 22Documentation/userspace-api/landlock.rst). Landlock logs can also be masked 23thanks to audit rules. Landlock can generate 2 audit record types. 24 25Record types 26------------ 27 28AUDIT_LANDLOCK_ACCESS 29 This record type identifies a denied access request to a kernel resource. 30 The ``domain`` field indicates the ID of the domain that blocked the 31 request. The ``blockers`` field indicates the cause(s) of this denial 32 (separated by a comma), and the following fields identify the kernel object 33 (similar to SELinux). There may be more than one of this record type per 34 audit event. 35 36 Example with a file link request generating two records in the same event:: 37 38 domain=195ba459b blockers=fs.refer path="/usr/bin" dev="vda2" ino=351 39 domain=195ba459b blockers=fs.make_reg,fs.refer path="/usr/local" dev="vda2" ino=365 40 41 42 The ``blockers`` field uses dot-separated prefixes to indicate the type of 43 restriction that caused the denial: 44 45 **fs.*** - Filesystem access rights (ABI 1+): 46 - fs.execute, fs.write_file, fs.read_file, fs.read_dir 47 - fs.remove_dir, fs.remove_file 48 - fs.make_char, fs.make_dir, fs.make_reg, fs.make_sock 49 - fs.make_fifo, fs.make_block, fs.make_sym 50 - fs.refer (ABI 2+) 51 - fs.truncate (ABI 3+) 52 - fs.ioctl_dev (ABI 5+) 53 54 **net.*** - Network access rights (ABI 4+): 55 - net.bind_tcp - TCP port binding was denied 56 - net.connect_tcp - TCP connection was denied 57 58 **scope.*** - IPC scoping restrictions (ABI 6+): 59 - scope.abstract_unix_socket - Abstract UNIX socket connection denied 60 - scope.signal - Signal sending denied 61 62 Multiple blockers can appear in a single event (comma-separated) when 63 multiple access rights are missing. For example, creating a regular file 64 in a directory that lacks both ``make_reg`` and ``refer`` rights would show 65 ``blockers=fs.make_reg,fs.refer``. 66 67 The object identification fields (path, dev, ino for filesystem; opid, 68 ocomm for signals) depend on the type of access being blocked and provide 69 context about what resource was involved in the denial. 70 71 72AUDIT_LANDLOCK_DOMAIN 73 This record type describes the status of a Landlock domain. The ``status`` 74 field can be either ``allocated`` or ``deallocated``. 75 76 The ``allocated`` status is part of the same audit event and follows 77 the first logged ``AUDIT_LANDLOCK_ACCESS`` record of a domain. It identifies 78 Landlock domain information at the time of the sys_landlock_restrict_self() 79 call with the following fields: 80 81 - the ``domain`` ID 82 - the enforcement ``mode`` 83 - the domain creator's ``pid`` 84 - the domain creator's ``uid`` 85 - the domain creator's executable path (``exe``) 86 - the domain creator's command line (``comm``) 87 88 Example:: 89 90 domain=195ba459b status=allocated mode=enforcing pid=300 uid=0 exe="/root/sandboxer" comm="sandboxer" 91 92 The ``deallocated`` status is an event on its own and it identifies a 93 Landlock domain release. After such event, it is guarantee that the 94 related domain ID will never be reused during the lifetime of the system. 95 The ``domain`` field indicates the ID of the domain which is released, and 96 the ``denials`` field indicates the total number of denied access request, 97 which might not have been logged according to the audit rules and 98 sys_landlock_restrict_self()'s flags. 99 100 Example:: 101 102 domain=195ba459b status=deallocated denials=3 103 104 105Event samples 106-------------- 107 108Here are two examples of log events (see serial numbers). 109 110In this example a sandboxed program (``kill``) tries to send a signal to the 111init process, which is denied because of the signal scoping restriction 112(``LL_SCOPED=s``):: 113 114 $ LL_FS_RO=/ LL_FS_RW=/ LL_SCOPED=s LL_FORCE_LOG=1 ./sandboxer kill 1 115 116This command generates two events, each identified with a unique serial 117number following a timestamp (``msg=audit(1729738800.268:30)``). The first 118event (serial ``30``) contains 4 records. The first record 119(``type=LANDLOCK_ACCESS``) shows an access denied by the domain `1a6fdc66f`. 120The cause of this denial is signal scoping restriction 121(``blockers=scope.signal``). The process that would have receive this signal 122is the init process (``opid=1 ocomm="systemd"``). 123 124The second record (``type=LANDLOCK_DOMAIN``) describes (``status=allocated``) 125domain `1a6fdc66f`. This domain was created by process ``286`` executing the 126``/root/sandboxer`` program launched by the root user. 127 128The third record (``type=SYSCALL``) describes the syscall, its provided 129arguments, its result (``success=no exit=-1``), and the process that called it. 130 131The fourth record (``type=PROCTITLE``) shows the command's name as an 132hexadecimal value. This can be translated with ``python -c 133'print(bytes.fromhex("6B696C6C0031"))'``. 134 135Finally, the last record (``type=LANDLOCK_DOMAIN``) is also the only one from 136the second event (serial ``31``). It is not tied to a direct user space action 137but an asynchronous one to free resources tied to a Landlock domain 138(``status=deallocated``). This can be useful to know that the following logs 139will not concern the domain ``1a6fdc66f`` anymore. This record also summarize 140the number of requests this domain denied (``denials=1``), whether they were 141logged or not. 142 143.. code-block:: 144 145 type=LANDLOCK_ACCESS msg=audit(1729738800.268:30): domain=1a6fdc66f blockers=scope.signal opid=1 ocomm="systemd" 146 type=LANDLOCK_DOMAIN msg=audit(1729738800.268:30): domain=1a6fdc66f status=allocated mode=enforcing pid=286 uid=0 exe="/root/sandboxer" comm="sandboxer" 147 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" [...] 148 type=PROCTITLE msg=audit(1729738800.268:30): proctitle=6B696C6C0031 149 type=LANDLOCK_DOMAIN msg=audit(1729738800.324:31): domain=1a6fdc66f status=deallocated denials=1 150 151Here is another example showcasing filesystem access control:: 152 153 $ LL_FS_RO=/ LL_FS_RW=/tmp LL_FORCE_LOG=1 ./sandboxer sh -c "echo > /etc/passwd" 154 155The related audit logs contains 8 records from 3 different events (serials 33, 15634 and 35) created by the same domain `1a6fdc679`:: 157 158 type=LANDLOCK_ACCESS msg=audit(1729738800.221:33): domain=1a6fdc679 blockers=fs.write_file path="/dev/tty" dev="devtmpfs" ino=9 159 type=LANDLOCK_DOMAIN msg=audit(1729738800.221:33): domain=1a6fdc679 status=allocated mode=enforcing pid=289 uid=0 exe="/root/sandboxer" comm="sandboxer" 160 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" [...] 161 type=PROCTITLE msg=audit(1729738800.221:33): proctitle=7368002D63006563686F203E202F6574632F706173737764 162 type=LANDLOCK_ACCESS msg=audit(1729738800.221:34): domain=1a6fdc679 blockers=fs.write_file path="/etc/passwd" dev="vda2" ino=143821 163 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" [...] 164 type=PROCTITLE msg=audit(1729738800.221:34): proctitle=7368002D63006563686F203E202F6574632F706173737764 165 type=LANDLOCK_DOMAIN msg=audit(1729738800.261:35): domain=1a6fdc679 status=deallocated denials=2 166 167 168Event filtering 169--------------- 170 171If you get spammed with audit logs related to Landlock, this is either an 172attack attempt or a bug in the security policy. We can put in place some 173filters to limit noise with two complementary ways: 174 175- with sys_landlock_restrict_self()'s flags if we can fix the sandboxed 176 programs, 177- or with audit rules (see :manpage:`auditctl(8)`). 178 179Additional documentation 180======================== 181 182* `Linux Audit Documentation`_ 183* Documentation/userspace-api/landlock.rst 184* Documentation/security/landlock.rst 185* https://landlock.io 186 187.. Links 188.. _Linux Audit Documentation: 189 https://github.com/linux-audit/audit-documentation/wiki 190