Skip to content

Commit 8fbba96

Browse files
author
J. Bruce Fields
committed
nfsd4: stricter cred comparison for setclientid/exchange_id
The typical setclientid or exchange_id will probably be performed with a credential that maps to either root or nobody, so comparing just uid's is unlikely to be useful. So, use everything else we can get our hands on. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 03a4e1f commit 8fbba96

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

‎fs/nfsd/nfs4state.c‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,11 +1201,31 @@ same_clid(clientid_t *cl1, clientid_t *cl2)
12011201
return (cl1->cl_boot == cl2->cl_boot) && (cl1->cl_id == cl2->cl_id);
12021202
}
12031203

1204+
static bool groups_equal(struct group_info *g1, struct group_info *g2)
1205+
{
1206+
int i;
1207+
1208+
if (g1->ngroups != g2->ngroups)
1209+
return false;
1210+
for (i=0; i<g1->ngroups; i++)
1211+
if (GROUP_AT(g1, i) != GROUP_AT(g2, i))
1212+
return false;
1213+
return true;
1214+
}
1215+
12041216
/* XXX what about NGROUP */
12051217
static int
12061218
same_creds(struct svc_cred *cr1, struct svc_cred *cr2)
12071219
{
1208-
return cr1->cr_uid == cr2->cr_uid;
1220+
if ((cr1->cr_uid != cr2->cr_uid)
1221+
|| (cr1->cr_gid != cr2->cr_gid)
1222+
|| !groups_equal(cr1->cr_group_info, cr2->cr_group_info))
1223+
return false;
1224+
if (cr1->cr_principal == cr2->cr_principal)
1225+
return true;
1226+
if (!cr1->cr_principal || !cr2->cr_principal)
1227+
return false;
1228+
return 0 == strcmp(cr1->cr_principal, cr1->cr_principal);
12091229
}
12101230

12111231
static void gen_clid(struct nfs4_client *clp)

0 commit comments

Comments
 (0)