Skip to content

Commit 8f6c5ff

Browse files
wyqkptorvalds
authored andcommitted
kernel/groups.c: remove return value of set_groups
After commit 6307f8f ("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>
1 parent 6af9f7b commit 8f6c5ff

3 files changed

Lines changed: 4 additions & 17 deletions

File tree

fs/nfsd/auth.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,8 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
7171
if (gid_eq(new->fsgid, INVALID_GID))
7272
new->fsgid = exp->ex_anon_gid;
7373

74-
ret = set_groups(new, gi);
74+
set_groups(new, gi);
7575
put_group_info(gi);
76-
if (ret < 0)
77-
goto error;
7876

7977
if (!uid_eq(new->fsuid, GLOBAL_ROOT_UID))
8078
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)
8987

9088
oom:
9189
ret = -ENOMEM;
92-
error:
9390
abort_creds(new);
9491
return ret;
9592
}

include/linux/cred.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extern struct group_info *groups_alloc(int);
6666
extern struct group_info init_groups;
6767
extern void groups_free(struct group_info *);
6868
extern int set_current_groups(struct group_info *);
69-
extern int set_groups(struct cred *, struct group_info *);
69+
extern void set_groups(struct cred *, struct group_info *);
7070
extern int groups_search(const struct group_info *, kgid_t);
7171

7272
/* access the groups "array" with this macro */

kernel/groups.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,13 @@ int groups_search(const struct group_info *group_info, kgid_t grp)
157157
* set_groups - Change a group subscription in a set of credentials
158158
* @new: The newly prepared set of credentials to alter
159159
* @group_info: The group list to install
160-
*
161-
* Validate a group subscription and, if valid, insert it into a set
162-
* of credentials.
163160
*/
164-
int set_groups(struct cred *new, struct group_info *group_info)
161+
void set_groups(struct cred *new, struct group_info *group_info)
165162
{
166163
put_group_info(new->group_info);
167164
groups_sort(group_info);
168165
get_group_info(group_info);
169166
new->group_info = group_info;
170-
return 0;
171167
}
172168

173169
EXPORT_SYMBOL(set_groups);
@@ -182,18 +178,12 @@ EXPORT_SYMBOL(set_groups);
182178
int set_current_groups(struct group_info *group_info)
183179
{
184180
struct cred *new;
185-
int ret;
186181

187182
new = prepare_creds();
188183
if (!new)
189184
return -ENOMEM;
190185

191-
ret = set_groups(new, group_info);
192-
if (ret < 0) {
193-
abort_creds(new);
194-
return ret;
195-
}
196-
186+
set_groups(new, group_info);
197187
return commit_creds(new);
198188
}
199189

0 commit comments

Comments
 (0)