Add Landlock syscall tests#13740
Open
connrg wants to merge 1 commit into
Open
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
I signed it! |
connrg
force-pushed
the
landlock-syscall-tests
branch
from
July 17, 2026 14:49
01c716e to
9ae9b2a
Compare
Adds a syscall test suite for Linux Landlock under test/syscalls/linux. Each test builds and applies a Landlock ruleset inside a forked child, then checks from the parent that the rules were actually enforced: files outside an allowed directory can't be read, written, listed, created or removed; cross-directory renames are blocked; truncate, TCP bind/connect and device ioctls are gated; and signals and abstract unix sockets are scoped. gVisor doesn't implement Landlock yet, so every test skips under gVisor and runs against a real Linux kernel as the reference. Tests are grouped by the ABI version that introduced each feature and skip themselves on kernels that are too old to support it. As gVisor gains Landlock support we can drop the per-test gVisor skips one at a time. Updates google#13439.
connrg
force-pushed
the
landlock-syscall-tests
branch
from
July 17, 2026 15:26
9ae9b2a to
1465227
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
Tests for Linux Landlock — the kernel feature that lets a process lock itself into a limited set of files, network ports, and so on.
This follows the approach @EtiennePerot suggested in #13439: start by adding tests against the real Linux kernel, cover the rule types we'd want gVisor to support, and skip under gVisor (which doesn't implement Landlock yet). Once the suite is in, gVisor can be matched against it one feature at a time, dropping the "skip on gVisor" guard for each feature as it's implemented.
How the tests work
Landlock is one-way: once a process locks itself down it can't undo it, so a test can't apply a policy to itself without poisoning the whole test binary. As Etienne suggested, each test forks a child, locks the child down, has it try something, and the parent checks from the outside whether it was allowed or blocked (via the child's exit code). I used the existing
seccomp.cctests as a model, as he recommended.What's covered
Grouped by the Landlock version that introduced each feature. Each test skips itself if the kernel is too old:
no_new_privs, unknown flags, and so on)Plus two of the trickier guarantees: that the sandbox is inherited by child processes, and that stacking a second policy can only ever take access away, never add it.
The newest Landlock version (v7, audit) isn't covered yet — it needs a newer kernel than our test machines run. There's a TODO in the file.
Testing
Ran on Linux 6.14 (Landlock v6): 38 tests, all passing. On older kernels, the unsupported tests skip, and under gVisor everything skips.
Updates #13439.