SUNRPC: fix copying of multiple pages in gss_read_proxy_verf()
[ Upstream commitd48c812474
] 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:5866efa8cb
"SUNRPC: Fix svcauth_gss_proxy_init()" Signed-off-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
e412625f38
commit
6498597aeb
|
@ -1095,9 +1095,9 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
|
||||||
struct gssp_in_token *in_token)
|
struct gssp_in_token *in_token)
|
||||||
{
|
{
|
||||||
struct kvec *argv = &rqstp->rq_arg.head[0];
|
struct kvec *argv = &rqstp->rq_arg.head[0];
|
||||||
unsigned int page_base, length;
|
unsigned int length, pgto_offs, pgfrom_offs;
|
||||||
int pages, i, res;
|
int pages, i, res, pgto, pgfrom;
|
||||||
size_t inlen;
|
size_t inlen, to_offs, from_offs;
|
||||||
|
|
||||||
res = gss_read_common_verf(gc, argv, authp, in_handle);
|
res = gss_read_common_verf(gc, argv, authp, in_handle);
|
||||||
if (res)
|
if (res)
|
||||||
|
@ -1125,17 +1125,24 @@ static int gss_read_proxy_verf(struct svc_rqst *rqstp,
|
||||||
memcpy(page_address(in_token->pages[0]), argv->iov_base, length);
|
memcpy(page_address(in_token->pages[0]), argv->iov_base, length);
|
||||||
inlen -= length;
|
inlen -= length;
|
||||||
|
|
||||||
i = 1;
|
to_offs = length;
|
||||||
page_base = rqstp->rq_arg.page_base;
|
from_offs = rqstp->rq_arg.page_base;
|
||||||
while (inlen) {
|
while (inlen) {
|
||||||
length = min_t(unsigned int, inlen, PAGE_SIZE);
|
pgto = to_offs >> PAGE_SHIFT;
|
||||||
memcpy(page_address(in_token->pages[i]),
|
pgfrom = from_offs >> PAGE_SHIFT;
|
||||||
page_address(rqstp->rq_arg.pages[i]) + page_base,
|
pgto_offs = to_offs & ~PAGE_MASK;
|
||||||
|
pgfrom_offs = from_offs & ~PAGE_MASK;
|
||||||
|
|
||||||
|
length = min_t(unsigned int, inlen,
|
||||||
|
min_t(unsigned int, PAGE_SIZE - pgto_offs,
|
||||||
|
PAGE_SIZE - pgfrom_offs));
|
||||||
|
memcpy(page_address(in_token->pages[pgto]) + pgto_offs,
|
||||||
|
page_address(rqstp->rq_arg.pages[pgfrom]) + pgfrom_offs,
|
||||||
length);
|
length);
|
||||||
|
|
||||||
|
to_offs += length;
|
||||||
|
from_offs += length;
|
||||||
inlen -= length;
|
inlen -= length;
|
||||||
page_base = 0;
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue