History

Merge tag 'landlock-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux

Pull landlock updates from Mickaël Salaün: "This brings ioctl control to Landlock, contributed by Günther Noack. This also adds him as a Landlock reviewer, and fixes an issue in the sample" * tag 'landlock-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mic/linux: MAINTAINERS: Add Günther Noack as Landlock reviewer fs/ioctl: Add a comment to keep the logic in sync with LSM policies MAINTAINERS: Notify Landlock maintainers about changes to fs/ioctl.c landlock: Document IOCTL support samples/landlock: Add support for LANDLOCK_ACCESS_FS_IOCTL_DEV selftests/landlock: Exhaustive test for the IOCTL allow-list selftests/landlock: Check IOCTL restrictions for named UNIX domain sockets selftests/landlock: Test IOCTLs on named pipes selftests/landlock: Test ioctl(2) and ftruncate(2) with open(O_PATH) selftests/landlock: Test IOCTL with memfds selftests/landlock: Test IOCTL support landlock: Add IOCTL access right for character and block devices samples/landlock: Fix incorrect free in populate_ruleset_net

Linus Torvalds committed 2 years ago

Commit 2fc0e782 parents 89721e3 5bf9e5710 files · +811 −46Browse files

Showing the changes to include/uapi/linux (1 of 10 files). Show all

Unified · Split

include/uapi/linux/landlock.h+30−8
@@ -128,7 +128,7 @@ struct landlock_net_port_attr { · 127 unmodified lines
128128 * files and directories. Files or directories opened before the sandboxing
129129 * are not subject to these restrictions.
130130 *
131− * A file can only receive these access rights:
131+ * The following access rights apply only to files:
132132 *
133133 * - %LANDLOCK_ACCESS_FS_EXECUTE: Execute a file.
134134 * - %LANDLOCK_ACCESS_FS_WRITE_FILE: Open a file with write access. Note that
@@ -138,12 +138,13 @@ struct landlock_net_port_attr { · 3 unmodified lines
138138 * - %LANDLOCK_ACCESS_FS_READ_FILE: Open a file with read access.
139139 * - %LANDLOCK_ACCESS_FS_TRUNCATE: Truncate a file with :manpage:`truncate(2)`,
140140 * :manpage:`ftruncate(2)`, :manpage:`creat(2)`, or :manpage:`open(2)` with
141− * ``O_TRUNC``. Whether an opened file can be truncated with
142− * :manpage:`ftruncate(2)` is determined during :manpage:`open(2)`, in the
143− * same way as read and write permissions are checked during
144− * :manpage:`open(2)` using %LANDLOCK_ACCESS_FS_READ_FILE and
145− * %LANDLOCK_ACCESS_FS_WRITE_FILE. This access right is available since the
146− * third version of the Landlock ABI.
141+ * ``O_TRUNC``. This access right is available since the third version of the
142+ * Landlock ABI.
143+ *
144+ * Whether an opened file can be truncated with :manpage:`ftruncate(2)` or used
145+ * with `ioctl(2)` is determined during :manpage:`open(2)`, in the same way as
146+ * read and write permissions are checked during :manpage:`open(2)` using
147+ * %LANDLOCK_ACCESS_FS_READ_FILE and %LANDLOCK_ACCESS_FS_WRITE_FILE.
147148 *
148149 * A directory can receive access rights related to files or directories. The
149150 * following access right is applied to the directory itself, and the
@@ -198,13 +199,33 @@ struct landlock_net_port_attr { · 48 unmodified lines
198199 * If multiple requirements are not met, the ``EACCES`` error code takes
199200 * precedence over ``EXDEV``.
200201 *
202+ * The following access right applies both to files and directories:
203+ *
204+ * - %LANDLOCK_ACCESS_FS_IOCTL_DEV: Invoke :manpage:`ioctl(2)` commands on an opened
205+ * character or block device.
206+ *
207+ * This access right applies to all `ioctl(2)` commands implemented by device
208+ * drivers. However, the following common IOCTL commands continue to be
209+ * invokable independent of the %LANDLOCK_ACCESS_FS_IOCTL_DEV right:
210+ *
211+ * * IOCTL commands targeting file descriptors (``FIOCLEX``, ``FIONCLEX``),
212+ * * IOCTL commands targeting file descriptions (``FIONBIO``, ``FIOASYNC``),
213+ * * IOCTL commands targeting file systems (``FIFREEZE``, ``FITHAW``,
214+ * ``FIGETBSZ``, ``FS_IOC_GETFSUUID``, ``FS_IOC_GETFSSYSFSPATH``)
215+ * * Some IOCTL commands which do not make sense when used with devices, but
216+ * whose implementations are safe and return the right error codes
217+ * (``FS_IOC_FIEMAP``, ``FICLONE``, ``FICLONERANGE``, ``FIDEDUPERANGE``)
218+ *
219+ * This access right is available since the fifth version of the Landlock
220+ * ABI.
221+ *
201222 * .. warning::
202223 *
203224 * It is currently not possible to restrict some file-related actions
204225 * accessible through these syscall families: :manpage:`chdir(2)`,
205226 * :manpage:`stat(2)`, :manpage:`flock(2)`, :manpage:`chmod(2)`,
206227 * :manpage:`chown(2)`, :manpage:`setxattr(2)`, :manpage:`utime(2)`,
207− * :manpage:`ioctl(2)`, :manpage:`fcntl(2)`, :manpage:`access(2)`.
228+ * :manpage:`fcntl(2)`, :manpage:`access(2)`.
208229 * Future Landlock evolutions will enable to restrict them.
209230 */
210231 /* clang-format off */
@@ -223,6 +244,7 @@ struct landlock_net_port_attr { · 12 unmodified lines
223244 #define LANDLOCK_ACCESS_FS_MAKE_SYM (1ULL << 12)
224245 #define LANDLOCK_ACCESS_FS_REFER (1ULL << 13)
225246 #define LANDLOCK_ACCESS_FS_TRUNCATE (1ULL << 14)
247+#define LANDLOCK_ACCESS_FS_IOCTL_DEV (1ULL << 15)
226248 /* clang-format on */
227249
228250 /**

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