From: Justin Suess <utilityemal77@gmail.com>
To: linux-security-module@vger.kernel.org
Cc: "Tingmao Wang" <m@maowtm.org>,
"Günther Noack" <gnoack@google.com>, "Jan Kara" <jack@suse.cz>,
"Abhinav Saxena" <xandfury@gmail.com>,
"Mickaël Salaün" <mic@digikod.net>,
"Justin Suess" <utilityemal77@gmail.com>
Subject: [PATCH v2 0/6] Implement LANDLOCK_ADD_RULE_NO_INHERIT
Date: Thu, 20 Nov 2025 17:23:40 -0500 [thread overview]
Message-ID: <20251120222346.1157004-1-utilityemal77@gmail.com> (raw)
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
next reply other threads:[~2025-11-20 22:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 22:23 Justin Suess [this message]
2025-11-20 22:23 ` [PATCH 1/6] landlock: Implement LANDLOCK_ADD_RULE_NO_INHERIT Justin Suess
2025-11-20 22:23 ` [PATCH 2/6] landlock: Implement LANDLOCK_ADD_RULE_NO_INHERIT userspace api Justin Suess
2025-11-23 21:03 ` Tingmao Wang
2025-11-25 12:06 ` Justin Suess
2025-11-20 22:23 ` [PATCH 3/6] samples/landlock: Add LANDLOCK_ADD_RULE_NO_INHERIT to landlock-sandboxer Justin Suess
2025-11-20 22:23 ` [PATCH 4/6] selftests/landlock: Implement selftests for LANDLOCK_ADD_RULE_NO_INHERIT Justin Suess
2025-11-20 22:23 ` [PATCH 5/6] landlock: Fix compilation error for kunit tests when CONFIG_AUDIT is disabled Justin Suess
2025-11-22 23:35 ` Tingmao Wang
2025-11-23 16:43 ` Justin Suess
2025-11-20 22:23 ` [PATCH 6/6] landlock: Implement KUnit test for LANDLOCK_ADD_RULE_NO_INHERIT Justin Suess
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251120222346.1157004-1-utilityemal77@gmail.com \
--to=utilityemal77@gmail.com \
--cc=gnoack@google.com \
--cc=jack@suse.cz \
--cc=linux-security-module@vger.kernel.org \
--cc=m@maowtm.org \
--cc=mic@digikod.net \
--cc=xandfury@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).