lkml.org 
[lkml]   [2021]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2021-05-15 03:25    [W:0.144 / U:0.792 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site