[RFC PATCH v6 18/26] fs: Support FSCONFIG_SET_USERLAND in fsconfig()

sashiko-bot at kernel.org sashiko-bot at kernel.org
Sun Nov 22 01:45:32 UTC 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] devpts: missing fc->user_ns uid/gid mapping check in
  devpts_parse_param()
--

commit 3b686423ce72875c03141d25884aa118403b95e4
Author: Jarkko Sakkinen <jarkko at kernel.org>

fs: Support FSCONFIG_SET_USERLAND in fsconfig()

This commit adds FSCONFIG_SET_USERLAND to bind an fs_context to a target
userland's user and network namespaces before parameter configuration, and
opts tmpfs, ramfs, and devpts into FS_USERLAND_MOUNT.

> diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
> index bd1e8eb26edb7..921b67d18fa2e 100644
> --- a/fs/devpts/inode.c
> +++ b/fs/devpts/inode.c
[ ... ]
> @@ -457,7 +459,7 @@ static struct file_system_type devpts_fs_type = {
>  	.init_fs_context = devpts_init_fs_context,
>  	.parameters	= devpts_param_specs,
>  	.kill_sb	= devpts_kill_sb,
> -	.fs_flags	= FS_USERNS_MOUNT,
> +	.fs_flags	= FS_USERNS_MOUNT | FS_USERLAND_MOUNT,
>  };

[Severity: High]
Can opting devpts into FS_USERLAND_MOUNT allow an unprivileged user to
create slave PTY device nodes owned by arbitrary host UIDs and GIDs that
are not mapped in fc->user_ns?

When a process in init_user_ns binds a devpts context to a child userland
via FSCONFIG_SET_USERLAND and passes uid or gid options, fs_param_is_uid()
and fs_param_is_gid() resolve them against current_user_ns() rather than
fc->user_ns.  Unlike shmem_parse_one(), devpts_parse_param() does not
verify kuid_has_mapping(fc->user_ns, result.uid) or
kgid_has_mapping(fc->user_ns, result.gid):

fs/devpts/inode.c:devpts_parse_param() {
    ...
	case Opt_uid:
		opts->uid = result.uid;
		opts->setuid = 1;
		break;
	case Opt_gid:
		opts->gid = result.gid;
		opts->setgid = 1;
		break;
    ...
}

devpts_pty_new() then assigns opts->uid and opts->gid directly to
inode->i_uid and inode->i_gid on the userns-owned superblock, allowing
slave PTY device nodes to be created with unmapped host IDs such as
GLOBAL_ROOT_UID.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261122011809.2667684-1-jarkko@kernel.org?part=18



More information about the Linux-security-module-archive mailing list