linux/security/landlock
Günther Noack 672fa082d4
landlock: Require LANDLOCK_ACCESS_FS_MAKE_REG for whiteout creation
Whiteout objects are used in the upper layer of an OverlayFS to
indicate that the file with this name does not exist in the unified
view, even if it is present in one of the lower layer file systems.

For the userspace implementations of OverlayFS (fuse-overlayfs),
whiteout objects can be created from userspace as well:

* mknod(2) with S_IFCHR and makedev(0, 0)
* renameat2(2) with RENAME_WHITEOUT,
  creating the whiteout in the old place of the moved file.

This commit guards whiteout creation in both of these cases with
LANDLOCK_ACCESS_FS_MAKE_REG.  Whiteout objects are *not* considered
character devices and are not bound to a driver.

LANDLOCK_ACCESS_FS_MAKE_REG describes the same permission class as a
whiteout object: creating one is the only S_IFCHR creation that the VFS
exempts from CAP_MKNOD, so it is as unprivileged as creating a regular
file, while LANDLOCK_ACCESS_FS_MAKE_CHAR and
LANDLOCK_ACCESS_FS_MAKE_BLOCK keep meaning the creation of devices that
expose a kernel interface [1].

For the mknod(2) case, introduce a Landlock erratum.  The creation of
whiteout objects through mknod(2) was previously guarded using
LANDLOCK_ACCESS_FS_MAKE_CHAR, and it is now guarded using
LANDLOCK_ACCESS_FS_MAKE_REG.

For the renameat2(2) case, fix a bug: Before this commit, renameat2(2)
with RENAME_WHITEOUT would create a directory entry even when all
LANDLOCK_ACCESS_FS_MAKE_* rights were denied.

This does not affect normal renames within layered OverlayFS mounts:
When doing a regular rename() on a mounted fuse-overlayfs, it is the
fuse-overlayfs daemon that exercises renameat2() with RENAME_WHITEOUT,
and only the Landlock domain of that daemon is checked there.

Suggested-by: Christian Brauner <brauner@kernel.org>
Suggested-by: Mickaël Salaün <mic@digikod.net>
Cc: stable@vger.kernel.org
Fixes: cb2c7d1a17 ("landlock: Support filesystem access-control")
Depends-on: 49c9e09d96 ("landlock: Fix handling of disconnected directories")
Depends-on: fe72ce6710 ("landlock: Add errata documentation section")
Signed-off-by: Günther Noack <gnoack@google.com>
Link: https://patch.msgid.link/20260720.chow9ohYie5b@digikod.net [1]
Link: https://patch.msgid.link/20260813093157.1436894-3-gnoack@google.com
[mic: Record why LANDLOCK_ACCESS_FS_MAKE_REG is the matching right, and
add link(2) to the user doc]
Signed-off-by: Mickaël Salaün <mic@digikod.net>
History 2026-08-15 09:14:43 +02:00
..
errata landlock: Require LANDLOCK_ACCESS_FS_MAKE_REG for whiteout creation 2026-08-15 09:14:43 +02:00
.kunitconfig landlock: Add unique ID generator 2025-03-26 13:59:34 +01:00
access.h landlock: Suppress logging when quiet flag is present 2026-06-14 20:17:19 +02:00
audit.c landlock: Suppress logging when quiet flag is present 2026-06-14 20:17:19 +02:00
audit.h landlock: Suppress logging when quiet flag is present 2026-06-14 20:17:19 +02:00
common.h landlock: Add support for KUnit tests 2024-02-27 11:21:45 +01:00
cred.c landlock: Fix LOG_SUBDOMAINS_OFF inheritance across fork() 2026-04-07 18:50:56 +02:00
cred.h landlock: Improve kernel-doc "Return:" section consistency 2026-04-07 18:51:04 +02:00
domain.c landlock: Suppress logging when quiet flag is present 2026-06-14 20:17:19 +02:00
domain.h landlock: Suppress logging when quiet flag is present 2026-06-14 20:17:19 +02:00
errata.h landlock: Prepare to add second errata 2025-03-21 12:12:21 +01:00
fs.c landlock: Require LANDLOCK_ACCESS_FS_MAKE_REG for whiteout creation 2026-08-15 09:14:43 +02:00
fs.h landlock: Suppress logging when quiet flag is present 2026-06-14 20:17:19 +02:00
id.c landlock: Improve kernel-doc "Return:" section consistency 2026-04-07 18:51:04 +02:00
id.h landlock: Add unique ID generator 2025-03-26 13:59:34 +01:00
Kconfig landlock: Add support for KUnit tests 2024-02-27 11:21:45 +01:00
limits.h landlock: Add a place for flags to layer rules 2026-06-14 20:17:18 +02:00
Makefile landlock: Multithreading support for landlock_restrict_self() 2026-02-06 17:54:37 +01:00
net.c landlock: Fix TCP Fast Open connection bypass 2026-07-10 12:59:07 +02:00
net.h landlock: Add API support and docs for the quiet flags 2026-06-14 20:17:19 +02:00
object.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
object.h landlock: Format with clang-format 2022-05-09 12:31:10 +02:00
ruleset.c landlock: Add API support and docs for the quiet flags 2026-06-14 20:17:19 +02:00
ruleset.h landlock: Fix kernel-doc for the nested quiet layer flag 2026-07-10 12:59:09 +02:00
setup.c lsm: replace the name field with a pointer to the lsm_id struct 2025-10-22 19:24:18 -04:00
setup.h landlock: Add the errata interface 2025-03-21 12:12:19 +01:00
syscalls.c landlock: Add API support and docs for the quiet flags 2026-06-14 20:17:19 +02:00
task.c landlock: Harden sock_is_scoped() against file-less sockets 2026-08-14 12:38:26 +02:00
task.h landlock: Rename "ptrace" files to "task" 2024-03-08 18:22:16 +01:00
tsync.c landlock: Fix formatting in tsync.c 2026-04-07 18:51:04 +02:00
tsync.h landlock: Multithreading support for landlock_restrict_self() 2026-02-06 17:54:37 +01:00