All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv3 1/2] groups: Factor out a function to set a pre-sorted group list
@ 2014-11-15 23:49 Josh Triplett
       [not found] ` <3ccec8a13019b5e8ce7b1d7889677b778b070dc8.1416095211.git.josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>
  2014-11-15 23:50 ` [PATCH] getgroups.2: Document unprivileged setgroups calls Josh Triplett
  0 siblings, 2 replies; 4+ messages in thread
From: Josh Triplett @ 2014-11-15 23:49 UTC (permalink / raw)
  To: Andrew Morton, Andy Lutomirski, Eric W. Biederman, Kees Cook,
	mtk.manpages, linux-api, linux-man, linux-kernel

This way, functions that already need to sort the group list need not do
so twice.

The new set_groups_sorted is intentionally not exported.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---
v2, v3: No changes to patch 1/2.
 kernel/groups.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/kernel/groups.c b/kernel/groups.c
index 451698f..f0667e7 100644
--- a/kernel/groups.c
+++ b/kernel/groups.c
@@ -154,16 +154,26 @@ int groups_search(const struct group_info *group_info, kgid_t grp)
 }
 
 /**
+ * set_groups_sorted - Change a group subscription in a set of credentials
+ * @new: The newly prepared set of credentials to alter
+ * @group_info: The group list to install; must be sorted
+ */
+static void set_groups_sorted(struct cred *new, struct group_info *group_info)
+{
+	put_group_info(new->group_info);
+	get_group_info(group_info);
+	new->group_info = group_info;
+}
+
+/**
  * set_groups - Change a group subscription in a set of credentials
  * @new: The newly prepared set of credentials to alter
  * @group_info: The group list to install
  */
 void set_groups(struct cred *new, struct group_info *group_info)
 {
-	put_group_info(new->group_info);
 	groups_sort(group_info);
-	get_group_info(group_info);
-	new->group_info = group_info;
+	set_groups_sorted(new, group_info);
 }
 
 EXPORT_SYMBOL(set_groups);
-- 
2.1.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-11-15 23:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-15 23:49 [PATCHv3 1/2] groups: Factor out a function to set a pre-sorted group list Josh Triplett
     [not found] ` <3ccec8a13019b5e8ce7b1d7889677b778b070dc8.1416095211.git.josh-iaAMLnmF4UmaiuxdJuQwMA@public.gmane.org>
2014-11-15 23:50   ` [PATCHv3 2/2] groups: Allow unprivileged processes to use setgroups to drop groups Josh Triplett
2014-11-15 23:50     ` Josh Triplett
2014-11-15 23:50 ` [PATCH] getgroups.2: Document unprivileged setgroups calls Josh Triplett

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.