Skip to content

Commit 2ff5a1b

Browse files
author
Malahal Naineni
committed
Prevent set_threadgroups() failure
Neither uid nor gid should be -1. If a client sends such a value, setfsuid, setfsuid or __NR_setgroups may fail. Check for invalid uid/gid and return a failure in such a case.
1 parent dadc0cd commit 2ff5a1b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/svc_auth_unix.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,19 @@ _svcauth_unix(struct svc_req *req)
9393
aup->aup_uid = (int)IXDR_GET_INT32(buf);
9494
aup->aup_gid = (int)IXDR_GET_INT32(buf);
9595
gid_len = (size_t) IXDR_GET_U_INT32(buf);
96-
if (gid_len > NGRPS) {
96+
if (gid_len > NGRPS || aup->aup_uid == (uid_t)-1 ||
97+
aup->aup_gid == (gid_t)-1) {
9798
stat = AUTH_BADCRED;
9899
goto done;
99100
}
100101
aup->aup_len = gid_len;
101102
for (i = 0; i < gid_len; i++) {
102103
/* suppress block warning */
103104
aup->aup_gids[i] = (int)IXDR_GET_INT32(buf);
105+
if (aup->aup_gids[i] == (gid_t)-1) {
106+
stat = AUTH_BADCRED;
107+
goto done;
108+
}
104109
}
105110
/*
106111
* five is the smallest unix credentials structure -

0 commit comments

Comments
 (0)