Skip to content

Commit 6498597

Browse files
martijndegouwgregkh
authored andcommitted
SUNRPC: fix copying of multiple pages in gss_read_proxy_verf()
[ Upstream commit d48c812 ] When the passed token is longer than 4032 bytes, the remaining part of the token must be copied from the rqstp->rq_arg.pages. But the copy must make sure it happens in a consecutive way. With the existing code, the first memcpy copies 'length' bytes from argv->iobase, but since the header is in front, this never fills the whole first page of in_token->pages. The mecpy in the loop copies the following bytes, but starts writing at the next page of in_token->pages. This leaves the last bytes of page 0 unwritten. Symptoms were that users with many groups were not able to access NFS exports, when using Active Directory as the KDC. Signed-off-by: Martijn de Gouw <martijn.de.gouw@prodrive-technologies.com> Fixes: 5866efa "SUNRPC: Fix svcauth_gss_proxy_init()" Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e412625 commit 6498597

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

‎net/sunrpc/auth_gss/svcauth_gss.c‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,9 +1095,9 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
10951095
struct gssp_in_token *in_token)
10961096
{
10971097
struct kvec *argv = &rqstp->rq_arg.head[0];
1098-
unsigned int page_base, length;
1099-
int pages, i, res;
1100-
size_t inlen;
1098+
unsigned int length, pgto_offs, pgfrom_offs;
1099+
int pages, i, res, pgto, pgfrom;
1100+
size_t inlen, to_offs, from_offs;
11011101

11021102
res = gss_read_common_verf(gc, argv, authp, in_handle);
11031103
if (res)
@@ -1125,17 +1125,24 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
11251125
memcpy(page_address(in_token->pages[0]), argv->iov_base, length);
11261126
inlen -= length;
11271127

1128-
i = 1;
1129-
page_base = rqstp->rq_arg.page_base;
1128+
to_offs = length;
1129+
from_offs = rqstp->rq_arg.page_base;
11301130
while (inlen) {
1131-
length = min_t(unsigned int, inlen, PAGE_SIZE);
1132-
memcpy(page_address(in_token->pages[i]),
1133-
page_address(rqstp->rq_arg.pages[i]) + page_base,
1131+
pgto = to_offs >> PAGE_SHIFT;
1132+
pgfrom = from_offs >> PAGE_SHIFT;
1133+
pgto_offs = to_offs & ~PAGE_MASK;
1134+
pgfrom_offs = from_offs & ~PAGE_MASK;
1135+
1136+
length = min_t(unsigned int, inlen,
1137+
min_t(unsigned int, PAGE_SIZE - pgto_offs,
1138+
PAGE_SIZE - pgfrom_offs));
1139+
memcpy(page_address(in_token->pages[pgto]) + pgto_offs,
1140+
page_address(rqstp->rq_arg.pages[pgfrom]) + pgfrom_offs,
11341141
length);
11351142

1143+
to_offs += length;
1144+
from_offs += length;
11361145
inlen -= length;
1137-
page_base = 0;
1138-
i++;
11391146
}
11401147
return 0;
11411148
}

0 commit comments

Comments
 (0)