nfsd: restrict rd_maxcount to svc_max_payload in nfsd_encode_readdir
commit626fb93235dc1cc8c52478712737ffd4451301e7
authorScott Mayhew <smayhew@redhat.com>
Mon, 7 May 2018 13:01:08 +0000 (7 09:01 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 3 Jul 2018 09:18:48 +0000 (3 11:18 +0200)
tree4c3c08469f4612b8f7f20d32ec752132ae11d30a
parentea5c4686be7fc4d6d618529910e06d1b5255fcc2
nfsd: restrict rd_maxcount to svc_max_payload in nfsd_encode_readdir

commit 9c2ece6ef67e9d376f32823086169b489c422ed0 upstream.

nfsd4_readdir_rsize restricts rd_maxcount to svc_max_payload when
estimating the size of the readdir reply, but nfsd_encode_readdir
restricts it to INT_MAX when encoding the reply.  This can result in log
messages like "kernel: RPC request reserved 32896 but used 1049444".

Restrict rd_dircount similarly (no reason it should be larger than
svc_max_payload).

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nfsd/nfs4xdr.c