From: "Günther Noack" <gnoack3000@gmail.com>
To: "Mickaël Salaün" <mic@digikod.net>
Cc: "Paul Moore" <paul@paul-moore.com>,
"James Morris" <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
"Konstantin Meskhidze" <konstantin.meskhidze@huawei.com>,
"Shuah Khan" <shuah@kernel.org>, "Dwi Siswanto" <me@dw1.io>,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
"Günther Noack" <gnoack3000@gmail.com>
Subject: [PATCH v3 5/5] landlock: Clarify implicit handling of LANDLOCK_ACCESS_FS_REFER
Date: Fri, 13 Nov 2026 21:23:27 +0100 [thread overview]
Message-ID: <20261113-b4-landlock-refer-nonfs-layer-v3-5-02d7e42bcdfd@gmail.com> (raw)
In-Reply-To: <20261113-b4-landlock-refer-nonfs-layer-v3-0-02d7e42bcdfd@gmail.com>
The LANDLOCK_ACCESS_FS_REFER right is handled implicitly in a ruleset,
but only if any other filesystem access right is declared as handled
in the given ruleset.
The old documentation was still a remnant from the times when
filesystem access rights were the only access rights that existed in
Landlock, but it became misleading when we introduced additional types
of access rights.
Fixes: fff69fb03dde ("landlock: Support network rules with TCP bind and connect")
Signed-off-by: Günther Noack <gnoack3000@gmail.com>
---
include/uapi/linux/landlock.h | 17 +++++++++--------
security/landlock/access.h | 13 +++++++------
tools/testing/selftests/landlock/fs_test.c | 7 ++++---
3 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/include/uapi/linux/landlock.h b/include/uapi/linux/landlock.h
index 24510e5d8479..7e38b9d1bf12 100644
--- a/include/uapi/linux/landlock.h
+++ b/include/uapi/linux/landlock.h
@@ -22,10 +22,10 @@
* enacted. Vice versa, access rights that are not specifically listed here are
* not going to be denied by this ruleset when it is enacted.
*
- * For historical reasons, the %LANDLOCK_ACCESS_FS_REFER right is always denied
- * by default, even when its bit is not set in @handled_access_fs. In order to
- * add new rules with this access right, the bit must still be set explicitly
- * (cf. `Filesystem flags`_).
+ * For historical reasons, as soon as any filesystem access right is handled in
+ * @handled_access_fs, the %LANDLOCK_ACCESS_FS_REFER right is always denied as
+ * well. In order to add new rules with this access right, the bit must still
+ * be set explicitly (cf. `Filesystem flags`_).
*
* The explicit listing of *handled access rights* is required for backwards
* compatibility reasons. In most use cases, processes that use Landlock will
@@ -462,10 +462,11 @@ struct landlock_capability_attr {
* This access right is available since the second version of the Landlock
* ABI.
*
- * This is the only access right which is denied by default by any ruleset,
- * even if the right is not specified as handled at ruleset creation time.
- * The only way to make a ruleset grant this right is to explicitly allow it
- * for a specific directory by adding a matching rule to the ruleset.
+ * This is the only access right which is denied by default by any ruleset
+ * that handles filesystem access rights, even if the right is not specified
+ * as handled at ruleset creation time. The only way to make a ruleset grant
+ * this right is to explicitly allow it for a specific directory by adding a
+ * matching rule to the ruleset.
*
* In particular, when using the first Landlock ABI version, Landlock will
* always deny attempts to reparent files between different directories.
diff --git a/security/landlock/access.h b/security/landlock/access.h
index f9eaa2f53686..789ccfd9f669 100644
--- a/security/landlock/access.h
+++ b/security/landlock/access.h
@@ -18,10 +18,11 @@
#include "limits.h"
/*
- * All access rights that are denied by default whether they are handled or not
- * by a ruleset/layer. This must be ORed with the .handled field of all
- * domain->layers[] entries when we need to get the absolute handled access
- * masks, see landlock_upgrade_handled_layer_config().
+ * All filesystem access rights that are denied by default as soon as any other
+ * filesystem access right is handled, even if the access right is not
+ * explicitly declared to be handled itself. This must be ORed with the
+ * .handled field of all domain->layers[] entries when we need to get the
+ * absolute handled access masks, see landlock_upgrade_handled_layer_config().
*/
/* clang-format off */
#define _LANDLOCK_ACCESS_FS_INITIALLY_DENIED ( \
@@ -178,8 +179,8 @@ static inline struct layer_config
landlock_upgrade_handled_layer_config(struct layer_config layer_config)
{
/*
- * All access rights that are denied by default whether they are
- * explicitly handled or not.
+ * All filesystem access rights that are denied by default
+ * as soon as any other filesystem access right is handled.
*/
if (layer_config.handled.fs)
layer_config.handled.fs |= _LANDLOCK_ACCESS_FS_INITIALLY_DENIED;
diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/selftests/landlock/fs_test.c
index 6d9baab0fae8..48c1f896dc9a 100644
--- a/tools/testing/selftests/landlock/fs_test.c
+++ b/tools/testing/selftests/landlock/fs_test.c
@@ -3034,8 +3034,8 @@ TEST_F_FORK(layout1, reparent_exdev_layers_rename1)
/*
* Moving the file2_s1d3 file below dir_s2d3 is denied because the
- * second layer does not handle REFER, which is always denied by
- * default.
+ * second layer does not handle REFER, which is always denied as soon as
+ * any other filesystem access right is handled.
*/
ASSERT_EQ(-1, rename(file2_s1d3, file1_s2d3));
ASSERT_EQ(EXDEV, errno);
@@ -3073,7 +3073,8 @@ TEST_F_FORK(layout1, reparent_exdev_layers_rename2)
ASSERT_EQ(EXDEV, errno);
/*
* Modifying the layout is now denied because the second layer does not
- * handle REFER, which is always denied by default.
+ * handle REFER, which is always denied as soon as any other filesystem
+ * access right is handled.
*/
ASSERT_EQ(-1, rename(file2_s1d2, file1_s2d3));
ASSERT_EQ(EXDEV, errno);
--
2.56.1
next prev parent reply other threads:[~2026-11-13 20:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 20:23 [PATCH v3 0/5] landlock: Fix REFER in layered domains Günther Noack
2026-11-13 20:23 ` [PATCH v3 1/5] landlock: Fix layer composition of LANDLOCK_ACCESS_FS_REFER Günther Noack
2026-11-13 20:23 ` [PATCH v3 2/5] landlock: Add KUnit test for landlock_get_fs_access_mask() Günther Noack
2026-11-13 20:23 ` [PATCH v3 3/5] selftests/landlock: Test that layering does not break refer Günther Noack
2026-11-13 20:23 ` [PATCH v3 4/5] landlock: Simplify landlock_get_fs_access_mask() Günther Noack
2026-11-13 20:23 ` Günther Noack [this message]
2026-12-04 15:52 ` [PATCH v3 0/5] landlock: Fix REFER in layered domains Mickaël Salaün
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=20261113-b4-landlock-refer-nonfs-layer-v3-5-02d7e42bcdfd@gmail.com \
--to=gnoack3000@gmail.com \
--cc=jmorris@namei.org \
--cc=konstantin.meskhidze@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=me@dw1.io \
--cc=mic@digikod.net \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
--cc=shuah@kernel.org \
/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
all inboxes | Powered by JetHome®