SUNRPC: Fix leak of krb5p encode pages

commit 8dae5398ab upstream.

call_encode can be invoked more than once per RPC call. Ensure that
each call to gss_wrap_req_priv does not overwrite pointers to
previously allocated memory.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: stable@kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Chuck Lever 2018-11-30 15:39:57 -05:00 committed by Greg Kroah-Hartman
parent e32c7473a4
commit 5f3c652e0f
1 changed files with 4 additions and 0 deletions

View File

@ -1722,6 +1722,7 @@ priv_release_snd_buf(struct rpc_rqst *rqstp)
for (i=0; i < rqstp->rq_enc_pages_num; i++)
__free_page(rqstp->rq_enc_pages[i]);
kfree(rqstp->rq_enc_pages);
rqstp->rq_release_snd_buf = NULL;
}
static int
@ -1730,6 +1731,9 @@ alloc_enc_pages(struct rpc_rqst *rqstp)
struct xdr_buf *snd_buf = &rqstp->rq_snd_buf;
int first, last, i;
if (rqstp->rq_release_snd_buf)
rqstp->rq_release_snd_buf(rqstp);
if (snd_buf->page_len == 0) {
rqstp->rq_enc_pages_num = 0;
return 0;