Support for landlock ABI v5?
Would it be possible to support systems with ABI v5? It would enable us to run sandlock on top of RHEL 9 Kernel. I'm mostly interested in FS and network sandboxing. ABI v6 added LANDLOCK_SCOPE_SIGNAL and LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET. The Kernel docs have an example how to rescope a ruleset.
$ sandlock --version
sandlock 0.6.0
$ sandlock check
Kernel feature support:
Landlock: ABI v5
Minimum required: ABI v6
Status: UNSUPPORTED (upgrade kernel)
Filesystem: supported (ABI v1+)
File truncate: supported (ABI v3+)
TCP ports: supported (ABI v4+)
Device ioctl: supported (ABI v5+)
IPC scoping: not supported
Signal scoping: not supported
Platform: x86_64
$ uname -r
5.14.0-570.79.1.el9_6.x86_64
Requiring ABI v6 is deliberate. v6 is what lets sandlock close two escape paths that v5 leaves open, and we treat that as part of the security guarantee, not an optional extra.
We unconditionally enable two v6-only scopes:
LANDLOCK_SCOPE_ABSTRACT_UNIX_SOCKET: without it, a sandboxed process canconnect()to any abstract Unix socket in the host namespace (D-Bus session bus, ssh-agent/gpg-agent, X11/Wayland on abstract sockets, snapd, etc.). The FS allowlist can't block these because abstract sockets don't live on the filesystem.LANDLOCK_SCOPE_SIGNAL: without it, the sandboxed PID cankill(2)any process owned by the invoking UID (supervisor, sibling sandboxes, user-session daemons). A DoS and integrity leak across the boundary.
Your FS + TCP use case is genuinely well-served by v5 (path-beneath, REFER, truncate, TCP bind/connect, device ioctl all work), but without the v6 scopes the sandbox boundary leaks laterally through kernel IPC, and we don't want to ship a mode that silently degrades that guarantee depending on the host kernel.
Curious how you'd weigh this for your setup: is the v5-level FS+TCP jail still useful to you knowing the IPC/signal boundary isn't enforced, or does that change the calculus?
Hello, I have hit the same issue unfortunately.
Using ABI v6 as a secure default makes sense. At the same time, the Policy object already allows for specific usability / risk trade-offs to this secure by default model. Could we enable the ability to configure a Policy object away from this secure default that explicitly/implicitly drops the requirement on v6 Landlock ABI? I.e allowlist socket I/O and sending signals.
Lots of server infrastructure run LTS OS Versions, like Ubuntu 24.04. This limitation prevents containerized apps (ie a Kubernetes nodes) from using Sandlock, which is where I see a common use-case for Sandlock: where a node is already isolated from the system via containerization, but the code within the node wants to apply further hardening by extension.
Joining this thread with a similar use case — wrapping Python workloads on Kubernetes nodes that run RHEL 9 / Ubuntu 24.04 LTS. Container isolation is the first boundary; sandlock would be a defense-in-depth layer for the in-container code. The v6 scopes are exactly the guarantees we'd want when sandlock is the only boundary, but in a container-first deployment model the abstract-socket and signal escapes are already mitigated at the outer layer (no host D-Bus / X11 / agent sockets reachable inside the container; signal blast radius bounded by the container's PID namespace). So the v5-level FS + TCP + REFER + truncate + ioctl jail is still useful as the inner layer, even knowing the v6 scopes aren't enforced.
Concretely on scope: the kernels currently shipped in LTS / enterprise base images that downstream consumers will realistically standardize on — RHEL 9 (5.14), Ubuntu 24.04 LTS (6.8), Debian 12 (6.1), SLES 15 (6.4), Amazon Linux 2023 (6.1) — all sit below the v6 line. Where HWE or backport tracks do exist, security teams in regulated environments typically refuse to deviate from the certified kernel baseline. The v6 requirement therefore effectively blocks sandlock adoption in those environments for at least the next 2–3 LTS adoption cycles — that's the gap I'd be writing the implementation against, and the reason I'm willing to spend the time on a contained opt-in rather than waiting it out.
I understand the position that shipping a silently-degraded mode is a no-go. Would you be open to merging an explicit opt-in if the API made the trade-off impossible to take by accident? Rough shape (not a PR):
- A separate constructor on
Policy, not a flag on the default builder — e.g.Policy::unsafe_v5_fallback_no_ipc_scope()— so the compromise is visible at the call site. - The opt-in is a fallback, not a downgrade: if v6 is detected on the host, the v6 scopes are still applied regardless of the opt-in.
sandlock checkreports the degraded boundary explicitly when the opt-in is in effect.- A dedicated doc page enumerating exactly what doesn't hold (abstract-socket
connect, signal delivery to UID peers), so users know what they're swapping for kernel coverage.
If the shape is acceptable in principle, I'm happy to draft the implementation as a follow-up PR — I have recent work on the Rust core and Python wrapper (#44, #46, #54) so the policy / dispatch plumbing is in head. If the answer is still "no v5, period", that's also a clear signal and I won't push further.
Thanks for bringing this up. This is is reasonable request.
@dzerik I am thinking about the following design which allows users to explicitly opt-in features available on their kernel:
use sandlock::{Sandbox, Protection};
// Only the protections you name are enforced.
let sb = Sandbox::builder()
.fs_read("/data")
.fs_write("/tmp")
.protect(Protection::SignalScope) // require it; ENOTSUP if kernel can't
.protect(Protection::AbstractUnixScope)
.protect(Protection::FsTruncate)
.protect(Protection::FsIoctlDev)
.protect(Protection::NetTcpConnect)
.build()?; // ENOTSUP surfaces here (or at run())
// Old kernel: just omit the two scopes.
let sb = Sandbox::builder()
.fs_read("/data")
.protect(Protection::FsTruncate)
.protect(Protection::FsIoctlDev)
// SignalScope / AbstractUnixScope simply not listed
// -> not enforced. No error. No warning. <-- the silent gap
.build()?;
Please feel free to suggest better design. And it is appreciated if you could work on a PR too.
Thanks.
Thanks — happy to take the PR. Before I start, one design point I'd like to land with you, because it changes the polarity of the builder API.
The Protection enum is exactly the right primitive — I'd keep it. My only concern is with the opt-in direction, and it's the failure mode you annotated yourself:
// SignalScope / AbstractUnixScope simply not listed
// -> not enforced. No error. No warning. <-- the silent gap
Opt-in inverts secure-by-default: the default (name nothing) enforces nothing, and a caller who forgets a protection silently loses it. That's the same thing your first comment on this issue argued against ("we don't want to ship a mode that silently degrades that guarantee depending on the host kernel").
Counter-proposal — same enum, opt-out polarity, which keeps the secure default and closes the gap:
// Default: full baseline, strict. build() fails on a kernel that can't
// provide a required protection — current behaviour, unchanged.
let sb = Sandbox::builder().fs_read("/data").build()?;
// Fallback: enforce where the kernel supports it, skip where it can't.
let sb = Sandbox::builder()
.fs_read("/data")
.allow_degraded(Protection::SignalScope)
.allow_degraded(Protection::AbstractUnixScope)
.build()?; // succeeds on v5; the two scopes are skipped
// Deliberate disable: off even on a capable kernel (workload needs the
// capability the scope blocks, e.g. signalling a sibling).
let sb = Sandbox::builder()
.fs_read("/data")
.disable(Protection::SignalScope)
.build()?;
Three states per protection: required-strict (default), allow_degraded (fallback), disable (deliberate). No silent gap — the safe path needs no action, and every deviation is explicit at the call site and greppable (the audit-trail property unsafe gives). sandlock check would report each protection as active / degraded / disabled, so even a degraded scope is visible in the posture.
One thing that makes this cheaper than it looks: the per-ABI gating already exists in landlock.rs (abi >= 2/3/5 for REFER/truncate/ioctl-dev) — it's just unreachable today because MIN_ABI = 6 rejects everything below v6 first. So this is largely relaxing that hard floor into a per-protection policy, plus the reporting.
Open questions before I build:
- OK to invert to opt-out for the secure default, or do you want to keep opt-in?
- Verb names —
allow_degraded/disable, or do you prefer others? - Should
disablework on a capable kernel (deliberate bypass), or fallback-only? - Scope for v1 — just the two v6 IPC scopes, or the full ABI-gated set?
I'll mirror the RFC #43 chain (Rust core → C ABI + Python → CLI/docs) once we've settled the shape.
Excellent proposal, I think it is better, @dzerik .
Regarding your questions here:
- Yes, opt-out looks better
- disable() looks better since it is shorter
- It should work on capable kernel
- Just the two v6 IPC scopes is enough to unblock users in this thread.
Thanks!
Quick status update — I have an end-to-end implementation of the opt-out design we agreed on (default strict, allow_degraded(), disable() working on capable kernels too), and I've spent today running it against the LTS / enterprise kernels that motivated this issue. I wanted to share what fell out before opening the PR, in case any of it changes how you'd prefer it to look.
Implementation status
Branch on my fork (not yet open as PR): https://github.com/dzerik/sandlock/tree/follow-up-c-protection-foundation
13 commits, layered to match the RFC chain we used in #43 / #44 / #46:
- Rust core:
Protectionenum,ProtectionPolicy, polarity-resolvedResolved(Active/Degraded/Disabled) atSandbox::build(), per-protection ABI gating inlandlock.rs - C ABI:
sandlock_protection_t, two builder setters with move semantics,sandlock_protection_min_abi() - Python:
ProtectionIntEnum re-exported,allow_degraded/disablekwargs on the dataclass builder - CLI:
sandlock checknow reports per-protection availability;sandlock run --allow-degraded <name>/--disable <name>flags - Docs:
extension-handlers.mdandpython-handlers.mdsections, README pointer
283 lib + 18 integration + 6 FFI + 8 Python tests, all green. The ABI-host matrix is tested directly against ProtectionPolicy::resolve(), so the v3 / v4 / v5 / v6 paths are exercised regardless of the host kernel the CI machine has.
VM validation matrix
I brought up multipass VMs for the kernel cohorts from the thread:
| Distro | Kernel | sandlock check host ABI |
Strict default | --disable signal-scope --disable abstract-unix-scope-socket |
|---|---|---|---|---|
| Rocky 9.6 ← original repro env | 5.14.0-570.17.1.el9_6 | v5 (matches the report at the top of this thread) | fails with required protection SignalScope is not available: host Landlock ABI is v5, requires v6 |
Landlock stage passes ✅ |
| Rocky 9.7 | 5.14.0-611.5.1.el9_7 | v6 reported (RHEL backports) | fails with create ruleset: Invalid argument (see finding 1 below) |
Landlock stage passes ✅ |
| Ubuntu 22.04 | 5.15.0-179-generic | v1 reported in this multipass image | fails with required protection FsRefer is not available: host Landlock ABI is v1, requires v2 |
Landlock stage passes ✅ |
So the opt-out path does what we wanted on the original RHEL 9 repro: a single --disable signal-scope --disable abstract-unix-scope-socket produces a clean Landlock pipeline (full FS + REFER + truncate + TCP + ioctl-dev intact, only the two v6 IPC scopes off — exactly the trade you described in your first comment as "genuinely well-served by v5").
Two unexpected findings I'd like your read on
1. Rocky 9.7 reports ABI v6 but a default landlock_create_ruleset(...) call returns EINVAL. RHEL appears to be backporting the version number ahead of the underlying attrs. The opt-out path covers it (a user --disables the affected v5/v6 protections and the ruleset assembles cleanly), but it means the user-visible sandlock check ABI line can't be trusted as a capability statement on backport distros. Per-protection probing at build() is the only reliable signal, which is more or less what we already do — just flagging.
2. The seccomp install fails before Landlock is even attempted on every < 5.19 kernel. This was the actual blocker behind the Rocky / Ubuntu 22.04 exit codes during VM testing. Tracked separately as #62 — short version: the Rust port dropped the WAIT_KILLABLE_RECV fallback that your Python implementation (commit 50d5eb9) had explicitly added for older kernels. It's a Rust-port regression, the fix is a couple of lines, but until it lands the opt-out alone doesn't unblock the LTS use case end-to-end. Happy to send the precursor PR before the opt-out, or after — your call on ordering.
What I'm planning next
If the shape above looks right, I'll open the opt-out PR against main with the matrix as part of the description, and a GitHub Actions job covering ubuntu-22.04 + ubuntu-latest so the v3 / v4 paths get exercised on every push. The #62 fix slots in either before or after, whichever you prefer.
If anything in the implementation polarity, the verb names, or the scope needs adjusting before the PR opens, now's a good time — happy to rework.