Landlock(7)
๐ Landlock(7) ๐
okay so you found the Landlock(7) page, it lives in the Miscellaneous Information Manual, and bestie, it's literally one of the coolest things Linux ever did. grab a snack. ๐
โจ NAME โจ
Landlock โ unprivileged access-control. that's it. that's the whole vibe. ๐ซถ
๐ธ DESCRIPTION ๐ธ
Landlock is an access-control system that lets any process securely restrict itself and its future children. no root, no special powers, no asking permission from anybody. it's giving main character energy but for security. ๐
Because Landlock is a stackable Linux Security Module (LSM), it can create safe security sandboxes as brand-new security layers on top of whatever system-wide access-controls already exist. stacking layers, no drama, no conflicts. ๐
and what's the point of all this adorable sandboxing? it helps mitigate the security impact of bugs, plus any unexpected or malicious behaviors in applications. your fave app does something goofy โ Landlock catches it. periodt.
so a Landlock security policy is just a set of access rights (like: open a file read-only, make a directory, etc.) that's tied to a file hierarchy. and you configure and enforce that policy on yourself with three system calls:
landlock_create_ruleset(2)โ creates a new ruleset โจlandlock_add_rule(2)โ adds a new rule to a ruleset โจlandlock_restrict_self(2)โ enforces a ruleset on the calling thread โจ
lowkey important: to use these system calls, the running kernel has to actually support Landlock, and it must be enabled at boot time. no boot-time enable, no Landlock, no exceptions. ๐
๐ Landlock rules
A Landlock rule describes an action on an object that the process intends to perform. a bunch of rules get aggregated into a ruleset, and that ruleset can then restrict the thread enforcing it and its future children. generational restriction, cute. ๐ง
the two existing types of rules are:
Filesystem rules : For these rules, the object is a file hierarchy, and the related filesystem actions are defined with filesystem access rights.
Network rules (since ABI v4) : For these rules, the object is a TCP port, and the related actions are defined with network access rights.
๐ Filesystem actions
these flags let you restrict a sandboxed process to a set of actions on files and directories. quick heads-up bestie: files or directories opened before the sandboxing are not subject to these restrictions. you can't retroactively ground them. ๐
see landlock_add_rule(2) and landlock_create_ruleset(2) for more context.
the following access rights apply only to files:
LANDLOCK_ACCESS_FS_EXECUTEโ execute a file.LANDLOCK_ACCESS_FS_WRITE_FILEโ open a file with write access. when opening files for writing, you'll often additionally need theLANDLOCK_ACCESS_FS_TRUNCATEright too. in many cases, these system calls truncate existing files when overwriting them (e.g.,creat(2)). so yeah, it's a two-flag situation. slay responsibly.LANDLOCK_ACCESS_FS_READ_FILEโ open a file with read access.LANDLOCK_ACCESS_FS_TRUNCATE(since Landlock ABI version 3) โ truncate a file withtruncate(2),ftruncate(2),creat(2), oropen(2)withO_TRUNC.LANDLOCK_ACCESS_FS_IOCTL_DEV(since Landlock ABI version 5) โ invokeioctl(2)commands on an opened character or block device.
this access right applies to all ioctl(2) commands implemented by device drivers. however, the following common IOCTL commands continue to be invokable independent of the LANDLOCK_ACCESS_FS_IOCTL_DEV right. they get a permanent hall pass:
- IOCTL commands targeting file descriptors (
FIOCLEX,FIONCLEX) - IOCTL commands targeting file descriptions (
FIONBIO,FIOASYNC) - IOCTL commands targeting file systems (
FIFREEZE,FITHAW,FIGETBSZ,FS_IOC_GETFSUUID,FS_IOC_GETFSSYSFSPATH) - some IOCTL commands which do not make sense when used with devices, but whose implementations are safe and return the right error codes (
FS_IOC_FIEMAP,FICLONE,FICLONERANGE,FIDEDUPERANGE)
LANDLOCK_ACCESS_FS_RESOLVE_UNIX(since Landlock ABI version 9) โ look up pathname UNIX domain sockets (unix(7)). on UNIX domain sockets, this restricts both calls toconnect(2)andsendmsg(2)with an explicit recipient address.
this access right applies only to connections to UNIX server sockets which were created outside the newly created Landlock domain (e.g., from within a parent domain or from an unrestricted process). newly created UNIX servers within the same Landlock domain continue to be accessible. in this regard, LANDLOCK_ACCESS_FS_RESOLVE_UNIX has the same semantics as the LANDLOCK_SCOPE_* flags. iykyk. ๐
if a resolution attempt is denied, the operation returns an EACCES error, in line with other filesystem access rights (but different to denials for abstract UNIX domain sockets).
okay so whether an opened file can be truncated with ftruncate(2) or used with ioctl(2) is determined during open(2) โ in the same way as read and write permissions are checked during open(2) using LANDLOCK_ACCESS_FS_READ_FILE and LANDLOCK_ACCESS_FS_WRITE_FILE. one vibe check at open time, and that's your answer. โญ
a directory can receive access rights related to files or directories. the following access right is applied to the directory itself, and the directories beneath it:
LANDLOCK_ACCESS_FS_READ_DIRโ open a directory or list its content. ๐
however, the following access rights only apply to the content of a directory, not the directory itself:
LANDLOCK_ACCESS_FS_REMOVE_DIRโ remove an empty directory or rename one.LANDLOCK_ACCESS_FS_REMOVE_FILEโ unlink (or rename) a file.LANDLOCK_ACCESS_FS_MAKE_CHARโ create (or rename or link) a character device.LANDLOCK_ACCESS_FS_MAKE_DIRโ create (or rename) a directory.LANDLOCK_ACCESS_FS_MAKE_REGโ create (or rename or link) a regular file.LANDLOCK_ACCESS_FS_MAKE_SOCKโ create (or rename or link) a UNIX domain socket.LANDLOCK_ACCESS_FS_MAKE_FIFOโ create (or rename or link) a named pipe.LANDLOCK_ACCESS_FS_MAKE_BLOCKโ create (or rename or link) a block device.LANDLOCK_ACCESS_FS_MAKE_SYMโ create (or rename or link) a symbolic link.LANDLOCK_ACCESS_FS_REFER(since Landlock ABI version 2) โ link or rename a file from or to a different directory (i.e., reparent a file hierarchy).
๐จ bestie this one is the specialest one. this is the only access right which is denied by default by any ruleset, even if the right is not specified as handled at ruleset creation time. the only way to make a ruleset grant this right is to explicitly allow it for a specific directory by adding a matching rule to the ruleset. no accidental reparenting in this house.
in particular, when using Landlock ABI version 1, Landlock will always deny attempts to reparent files between different directories.
in addition to the source and destination directories having the LANDLOCK_ACCESS_FS_REFER access right, the attempted link or rename operation must meet the following constraints:
- the reparented file may not gain more access rights in the destination directory than it previously had in the source directory. if this is attempted, the operation results in an
EXDEVerror. - when linking or renaming, the
LANDLOCK_ACCESS_FS_MAKE_*right for the respective file type must be granted for the destination directory. otherwise, the operation results in anEACCESerror. - when renaming, the
LANDLOCK_ACCESS_FS_REMOVE_*right for the respective file type must be granted for the source directory. otherwise, the operation results in anEACCESerror.
and if multiple requirements are not met, the EACCES error code takes precedence over EXDEV. priority order = EACCES first, always. ๐ฅ
๐ Network flags
these flags let you restrict a sandboxed process to a set of network actions.
the following access rights apply to TCP port numbers:
LANDLOCK_ACCESS_NET_BIND_TCP(since Landlock ABI version 4) โ bind a TCP socket to a local port.LANDLOCK_ACCESS_NET_CONNECT_TCP(since Landlock ABI version 4) โ connect an active TCP socket to a remote port.
๐ฎ Scope flags
these flags let you isolate a sandboxed process from a set of IPC actions. setting a flag for a ruleset will isolate the Landlock domain to forbid connections to resources outside the domain. it's giving "we don't know them anymore". ๐
the following scopes exist:
LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET(since Landlock ABI version 6) โ restrict a sandboxed process from connecting to an abstract UNIX socket created by a process outside the related Landlock domain (e.g., a parent domain or a non-sandboxed process).LANDLOCK_SCOPE_SIGNAL(since Landlock ABI version 6) โ restrict a sandboxed process from sending a signal to another process outside the domain.
๐ง Layers of file path access rights
every single time a thread enforces a ruleset on itself, it updates its Landlock domain with a new layer of policy. this complementary policy gets stacked with any other rulesets potentially already restricting this thread. meaning: a sandboxed thread can safely add more constraints to itself with a new enforced ruleset. you can keep adding layers, it's fine, it's encouraged. layering is iconic. ๐
so how does access get decided? one policy layer grants access to a file path if at least one of its rules encountered on the path grants the access. and a sandboxed thread can only access a file path if all its enforced policy layers grant the access as well as all the other system access controls (e.g., filesystem DAC, other LSM policies, etc.). everybody has to agree. unanimous vote or nothing. โญ
๐ Bind mounts and OverlayFS
Landlock enables restricting access to file hierarchies โ which means these access rights can be propagated with bind mounts (cf. mount_namespaces(7)) but not with OverlayFS. we stan bind mounts. OverlayFS, we love you but you play different rules. ๐ญ
a bind mount mirrors a source file hierarchy to a destination. the destination hierarchy is then composed of the exact same files, on which Landlock rules can be tied, either via the source or the destination path. these rules restrict access when they are encountered on a path, which means they can restrict access to multiple file hierarchies at the same time, whether these hierarchies are the result of bind mounts or not. one rule, many hierarchies. efficient queen. ๐
an OverlayFS mount point consists of upper and lower layers. these layers are combined in a merge directory, result of the mount point. this merge hierarchy may include files from the upper and lower layers, but modifications performed on the merge hierarchy only reflect on the upper layer. from a Landlock policy point of view, each of the OverlayFS layers and merge hierarchies is standalone and contains its own set of files and directories โ which is different from a bind mount. a policy restricting an OverlayFS layer will not restrict the resulted merged hierarchy, and vice versa. ๐จ
so the takeaway for Landlock users: only think about the file hierarchies you want to allow access to, regardless of the underlying filesystem. don't overthink the mount situation, bestie. think about paths. ๐ฆ
to be continuedโฆ ๐ (yes there's more, stay with me)
๐งฌ Inheritance ๐งฌ
okay so picture the family tree: every new thread that pops into existence from clone(2) inherits its parent's Landlock domain restrictions. it's giving seccomp(2) inheritance energy, or literally any other LSM out here dealing with tasks' credentials(7). so like, one process's thread can apply Landlock rules to itself, but those rules will not automatically get applied to its sibling threads โ that's different from POSIX thread credential changes, cf. nptl(7), don't get it twisted bestie.
and here's the part that actually ate: when a thread sandboxes itself, we have the guarantee that the related security policy stays enforced on all of this thread's descendants. which means you can build standalone, modular security policies per application, and they'll automatically compose between themselves according to their run-time parent policies. beautiful. no notes. ๐
๐ต๏ธโ๏ธ Ptrace restrictions ๐ต๏ธโ๏ธ
obviously a sandboxed process has less privileges than a non-sandboxed one, which means it has to be subject to additional restrictions when it starts manipulating another process. so if a sandboxed process wants to use ptrace(2) and related syscalls on a target process, the sandboxed process should have a subset of the target process rules. translation? the tracee has to be in a sub-domain of the tracer. that's the whole rule. iykyk. ๐ซถ
๐ก IPC scoping ๐ก
similar to those implicit Ptrace restrictions, sometimes we wanna further restrict interactions between sandboxes. so, at ruleset creation time, each Landlock domain can restrict the scope for certain operations, so that these operations can only reach out to processes within the same Landlock domain or in a nested Landlock domain. that's the "scope". โจ
the operations which can be scoped are:
LANDLOCK_SCOPE_SIGNALโ this limits the sending of signals to target processes which run within the same or a nested Landlock domain.LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKETโ this limits the set of abstractunix(7)sockets to which we canconnect(2)to socket addresses which were created by a process in the same or a nested Landlock domain.
a sendto(2) on a non-connected datagram socket is treated as if it were doing an implicit connect(2) and will be blocked if the remote end does not stem from the same or a nested Landlock domain.
a sendto(2) on a socket which was previously connected will not be restricted. this works for both datagram and stream sockets.
heads up bestie: IPC scoping does not support exceptions via landlock_add_rule(2). if an operation is scoped within a domain, no rules can be added to allow access to resources or processes outside of the scope. no loopholes, periodt.
โ๏ธ Truncating files โ๏ธ
listen, the operations covered by LANDLOCK_ACCESS_FS_WRITE_FILE and LANDLOCK_ACCESS_FS_TRUNCATE both change the contents of a file, and sometimes they overlap in ways that are genuinely non-intuitive. so please, always specify both of these together. save yourself the confusion. ๐
a particularly surprising example is creat(2). the name suggests that this system call requires the rights to create and write files. however, it also requires the truncate right if an existing file under the same name is already present. the name is lying to you, lowkey.
also should be noted: truncating files does not require the LANDLOCK_ACCESS_FS_WRITE_FILE right. apart from the truncate(2) system call, this can also be done through open(2) with the flags O_RDONLY | O_TRUNC. yes really.
when opening a file, the availability of the LANDLOCK_ACCESS_FS_TRUNCATE right is associated with the newly created file descriptor and will be used for subsequent truncation attempts using ftruncate(2). the behavior is similar to opening a file for reading or writing, where permissions are checked during open(2), but not during the subsequent read(2) and write(2) calls.
as a consequence, it is possible to have multiple open file descriptors for the same file, where one grants the right to truncate the file and the other does not. it is also possible to pass such file descriptors between processes, keeping their Landlock properties, even when these processes do not have an enforced Landlock ruleset. icon behavior, honestly. ๐
๐คซ Quiet rule flag ๐คซ
starting with the Landlock ABI version 10, it is possible to selectively suppress logs for specific denied accesses on a per-object basis with the LANDLOCK_ADD_RULE_QUIET flag of landlock_add_rule(2), in combination with the quiet_access_fs and quiet_access_net fields of struct landlock_ruleset_attr. it is also now possible to suppress logs for scope accesses via the quiet_scoped field of struct landlock_ruleset_attr.
the object is marked as quiet within a ruleset when at least one landlock_add_rule(2) call is made for it with the LANDLOCK_ADD_RULE_QUIET flag. additional add-rule calls for the same object without this flag do not clear it. once it's quiet, it's quiet. ๐ค
๐ VERSIONS ๐
Landlock was introduced in Linux 5.13. baby's first release.
to determine which Landlock features are available, users should query the Landlock ABI version. here's the whole glow-up timeline:
- ABI
1โ kernel 5.13. newly introduced constants:LANDLOCK_ACCESS_FS_EXECUTELANDLOCK_ACCESS_FS_WRITE_FILELANDLOCK_ACCESS_FS_READ_FILELANDLOCK_ACCESS_FS_READ_DIRLANDLOCK_ACCESS_FS_REMOVE_DIRLANDLOCK_ACCESS_FS_REMOVE_FILELANDLOCK_ACCESS_FS_MAKE_CHARLANDLOCK_ACCESS_FS_MAKE_DIRLANDLOCK_ACCESS_FS_MAKE_REGLANDLOCK_ACCESS_FS_MAKE_SOCKLANDLOCK_ACCESS_FS_MAKE_FIFOLANDLOCK_ACCESS_FS_MAKE_BLOCKLANDLOCK_ACCESS_FS_MAKE_SYM
- ABI
2โ kernel 5.19. newly introduced:LANDLOCK_ACCESS_FS_REFER - ABI
3โ kernel 6.2. newly introduced:LANDLOCK_ACCESS_FS_TRUNCATE - ABI
4โ kernel 6.7. newly introduced:LANDLOCK_ACCESS_NET_BIND_TCP,LANDLOCK_ACCESS_NET_CONNECT_TCP - ABI
5โ kernel 6.10. newly introduced:LANDLOCK_ACCESS_FS_IOCTL_DEV - ABI
6โ kernel 6.12. newly introduced:LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET,LANDLOCK_SCOPE_SIGNAL - ABI
7โ kernel 6.15. newly introduced:LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF,LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON,LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF - ABI
8โ kernel 7.0. newly introduced:LANDLOCK_RESTRICT_SELF_TSYNC - ABI
9โ kernel 7.1. newly introduced:LANDLOCK_ACCESS_FS_RESOLVE_UNIX - ABI
10โ kernel 7.2. newly introduced:LANDLOCK_ADD_RULE_QUIET
bestie, listen: users should use the Landlock ABI version rather than the kernel version to determine which features are available. the mainline kernel versions listed here are only included for orientation. kernels from other sources may contain backported features, and their version numbers may not match. do not trust the number on the box, trust the ABI. ๐
to query the running kernel's Landlock ABI version, programs may pass the LANDLOCK_CREATE_RULESET_VERSION flag to landlock_create_ruleset(2).
when building fallback mechanisms for compatibility with older kernels, users are advised to consider the special semantics of the LANDLOCK_ACCESS_FS_REFER access right: in ABI v1, linking and moving of files between different directories is always forbidden, so programs relying on such operations are only compatible with Landlock ABI v2 and higher. plan accordingly. ๐ง
๐ NOTES ๐
Landlock is enabled by CONFIG_SECURITY_LANDLOCK. the lsm=lsm1,...,lsmN command line parameter controls the sequence of the initialization of Linux Security Modules. it must contain the string landlock to enable Landlock. if the command line parameter is not specified, the initialization falls back to the value of the deprecated security= command line parameter and further to the value of CONFIG_LSM.
and we can check that Landlock is enabled by looking for:
landlock: Up and running.
in kernel logs. that's the little sparkle that means it worked. โญ
๐ CAVEATS ๐
okay bestie, listen up, because this is the part where I have to break some bad news ๐ญ
Right now, Landlock can't restrict some file-related actions that you can still reach through these system call families: chdir(2), stat(2), flock(2), chmod(2), chown(2), setxattr(2), utime(2), fcntl(2), access(2).
Future Landlock evolutions will enable to restrict them. So likeโฆ the glow-up is coming, it's just not here yet โจ
no cap, if you were hoping Landlock would lock down chmod(2) for you today, it simply does not, and you need to know that going in ๐ซถ
๐ธ EXAMPLES ๐ธ
okay so here's the whole thing end to end, and honestly? it's giving tutorial energy in the best way ๐
๐ making the ruleset
First we need to create the ruleset that will contain our rules.
For this example, the ruleset will contain rules that only allow read actions, but write actions will be denied. The ruleset then needs to handle both of these kinds of actions. See the DESCRIPTION section for the description of filesystem actions.
struct landlock_ruleset_attr attr = {0};
int ruleset_fd;
attr.handled_access_fs =
LANDLOCK_ACCESS_FS_EXECUTE |
LANDLOCK_ACCESS_FS_WRITE_FILE |
LANDLOCK_ACCESS_FS_READ_FILE |
LANDLOCK_ACCESS_FS_READ_DIR |
LANDLOCK_ACCESS_FS_REMOVE_DIR |
LANDLOCK_ACCESS_FS_REMOVE_FILE |
LANDLOCK_ACCESS_FS_MAKE_CHAR |
LANDLOCK_ACCESS_FS_MAKE_DIR |
LANDLOCK_ACCESS_FS_MAKE_REG |
LANDLOCK_ACCESS_FS_MAKE_SOCK |
LANDLOCK_ACCESS_FS_MAKE_FIFO |
LANDLOCK_ACCESS_FS_MAKE_BLOCK |
LANDLOCK_ACCESS_FS_MAKE_SYM |
LANDLOCK_ACCESS_FS_REFER |
LANDLOCK_ACCESS_FS_TRUNCATE |
LANDLOCK_ACCESS_FS_IOCTL_DEV |
LANDLOCK_ACCESS_FS_RESOLVE_UNIX;
๐ฆ the backwards-compat part (iykyk)
To be compatible with older Linux versions, we detect the available Landlock ABI version, and only use the available subset of access rights:
/*
* Table of available file system access rights by ABI version,
* numbers hardcoded to keep the example short.
*/
__u64 landlock_fs_access_rights[] = {
(LANDLOCK_ACCESS_FS_MAKE_SYM << 1) - 1, // v1
(LANDLOCK_ACCESS_FS_REFER << 1) - 1, // v2: add "refer"
(LANDLOCK_ACCESS_FS_TRUNCATE << 1) - 1, // v3: add "truncate"
(LANDLOCK_ACCESS_FS_TRUNCATE << 1) - 1, // v4: TCP support
(LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) - 1, // v5: add "ioctl_dev"
(LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) - 1, // v6: same
(LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) - 1, // v7: same
(LANDLOCK_ACCESS_FS_IOCTL_DEV << 1) - 1, // v8: same
(LANDLOCK_ACCESS_FS_RESOLVE_UNIX << 1) - 1, // v9: add "resolve_unix"
(LANDLOCK_ACCESS_FS_RESOLVE_UNIX << 1) - 1, // v10: same
};
int abi = landlock_create_ruleset(NULL, 0,
LANDLOCK_CREATE_RULESET_VERSION);
if (abi == -1) {
/*
* Kernel too old, not compiled with Landlock,
* or Landlock was not enabled at boot time.
*/
perror("Unable to use Landlock");
return; /* Graceful fallback: Do nothing. */
}
abi = MIN(abi, 10);
/* Only use the available rights in the ruleset. */
attr.handled_access_fs &= landlock_fs_access_rights[abi - 1];
The available access rights for each ABI version are listed in the VERSIONS section.
If our program needed to create hard links or rename files between different directories (LANDLOCK_ACCESS_FS_REFER), we would require the following change to the backwards compatibility logic: Directory reparenting is not possible in a process restricted with Landlock ABI version 1. Therefore, if the program needed to do file reparenting, and if only Landlock ABI version 1 was available, we could not restrict the process.
like, that's a whole situation ๐ญ if you need reparenting and all you've got is ABI v1, girl you cannot restrict this process, that's just the truth
โจ creating the actual ruleset
Now that the ruleset attributes are determined, we create the Landlock ruleset and acquire a file descriptor as a handle to it, using landlock_create_ruleset(2):
ruleset_fd = landlock_create_ruleset(&attr, sizeof(attr), 0);
if (ruleset_fd == -1) {
perror("Failed to create a ruleset");
exit(EXIT_FAILURE);
}
๐ adding a rule
We can now add a new rule to the ruleset through the ruleset's file descriptor. The requested access rights must be a subset of the access rights which were specified in attr.handled_access_fs at ruleset creation time.
In this example, the rule will only allow reading the file hierarchy /usr. Without another rule, write actions would then be denied by the ruleset. To add /usr to the ruleset, we open it with the O_PATH flag and fill the struct landlock_path_beneath_attr with this file descriptor.
struct landlock_path_beneath_attr path_beneath = {0};
int err;
path_beneath.allowed_access =
LANDLOCK_ACCESS_FS_EXECUTE |
LANDLOCK_ACCESS_FS_READ_FILE |
LANDLOCK_ACCESS_FS_READ_DIR;
path_beneath.parent_fd = open("/usr", O_PATH | O_CLOEXEC);
if (path_beneath.parent_fd == -1) {
perror("Failed to open file");
close(ruleset_fd);
exit(EXIT_FAILURE);
}
err = landlock_add_rule(ruleset_fd, LANDLOCK_RULE_PATH_BENEATH,
&path_beneath, 0);
close(path_beneath.parent_fd);
if (err) {
perror("Failed to update ruleset");
close(ruleset_fd);
exit(EXIT_FAILURE);
}
๐ซถ no new privileges, no problems
We now have a ruleset with one rule allowing read access to /usr while denying all other handled accesses for the filesystem. The next step is to restrict the current thread from gaining more privileges (e.g., thanks to a set-user-ID binary).
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
perror("Failed to restrict privileges");
close(ruleset_fd);
exit(EXIT_FAILURE);
}
๐ฅ the moment we've all been waiting for
The current thread is now ready to sandbox itself with the ruleset.
if (landlock_restrict_self(ruleset_fd, 0)) {
perror("Failed to enforce ruleset");
close(ruleset_fd);
exit(EXIT_FAILURE);
}
close(ruleset_fd);
If the landlock_restrict_self(2) system call succeeds, the current thread is now restricted and this policy will be enforced on all its subsequently created children as well. Once a thread is landlocked, there is no way to remove its security policy; only adding more restrictions is allowed. These threads are now in a new Landlock domain, merge of their parent one (if any) with the new ruleset.
one-way door, periodt ๐ช๐ once you're landlocked, you're landlocked. no take-backs, no undo, only more rules.
Full working code can be found in https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/tree/samples/landlock/sandboxer.c
๐ SEE ALSO ๐
and that's the whole page bestie!! ๐โจ this little masterpiece comes from the Linux man-pages 6.20, dated 2026-09-11, and it's the Landlock(7) man page. go forth and sandbox responsibly ๐๐ฆ๐ธ
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 2017-2020, Mickaรซl Salaรผn <mic@digikod.net>
- Copyright 2019-2020, ANSSI
- Copyright 2021, Microsoft Corp
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms