[PATCH v2 0/6] Implement LANDLOCK_ADD_RULE_NO_INHERIT
Justin Suess
utilityemal77 at gmail.com
Thu Nov 20 22:23:40 UTC 2025
Hi,
This series introduces a new Landlock rule flag,
LANDLOCK_ADD_RULE_NO_INHERIT, which disables inheriting access rights
from parent objects within the same Landlock layer.
This is useful for policies where a parent directory requires broader
access than its children. For example, a sandbox may allow read-write
access to /home/user but prohibit writes to ~/.bashrc or ~/.ssh even
though they are nested inside the parent directory. Today, this is not
possible because access rights always propagate from parent to child
within a layer.
When a rule is added with LANDLOCK_ADD_RULE_NO_INHERIT:
* access rights on parent inodes are ignored for that inode and its
descendants; and
* operations that change the direct parent subtree of such an object
(rename, rmdir, link) are denied up to the mountpoint.
These parent-directory restrictions mitigate sandbox-restart attacks.
Without them, a sandboxed program could move a protected directory
before exit, causing the next sandbox instance to apply policies on the
wrong path. Denying such operations prevents these attacks.
This v2 series differs from v1 in the following ways:
1. Adds four new selftests for the new flag.
2. Adds a KUnit test for access layer propagation with flags.
2. Extends parent-directory protections (rename/unlink/link) to prevent
sandbox-restart attacks.
3. Rebased on v4 of Tingmao Wang's amazing "quiet flag" series.
For convenience, the original v1 is here:
https://lore.kernel.org/linux-security-module/20251105180019.1432367-1-utilityemal77@gmail.com/T/#t
And the quiet-flag v4 series is here:
https://lore.kernel.org/linux-security-module/cover.1763330228.git.m@maowtm.org/T/#t
A short usage example:
# LL_FS_RO="" LL_FS_RW="/" LL_FS_RO_NO_INHERIT="/a/b/c" landlock-sandboxer sh
# touch /a/b/c/fi # denied (does not inherit / RW)
# rmdir /a/b/c # denied due to parent-directory protections
# mv /a /bad # denied
# mkdir /a/good; touch /a/good/fi # allowed (unrelated to /a/b/c)
All kunit and selftests related to landlock, including the new ones, pass on my test system.
Feedback is very welcome. Thank you for your time and consideration.
Regards,
Justin Suess
Justin Suess (6):
landlock: Implement LANDLOCK_ADD_RULE_NO_INHERIT
landlock: Implement LANDLOCK_ADD_RULE_NO_INHERIT userspace api
samples/landlock: Add LANDLOCK_ADD_RULE_NO_INHERIT to
landlock-sandboxer
selftests/landlock: Implement selftests for
LANDLOCK_ADD_RULE_NO_INHERIT
landlock: Fix compilation error for kunit tests when CONFIG_AUDIT is
disabled.
landlock: Implement KUnit test for LANDLOCK_ADD_RULE_NO_INHERIT
include/uapi/linux/landlock.h | 9 +
samples/landlock/sandboxer.c | 39 +-
security/landlock/audit.h | 3 +-
security/landlock/fs.c | 433 ++++++++++++++++++++-
security/landlock/net.h | 2 +-
security/landlock/object.h | 2 +
security/landlock/ruleset.c | 171 +++++++-
security/landlock/ruleset.h | 39 ++
security/landlock/syscalls.c | 5 +-
tools/testing/selftests/landlock/fs_test.c | 222 ++++++++++-
10 files changed, 883 insertions(+), 42 deletions(-)
base-commit: d74278e895485ffe1c3708f7f2bc5c5b364aab0a
--
2.51.2
More information about the Linux-security-module-archive
mailing list