aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWang YanQing <udknight@gmail.com>2014-04-03 17:48:26 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-03 19:21:05 -0400
commit8f6c5ffc8987f4f5b5a3e9d557d94bbf3a9bf216 (patch)
tree79ea014021610d9a6057c070e1208542fd014e33
parent6af9f7bf3c399e0ab1eee048e13572c6d4e15fe9 (diff)
kernel/groups.c: remove return value of set_groups
After commit 6307f8fee295 ("security: remove dead hook task_setgroups"), set_groups will always return zero, so we could just remove return value of set_groups. This patch reduces code size, and simplfies code to use set_groups, because we don't need to check its return value any more. [akpm@linux-foundation.org: remove obsolete claims from set_groups() comment] Signed-off-by: Wang YanQing <udknight@gmail.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Serge Hallyn <serge.hallyn@canonical.com> Cc: Eric Paris <eparis@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/nfsd/auth.c5
-rw-r--r--include/linux/cred.h2
-rw-r--r--kernel/groups.c14
3 files changed, 4 insertions, 17 deletions
diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c
index 06cddd572264..2645be435e75 100644
--- a/fs/nfsd/auth.c
+++ b/fs/nfsd/auth.c
@@ -71,10 +71,8 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
71 if (gid_eq(new->fsgid, INVALID_GID)) 71 if (gid_eq(new->fsgid, INVALID_GID))
72 new->fsgid = exp->ex_anon_gid; 72 new->fsgid = exp->ex_anon_gid;
73 73
74 ret = set_groups(new, gi); 74 set_groups(new, gi);
75 put_group_info(gi); 75 put_group_info(gi);
76 if (ret < 0)
77 goto error;
78 76
79 if (!uid_eq(new->fsuid, GLOBAL_ROOT_UID)) 77 if (!uid_eq(new->fsuid, GLOBAL_ROOT_UID))
80 new->cap_effective = cap_drop_nfsd_set(new->cap_effective); 78 new->cap_effective = cap_drop_nfsd_set(new->cap_effective);
@@ -89,7 +87,6 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
89 87
90oom: 88oom:
91 ret = -ENOMEM; 89 ret = -ENOMEM;
92error:
93 abort_creds(new); 90 abort_creds(new);
94 return ret; 91 return ret;
95} 92}
diff --git a/include/linux/cred.h b/include/linux/cred.h
index 04421e825365..f61d6c8f5ef3 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -66,7 +66,7 @@ extern struct group_info *groups_alloc(int);
66extern struct group_info init_groups; 66extern struct group_info init_groups;
67extern void groups_free(struct group_info *); 67extern void groups_free(struct group_info *);
68extern int set_current_groups(struct group_info *); 68extern int set_current_groups(struct group_info *);
69extern int set_groups(struct cred *, struct group_info *); 69extern void set_groups(struct cred *, struct group_info *);
70extern int groups_search(const struct group_info *, kgid_t); 70extern int groups_search(const struct group_info *, kgid_t);
71 71
72/* access the groups "array" with this macro */ 72/* access the groups "array" with this macro */
diff --git a/kernel/groups.c b/kernel/groups.c
index 90cf1c38c8ea..451698f86cfa 100644
--- a/kernel/groups.c
+++ b/kernel/groups.c
@@ -157,17 +157,13 @@ int groups_search(const struct group_info *group_info, kgid_t grp)
157 * set_groups - Change a group subscription in a set of credentials 157 * set_groups - Change a group subscription in a set of credentials
158 * @new: The newly prepared set of credentials to alter 158 * @new: The newly prepared set of credentials to alter
159 * @group_info: The group list to install 159 * @group_info: The group list to install
160 *
161 * Validate a group subscription and, if valid, insert it into a set
162 * of credentials.
163 */ 160 */
164int set_groups(struct cred *new, struct group_info *group_info) 161void set_groups(struct cred *new, struct group_info *group_info)
165{ 162{
166 put_group_info(new->group_info); 163 put_group_info(new->group_info);
167 groups_sort(group_info); 164 groups_sort(group_info);
168 get_group_info(group_info); 165 get_group_info(group_info);
169 new->group_info = group_info; 166 new->group_info = group_info;
170 return 0;
171} 167}
172 168
173EXPORT_SYMBOL(set_groups); 169EXPORT_SYMBOL(set_groups);
@@ -182,18 +178,12 @@ EXPORT_SYMBOL(set_groups);
182int set_current_groups(struct group_info *group_info) 178int set_current_groups(struct group_info *group_info)
183{ 179{
184 struct cred *new; 180 struct cred *new;
185 int ret;
186 181
187 new = prepare_creds(); 182 new = prepare_creds();
188 if (!new) 183 if (!new)
189 return -ENOMEM; 184 return -ENOMEM;
190 185
191 ret = set_groups(new, group_info); 186 set_groups(new, group_info);
192 if (ret < 0) {
193 abort_creds(new);
194 return ret;
195 }
196
197 return commit_creds(new); 187 return commit_creds(new);
198} 188}
199 189