The old-kernel subdir path uses namespace unsharing and string-based
move_mount() which is unsafe for restricted users (TOCTOU). The safe
detached subdir open requires Linux >= 6.15.
Signed-off-by: Karel Zak <kzak@redhat.com>
}
#endif
+ if (mnt_context_target_fd_required(cxt)) {
+ DBG_OBJ(HOOK, hs, ul_debug(
+ "subdir mount refused for non-root user (kernel < 6.15)"));
+ return -ENOTSUP;
+ }
+
/* create unhared temporary target */
hsd->org_target = strdup(mnt_fs_get_target(cxt->fs));
if (!hsd->org_target)
+
Note that this feature will not work in session with an unshared private mount namespace (after *unshare --mount*) on old kernels or with *mount*(8) without support for file-descriptors-based mount kernel API. In this case, you need *unshare --mount --propagation shared*.
+
+For unprivileged (non-root) users, this feature requires Linux >= 6.15 where the subdirectory is opened directly on the detached mount tree.
++
This feature is EXPERIMENTAL.
*X-mount.owner*=_username_|_UID_, *X-mount.group*=_group_|_GID_::