Skip to content

Commit 49cecd8

Browse files
committed
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: Jeff Layton <jlayton@kernel.org> Tested-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent bc1b5ac commit 49cecd8

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

fs/nfsd/nfscache.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -640,24 +640,17 @@ void nfsd_cache_update(struct svc_rqst *rqstp, struct nfsd_cacherep *rp,
640640
return;
641641
}
642642

643-
/*
644-
* Copy cached reply to current reply buffer. Should always fit.
645-
* FIXME as reply is in a page, we should just attach the page, and
646-
* keep a refcount....
647-
*/
648643
static int
649644
nfsd_cache_append(struct svc_rqst *rqstp, struct kvec *data)
650645
{
651-
struct kvec *vec = &rqstp->rq_res.head[0];
652-
653-
if (vec->iov_len + data->iov_len > PAGE_SIZE) {
654-
printk(KERN_WARNING "nfsd: cached reply too large (%zd).\n",
655-
data->iov_len);
656-
return 0;
657-
}
658-
memcpy((char*)vec->iov_base + vec->iov_len, data->iov_base, data->iov_len);
659-
vec->iov_len += data->iov_len;
660-
return 1;
646+
__be32 *p;
647+
648+
p = xdr_reserve_space(&rqstp->rq_res_stream, data->iov_len);
649+
if (unlikely(!p))
650+
return false;
651+
memcpy(p, data->iov_base, data->iov_len);
652+
xdr_commit_encode(&rqstp->rq_res_stream);
653+
return true;
661654
}
662655

663656
/*

0 commit comments

Comments
 (0)