Skip to content

Commit 6abbb87

Browse files
gnoackl0kod
authored andcommitted
landlock: Clarify documentation for the IOCTL access right
Move the description of the LANDLOCK_ACCESS_FS_IOCTL_DEV access right together with the file access rights. This group of access rights applies to files (in this case device files), and they can be added to file or directory inodes using landlock_add_rule(2). The check for that works the same for all file access rights, including LANDLOCK_ACCESS_FS_IOCTL_DEV. Invoking ioctl(2) on directory FDs can not currently be restricted with Landlock. Having it grouped separately in the documentation is a remnant from earlier revisions of the LANDLOCK_ACCESS_FS_IOCTL_DEV patch set. Link: https://lore.kernel.org/all/20260108.Thaex5ruach2@digikod.net/ Signed-off-by: Günther Noack <gnoack3000@gmail.com> Link: https://lore.kernel.org/r/20260111175203.6545-2-gnoack3000@gmail.com Signed-off-by: Mickaël Salaün <mic@digikod.net>
1 parent 15e8d73 commit 6abbb87

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

include/uapi/linux/landlock.h

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,23 @@ struct landlock_net_port_attr {
216216
* :manpage:`ftruncate(2)`, :manpage:`creat(2)`, or :manpage:`open(2)` with
217217
* ``O_TRUNC``. This access right is available since the third version of the
218218
* Landlock ABI.
219+
* - %LANDLOCK_ACCESS_FS_IOCTL_DEV: Invoke :manpage:`ioctl(2)` commands on an opened
220+
* character or block device.
221+
*
222+
* This access right applies to all `ioctl(2)` commands implemented by device
223+
* drivers. However, the following common IOCTL commands continue to be
224+
* invokable independent of the %LANDLOCK_ACCESS_FS_IOCTL_DEV right:
225+
*
226+
* * IOCTL commands targeting file descriptors (``FIOCLEX``, ``FIONCLEX``),
227+
* * IOCTL commands targeting file descriptions (``FIONBIO``, ``FIOASYNC``),
228+
* * IOCTL commands targeting file systems (``FIFREEZE``, ``FITHAW``,
229+
* ``FIGETBSZ``, ``FS_IOC_GETFSUUID``, ``FS_IOC_GETFSSYSFSPATH``)
230+
* * Some IOCTL commands which do not make sense when used with devices, but
231+
* whose implementations are safe and return the right error codes
232+
* (``FS_IOC_FIEMAP``, ``FICLONE``, ``FICLONERANGE``, ``FIDEDUPERANGE``)
233+
*
234+
* This access right is available since the fifth version of the Landlock
235+
* ABI.
219236
*
220237
* Whether an opened file can be truncated with :manpage:`ftruncate(2)` or used
221238
* with `ioctl(2)` is determined during :manpage:`open(2)`, in the same way as
@@ -275,26 +292,6 @@ struct landlock_net_port_attr {
275292
* If multiple requirements are not met, the ``EACCES`` error code takes
276293
* precedence over ``EXDEV``.
277294
*
278-
* The following access right applies both to files and directories:
279-
*
280-
* - %LANDLOCK_ACCESS_FS_IOCTL_DEV: Invoke :manpage:`ioctl(2)` commands on an opened
281-
* character or block device.
282-
*
283-
* This access right applies to all `ioctl(2)` commands implemented by device
284-
* drivers. However, the following common IOCTL commands continue to be
285-
* invokable independent of the %LANDLOCK_ACCESS_FS_IOCTL_DEV right:
286-
*
287-
* * IOCTL commands targeting file descriptors (``FIOCLEX``, ``FIONCLEX``),
288-
* * IOCTL commands targeting file descriptions (``FIONBIO``, ``FIOASYNC``),
289-
* * IOCTL commands targeting file systems (``FIFREEZE``, ``FITHAW``,
290-
* ``FIGETBSZ``, ``FS_IOC_GETFSUUID``, ``FS_IOC_GETFSSYSFSPATH``)
291-
* * Some IOCTL commands which do not make sense when used with devices, but
292-
* whose implementations are safe and return the right error codes
293-
* (``FS_IOC_FIEMAP``, ``FICLONE``, ``FICLONERANGE``, ``FIDEDUPERANGE``)
294-
*
295-
* This access right is available since the fifth version of the Landlock
296-
* ABI.
297-
*
298295
* .. warning::
299296
*
300297
* It is currently not possible to restrict some file-related actions

0 commit comments

Comments
 (0)