]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/filesystems: test completing a context from another user namespace
authorChristian Brauner <brauner@kernel.org>
Sun, 2 Aug 2026 18:00:45 +0000 (20:00 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 10 Aug 2026 07:35:54 +0000 (09:35 +0200)
commitd64ba78b749ad6bae0e9a6f40614eda1c7db2f04
tree15e7026ec194c341c3c376a85601ff4690e77bda
parent79fdf39f1a31f88cb3833b6f8091fbf6acdca2c6
selftests/filesystems: test completing a context from another user namespace

fsopen() records the caller's user namespace in fc->user_ns and hands
back an ordinary file descriptor, so the task that issues
FSCONFIG_CMD_CREATE need not be the one that created the context.
mount_capable() authorizes that for a caller holding CAP_SYS_ADMIN in an
ancestor of fc->user_ns, which any unprivileged user has over a user
namespace it just created.

binfmt_misc and overlayfs used to WARN_ON() the mismatch. Add a test for
both. Also cover the handover within one user namespace. That is a
supported thing to do and has to keep working.

Link: https://patch.msgid.link/20260802-work-fill_super-warn-v1-3-4e987911a39a@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
tools/testing/selftests/Makefile
tools/testing/selftests/filesystems/fscontext_ns/Makefile [new file with mode: 0644]
tools/testing/selftests/filesystems/fscontext_ns/fscontext_ns_test.c [new file with mode: 0644]