Messages in this thread | | | Date | Fri, 14 May 2021 20:24:24 -0500 | From | "Serge E. Hallyn" <> | Subject | Re: [RFC PATCH 3/3] proc: hide unknown groups in status |
| |
On Mon, May 10, 2021 at 03:00:11PM +0200, Giuseppe Scrivano wrote: > when the "shadow" mode is enabled for the user namespace, do not copy > to userspace the groups that are not mapped. > > Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
> --- > fs/proc/array.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/fs/proc/array.c b/fs/proc/array.c > index 7ec59171f197..81dc733773d4 100644 > --- a/fs/proc/array.c > +++ b/fs/proc/array.c > @@ -202,9 +202,17 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns, > > seq_puts(m, "\nGroups:\t"); > group_info = cred->group_info; > - for (g = 0; g < group_info->ngroups; g++) > + for (g = 0; g < group_info->ngroups; g++) { > + gid_t gid = from_kgid(user_ns, group_info->gid[g]); > + > + if (gid == (gid_t)-1) { > + if (user_ns->flags & USERNS_SETGROUPS_SHADOW) > + continue; > + gid = overflowgid; > + } > seq_put_decimal_ull(m, g ? " " : "", > - from_kgid_munged(user_ns, group_info->gid[g])); > + gid); > + } > put_cred(cred); > /* Trailing space shouldn't have been added in the first place. */ > seq_putc(m, ' '); > -- > 2.31.1
| |