What is Landlock?
Landlock is a Linux security module that allows unprivileged processes to sandbox themselves. Unlike traditional LSMs (SELinux, AppArmor) that require root configuration, Landlock can be used by any process to restrict its own capabilities. Landlock was merged into Linux kernel 5.13 (2021) and has been enhanced in subsequent releases.How nono Uses Landlock
nono uses thelandlock Rust crate to:
- Detect the available Landlock ABI version
- Create a ruleset with the allowed operations
- Add path rules for each granted capability
- Apply the ruleset to the current process
ABI Versions
Landlock capabilities have evolved across kernel versions:
nono automatically detects the highest available ABI and uses it. On older kernels, some features are unavailable but core filesystem sandboxing still works.
Access Rights Mapping
nono maps its capability flags to Landlock access rights:Read Access (--read)
Write Access (--write)
RemoveFile and RemoveDir are both included because rename() requires removal rights on the source. This enables atomic write patterns (write to .tmp then rename to target) for both files and directories.
Note: Landlock rules bind to the inode that was open when the ruleset was applied, not to the path. A file-level grant therefore goes stale if the file is replaced via such an atomic write from outside the sandbox — the new inode carries no rule and access fails with EACCES. nono why reports this as stale_file_grant (see Troubleshooting). Directory grants are not affected: a directory rule covers all children, including files created after the sandbox started.
Full Access (--allow)
Both read and write access rights combined.
Network Filtering
Landlock ABI v4 (kernel 6.7+) added TCP network filtering:Signal and IPC Scoping
Landlock ABI v6 added scope restrictions for process signals and abstract UNIX sockets:shared_memory_only is the default IPC mode. On V6 kernels it prevents connecting to abstract UNIX sockets created outside the current Landlock domain. Profiles that need broader runtime IPC compatibility can opt into ipc_mode: "full".
Use verbose dry-run output to see what would be requested and enforced:
nono why for a focused scope query:
Pathname Unix Socket Mediation
Landlock filesystem rules and pathname Unix socket IPC are separate security surfaces. On Linux, a process that can reach a filesystem-backed Unix socket path may be able to communicate with a user-session service through that socket unless nono separately mediates AF_UNIXconnect(2) and bind(2).
For compatibility, this mediation is off by default on Landlock V4+ kernels.
Profiles that need stricter IPC isolation can opt in:
filesystem.unix_socket* grants. Broad filesystem read/write grants no longer
imply permission to talk to every socket under those paths.
Allowed pathname sockets are resumed through Linux seccomp user notification.
Because seccomp receives the syscall before the kernel copies sockaddr_un
from userspace, a multi-threaded sandboxed process can race an allowed
connect(2) or bind(2) by mutating that userspace address before the kernel
continues the syscall. Denied sockets do not have this race because nono returns
EACCES directly and the kernel never runs the original syscall. Treat this
mode as a strong default-deny IPC hardening layer; avoid broad socket grants for
untrusted multi-threaded workloads.
High-risk socket categories include user service managers, session buses,
keyring and credential agents, SSH/GPG agents, container runtimes, and package
manager daemons. Hardened profiles should grant only the specific sockets they
need.
Enforcement Status
nono reports the enforcement status after applying the sandbox:
Use
-v to see the enforcement status:
Checking Landlock Availability
Enabling Landlock
If Landlock is not listed in/sys/kernel/security/lsm, you may need to:
- Check kernel config: Ensure
CONFIG_SECURITY_LANDLOCK=y - Add to boot params: Add
lsm=landlock,lockdown,yama,integrity,apparmor,bpfto kernel boot parameters - Reboot
Irreversibility
Oncerestrict_self() is called:
- The ruleset is permanently applied
- No API exists to add more permissions
- Child processes inherit the restrictions
- The only escape is a kernel exploit
Debugging
If a command fails with permission errors:-
Run with dry-run: See what capabilities would be granted
-
Check verbose output:
-
Check dmesg for Landlock denials:
-
Use strace: See which syscalls are being denied
Limitations
Kernel Version Requirements
- Basic sandboxing requires kernel 5.13+
- Full filesystem control requires kernel 6.2+
- Network filtering requires kernel 6.7+
- Signal and abstract UNIX socket scoping requires Landlock ABI v6
No Network Filtering on Older Kernels
Without ABI v4 (kernel 6.7+), Landlock cannot filter TCP connections. nono will warn if you use--block-net on an older kernel. On kernels 6.7+, nono uses Landlock’s AccessNet::BindTcp and AccessNet::ConnectTcp to block TCP traffic.
Note: DNS resolution (UDP) is not blocked by Landlock, only TCP connections.
Bind Mounts
Landlock follows bind mounts. If/home is bind-mounted to /mnt/home, access to one affects the other. This is usually not a concern but can be surprising in complex mount configurations.