From: "Günther Noack" <gnoack3000@gmail.com>
To: "Mickaël Salaün" <mic@digikod.net>,
"Alejandro Colomar" <alx.manpages@gmail.com>
Cc: linux-doc@vger.kernel.org, linux-security-module@vger.kernel.org,
"Jonathan Corbet" <corbet@lwn.net>,
"Paul Moore" <paul@paul-moore.com>,
"Konstantin Meskhidze" <konstantin.meskhidze@huawei.com>,
"Xiu Jianfeng" <xiujianfeng@huawei.com>,
"Günther Noack" <gnoack3000@gmail.com>
Subject: [PATCH v4] landlock: Clarify documentation for the LANDLOCK_ACCESS_FS_REFER right
Date: Tue, 21 Feb 2023 17:52:05 +0100 [thread overview]
Message-ID: <20230221165205.4231-1-gnoack3000@gmail.com> (raw)
Clarify the "refer" documentation by splitting up a big paragraph of text.
- Call out specifically that the denial by default applies to ABI v1 as well.
- Turn the three additional constraints for link/rename operations
into bullet points, to give it more structure.
Signed-off-by: Günther Noack <gnoack3000@gmail.com>
---
include/uapi/linux/landlock.h | 46 +++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 15 deletions(-)
diff --git a/include/uapi/linux/landlock.h b/include/uapi/linux/landlock.h
index f3223f96469..81d09ef9aa5 100644
--- a/include/uapi/linux/landlock.h
+++ b/include/uapi/linux/landlock.h
@@ -130,21 +130,37 @@ struct landlock_path_beneath_attr {
* - %LANDLOCK_ACCESS_FS_MAKE_BLOCK: Create (or rename or link) a block device.
* - %LANDLOCK_ACCESS_FS_MAKE_SYM: Create (or rename or link) a symbolic link.
* - %LANDLOCK_ACCESS_FS_REFER: Link or rename a file from or to a different
- * directory (i.e. reparent a file hierarchy). This access right is
- * available since the second version of the Landlock ABI. This is also the
- * only access right which is always considered handled by any ruleset in
- * such a way that reparenting a file hierarchy is always denied by default.
- * To avoid privilege escalation, it is not enough to add a rule with this
- * access right. When linking or renaming a file, the destination directory
- * hierarchy must also always have the same or a superset of restrictions of
- * the source hierarchy. If it is not the case, or if the domain doesn't
- * handle this access right, such actions are denied by default with errno
- * set to ``EXDEV``. Linking also requires a ``LANDLOCK_ACCESS_FS_MAKE_*``
- * access right on the destination directory, and renaming also requires a
- * ``LANDLOCK_ACCESS_FS_REMOVE_*`` access right on the source's (file or
- * directory) parent. Otherwise, such actions are denied with errno set to
- * ``EACCES``. The ``EACCES`` errno prevails over ``EXDEV`` to let user space
- * efficiently deal with an unrecoverable error.
+ * directory (i.e. reparent a file hierarchy).
+ *
+ * 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.
+ *
+ * In particular, when using the first Landlock ABI version, Landlock will
+ * always deny attempts to reparent files between different directories.
+ *
+ * In addition to the source and destination directories having the
+ * %LANDLOCK_ACCESS_FS_REFER access right, the attempted link or rename
+ * operation must meet the following constraints:
+ *
+ * * The reparented file may not gain more access rights in the destination
+ * directory than it previously had in the source directory. If this is
+ * attempted, the operation results in an ``EXDEV`` error.
+ *
+ * * When linking or renaming, the ``LANDLOCK_ACCESS_FS_MAKE_*`` right for the
+ * respective file type must be granted for the destination directory.
+ * Otherwise, the operation results in an ``EACCES`` error.
+ *
+ * * When renaming, the ``LANDLOCK_ACCESS_FS_REMOVE_*`` right for the
+ * respective file type must be granted for the source directory. Otherwise,
+ * the operation results in an ``EACCES`` error.
+ *
+ * If multiple requirements are not met, the ``EACCES`` error code takes
+ * precedence over ``EXDEV``.
*
* .. warning::
*
base-commit: c9c3395d5e3dcc6daee66c6908354d47bf98cb0c
--
2.39.2
next reply other threads:[~2023-02-21 16:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-21 16:52 Günther Noack [this message]
2023-02-21 17:22 ` [PATCH v4] landlock: Clarify documentation for the LANDLOCK_ACCESS_FS_REFER right Mickaël Salaün
2023-02-24 23:00 ` Alex Colomar
2023-02-27 11:02 ` Mickaël Salaün
2023-02-27 13:30 ` Alejandro Colomar
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=20230221165205.4231-1-gnoack3000@gmail.com \
--to=gnoack3000@gmail.com \
--cc=alx.manpages@gmail.com \
--cc=corbet@lwn.net \
--cc=konstantin.meskhidze@huawei.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@digikod.net \
--cc=paul@paul-moore.com \
--cc=xiujianfeng@huawei.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).