History

landlock: Clarify documentation for the LANDLOCK_ACCESS_FS_REFER right

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.

Günther Noack committed 3 years ago

Commit ed35e2f1 parent 1c1ea1c1 file · +31 −15Browse files

Showing the changes to include/uapi (1 of 1 file). Show all

Unified · Split

include/uapi/linux/landlock.h+31−15
@@ -130,21 +130,37 @@ struct landlock_path_beneath_attr { · 129 unmodified lines
130130 * - %LANDLOCK_ACCESS_FS_MAKE_BLOCK: Create (or rename or link) a block device.
131131 * - %LANDLOCK_ACCESS_FS_MAKE_SYM: Create (or rename or link) a symbolic link.
132132 * - %LANDLOCK_ACCESS_FS_REFER: Link or rename a file from or to a different
133− * directory (i.e. reparent a file hierarchy). This access right is
134− * available since the second version of the Landlock ABI. This is also the
135− * only access right which is always considered handled by any ruleset in
136− * such a way that reparenting a file hierarchy is always denied by default.
137− * To avoid privilege escalation, it is not enough to add a rule with this
138− * access right. When linking or renaming a file, the destination directory
139− * hierarchy must also always have the same or a superset of restrictions of
140− * the source hierarchy. If it is not the case, or if the domain doesn't
141− * handle this access right, such actions are denied by default with errno
142− * set to ``EXDEV``. Linking also requires a ``LANDLOCK_ACCESS_FS_MAKE_*``
143− * access right on the destination directory, and renaming also requires a
144− * ``LANDLOCK_ACCESS_FS_REMOVE_*`` access right on the source's (file or
145− * directory) parent. Otherwise, such actions are denied with errno set to
146− * ``EACCES``. The ``EACCES`` errno prevails over ``EXDEV`` to let user space
147− * efficiently deal with an unrecoverable error.
133+ * directory (i.e. reparent a file hierarchy).
134+ *
135+ * This access right is available since the second version of the Landlock
136+ * ABI.
137+ *
138+ * This is the only access right which is denied by default by any ruleset,
139+ * even if the right is not specified as handled at ruleset creation time.
140+ * The only way to make a ruleset grant this right is to explicitly allow it
141+ * for a specific directory by adding a matching rule to the ruleset.
142+ *
143+ * In particular, when using the first Landlock ABI version, Landlock will
144+ * always deny attempts to reparent files between different directories.
145+ *
146+ * In addition to the source and destination directories having the
147+ * %LANDLOCK_ACCESS_FS_REFER access right, the attempted link or rename
148+ * operation must meet the following constraints:
149+ *
150+ * * The reparented file may not gain more access rights in the destination
151+ * directory than it previously had in the source directory. If this is
152+ * attempted, the operation results in an ``EXDEV`` error.
153+ *
154+ * * When linking or renaming, the ``LANDLOCK_ACCESS_FS_MAKE_*`` right for the
155+ * respective file type must be granted for the destination directory.
156+ * Otherwise, the operation results in an ``EACCES`` error.
157+ *
158+ * * When renaming, the ``LANDLOCK_ACCESS_FS_REMOVE_*`` right for the
159+ * respective file type must be granted for the source directory. Otherwise,
160+ * the operation results in an ``EACCES`` error.
161+ *
162+ * If multiple requirements are not met, the ``EACCES`` error code takes
163+ * precedence over ``EXDEV``.
148164 *
149165 * .. warning::
150166 *

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t