[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210510130011.1441834-4-gscrivan@redhat.com>
Date: Mon, 10 May 2021 15:00:11 +0200
From: Giuseppe Scrivano <gscrivan@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: serge@...lyn.com, dwalsh@...hat.com, christian.brauner@...ntu.com,
ebiederm@...ssion.com
Subject: [RFC PATCH 3/3] proc: hide unknown groups in status
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@...hat.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
Powered by blists - more mailing lists