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

sashiko-bot at kernel.org sashiko-bot at kernel.org
Sun Nov 22 19:58:00 UTC 2026


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

commit 5f6b9ba4a78b24bfe4f6ba168eb1ea41dd809f38
Author: Jarkko Sakkinen <jarkko at kernel.org>

fs: Support FSCONFIG_SET_USERLAND in fsconfig()

This commit adds FSCONFIG_SET_USERLAND and the ->set_userland() fs_context
operation so callers with CAP_SYS_ADMIN in a target userland's user
namespace can bind a newly opened fs_context to that userland, and marks
tmpfs, ramfs, and devpts with 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 in an
outer user namespace to configure opts->uid and opts->gid to host UIDs and
GIDs that have no mapping in fc->user_ns?

When a caller binds a devpts context to a target userland via
FSCONFIG_SET_USERLAND and passes uid or gid options, fs_parse() resolves
fsparam_uid and fsparam_gid against current_user_ns() rather than
fc->user_ns.  Unlike shmem_parse_one(), devpts_parse_param() does not
verify that the resulting IDs are mapped in fc->user_ns:

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 newly
allocated slave PTY device inodes on a superblock where SB_I_NODEV is
cleared, creating character device nodes owned by arbitrary unmapped host
UIDs and GIDs inside the userns-mounted devpts instance.

Should devpts_parse_param() check kuid_has_mapping(fc->user_ns, result.uid)
and kgid_has_mapping(fc->user_ns, result.gid) before accepting Opt_uid and
Opt_gid?

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



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