> proc: Implement ->set_run() fs_context operation TL;DR: The procfs gid= change may be an unintended user-visible behaviour change: mounts and remounts that worked before (e.g. with pidns= or from an ancestor userns) may now fail with -EINVAL. Should it be a separate patch? > diff --git a/fs/proc/root.c b/fs/proc/root.c > --- a/fs/proc/root.c > +++ b/fs/proc/root.c [ ... ] > @@ -178,7 +180,9 @@ static int proc_parse_param(struct fs_context *fc, struct fs_parameter *param) > > switch (opt) { > case Opt_gid: > - ctx->gid = result.uint_32; > + if (!kgid_has_mapping(fc->user_ns, result.gid)) > + return invalfc(fc, "Invalid gid"); > + ctx->gid = result.gid; > break; [ ... ] > @@ -234,8 +241,11 @@ static int proc_apply_options(struct proc_fs_info *fs_info, > ctx->pidonly != fs_info->pidonly) > return invalf(fc, "proc: subset=pid cannot be changed\n"); > > - if (ctx->mask & (1 << Opt_gid)) > - fs_info->pid_gid = make_kgid(user_ns, ctx->gid); > + if (ctx->mask & (1 << Opt_gid)) { > + if (!kgid_has_mapping(fc->user_ns, ctx->gid)) > + return invalfc(fc, "Invalid gid"); > + fs_info->pid_gid = ctx->gid; > + } Is it intended to change how gid= is handled for every procfs mount and remount, rather than only run-bound ones? The changelog only describes ->set_run(). The option used to be a u32 converted with make_kgid(current_user_ns(), ...) when applied. It is now converted at parse time by fs_param_is_gid(), and the resulting kgid must also be mapped in fc->user_ns, both in proc_parse_param() and in proc_apply_options(). Mounts that worked before can now fail with -EINVAL when the caller's user namespace is an ancestor of the procfs owner and the group is not mapped into that owner. For example, host root runs: mount -t proc -o pidns=/proc//ns/pid,gid= proc /mnt against a user-namespaced container. proc_parse_pidns_param() sets: fc->user_ns = get_user_ns(ctx->pid_ns->user_ns); to the container's user namespace. If gid= comes after pidns=, proc_parse_param() rejects it immediately with "Invalid gid". If gid= comes first, proc_fill_super() -> proc_apply_options() rejects it. Before the patch both orders succeeded and pid_gid was set to the host kgid. The same happens when host root enters only the container's pid and mount namespaces (nsenter -p -m, without -U) and mounts or remounts proc with gid=. For a remount, fc->user_ns is s_user_ns, which is now kept by the new FS_CONTEXT_FOR_RECONFIGURE branch in proc_init_fs_context(). Also, gid=4294967295 is now refused by fs_param_is_gid()'s gid_valid() check, where before it was silently stored as INVALID_GID. The stricter rule matches tmpfs, devpts and bpffs and may well be intended, but it is a user-visible restriction on an existing mount option, and Documentation/filesystems/proc.rst does not mention it. The s_fs_info move in proc_fill_super() and the reconfigure branch in proc_init_fs_context() exist only to support this new check. Should the gid change be a separate patch, with its own rationale and a note on the compatibility impact for pidns= and remount users? [ ... ] --- AI reviewed your patch. Please fix the bug or email reply why it's not a bug. See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md CI run summary: https://github.com/kernel-patches/bpf/actions/runs/47474652355