NFSD: Fix exposure in nfsd4_decode_bitmap()
authorChuck Lever <chuck.lever@oracle.com>
Sun, 14 Nov 2021 20:16:04 +0000 (15:16 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Nov 2021 08:48:35 +0000 (09:48 +0100)
commit10c22d9519f3f5939de61a1500aa3a926b778d3a
tree71c54b1c33a2532648cef30cf4cdc45bcbf99ca4
parentf6218db543517082b45f553b39f7731d6535126c
NFSD: Fix exposure in nfsd4_decode_bitmap()

[ Upstream commit c0019b7db1d7ac62c711cda6b357a659d46428fe ]

rtm@csail.mit.edu reports:
> nfsd4_decode_bitmap4() will write beyond bmval[bmlen-1] if the RPC
> directs it to do so. This can cause nfsd4_decode_state_protect4_a()
> to write client-supplied data beyond the end of
> nfsd4_exchange_id.spo_must_allow[] when called by
> nfsd4_decode_exchange_id().

Rewrite the loops so nfsd4_decode_bitmap() cannot iterate beyond
@bmlen.

Reported by: rtm@csail.mit.edu
Fixes: d1c263a031e8 ("NFSD: Replace READ* macros in nfsd4_decode_fattr()")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfsd/nfs4xdr.c