Commit 49cecd86 authored by Chuck Lever's avatar Chuck Lever

NFSD: Update nfsd_cache_append() to use xdr_stream

When inserting a DRC-cached response into the reply buffer, ensure
that the reply buffer's xdr_stream is updated properly. Otherwise
the server will send a garbage response.

Cc: stable@vger.kernel.org # v6.3+
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Tested-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent bc1b5acb
...@@ -640,24 +640,17 @@ void nfsd_cache_update(struct svc_rqst *rqstp, struct nfsd_cacherep *rp, ...@@ -640,24 +640,17 @@ void nfsd_cache_update(struct svc_rqst *rqstp, struct nfsd_cacherep *rp,
return; return;
} }
/*
* Copy cached reply to current reply buffer. Should always fit.
* FIXME as reply is in a page, we should just attach the page, and
* keep a refcount....
*/
static int static int
nfsd_cache_append(struct svc_rqst *rqstp, struct kvec *data) nfsd_cache_append(struct svc_rqst *rqstp, struct kvec *data)
{ {
struct kvec *vec = &rqstp->rq_res.head[0]; __be32 *p;
if (vec->iov_len + data->iov_len > PAGE_SIZE) { p = xdr_reserve_space(&rqstp->rq_res_stream, data->iov_len);
printk(KERN_WARNING "nfsd: cached reply too large (%zd).\n", if (unlikely(!p))
data->iov_len); return false;
return 0; memcpy(p, data->iov_base, data->iov_len);
} xdr_commit_encode(&rqstp->rq_res_stream);
memcpy((char*)vec->iov_base + vec->iov_len, data->iov_base, data->iov_len); return true;
vec->iov_len += data->iov_len;
return 1;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment