diff options
Diffstat (limited to 'net/sunrpc/auth_unix.c')
-rw-r--r-- | net/sunrpc/auth_unix.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index 306fc0f54596..82337e1ec9cd 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c | |||
@@ -14,12 +14,10 @@ | |||
14 | #include <linux/sunrpc/auth.h> | 14 | #include <linux/sunrpc/auth.h> |
15 | #include <linux/user_namespace.h> | 15 | #include <linux/user_namespace.h> |
16 | 16 | ||
17 | #define NFS_NGROUPS 16 | ||
18 | |||
19 | struct unx_cred { | 17 | struct unx_cred { |
20 | struct rpc_cred uc_base; | 18 | struct rpc_cred uc_base; |
21 | kgid_t uc_gid; | 19 | kgid_t uc_gid; |
22 | kgid_t uc_gids[NFS_NGROUPS]; | 20 | kgid_t uc_gids[UNX_NGROUPS]; |
23 | }; | 21 | }; |
24 | #define uc_uid uc_base.cr_uid | 22 | #define uc_uid uc_base.cr_uid |
25 | 23 | ||
@@ -82,13 +80,13 @@ unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t | |||
82 | 80 | ||
83 | if (acred->group_info != NULL) | 81 | if (acred->group_info != NULL) |
84 | groups = acred->group_info->ngroups; | 82 | groups = acred->group_info->ngroups; |
85 | if (groups > NFS_NGROUPS) | 83 | if (groups > UNX_NGROUPS) |
86 | groups = NFS_NGROUPS; | 84 | groups = UNX_NGROUPS; |
87 | 85 | ||
88 | cred->uc_gid = acred->gid; | 86 | cred->uc_gid = acred->gid; |
89 | for (i = 0; i < groups; i++) | 87 | for (i = 0; i < groups; i++) |
90 | cred->uc_gids[i] = acred->group_info->gid[i]; | 88 | cred->uc_gids[i] = acred->group_info->gid[i]; |
91 | if (i < NFS_NGROUPS) | 89 | if (i < UNX_NGROUPS) |
92 | cred->uc_gids[i] = INVALID_GID; | 90 | cred->uc_gids[i] = INVALID_GID; |
93 | 91 | ||
94 | return &cred->uc_base; | 92 | return &cred->uc_base; |
@@ -132,12 +130,12 @@ unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags) | |||
132 | 130 | ||
133 | if (acred->group_info != NULL) | 131 | if (acred->group_info != NULL) |
134 | groups = acred->group_info->ngroups; | 132 | groups = acred->group_info->ngroups; |
135 | if (groups > NFS_NGROUPS) | 133 | if (groups > UNX_NGROUPS) |
136 | groups = NFS_NGROUPS; | 134 | groups = UNX_NGROUPS; |
137 | for (i = 0; i < groups ; i++) | 135 | for (i = 0; i < groups ; i++) |
138 | if (!gid_eq(cred->uc_gids[i], acred->group_info->gid[i])) | 136 | if (!gid_eq(cred->uc_gids[i], acred->group_info->gid[i])) |
139 | return 0; | 137 | return 0; |
140 | if (groups < NFS_NGROUPS && gid_valid(cred->uc_gids[groups])) | 138 | if (groups < UNX_NGROUPS && gid_valid(cred->uc_gids[groups])) |
141 | return 0; | 139 | return 0; |
142 | return 1; | 140 | return 1; |
143 | } | 141 | } |
@@ -166,7 +164,7 @@ unx_marshal(struct rpc_task *task, __be32 *p) | |||
166 | *p++ = htonl((u32) from_kuid(&init_user_ns, cred->uc_uid)); | 164 | *p++ = htonl((u32) from_kuid(&init_user_ns, cred->uc_uid)); |
167 | *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gid)); | 165 | *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gid)); |
168 | hold = p++; | 166 | hold = p++; |
169 | for (i = 0; i < 16 && gid_valid(cred->uc_gids[i]); i++) | 167 | for (i = 0; i < UNX_NGROUPS && gid_valid(cred->uc_gids[i]); i++) |
170 | *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gids[i])); | 168 | *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gids[i])); |
171 | *hold = htonl(p - hold - 1); /* gid array length */ | 169 | *hold = htonl(p - hold - 1); /* gid array length */ |
172 | *base = htonl((p - base - 1) << 2); /* cred length */ | 170 | *base = htonl((p - base - 1) << 2); /* cred length */ |