nfsd4: fix bad bounds checking
authorJ. Bruce Fields <bfields@redhat.com>
Tue, 1 Mar 2016 01:21:21 +0000 (20:21 -0500)
committerSasha Levin <sasha.levin@oracle.com>
Mon, 18 Apr 2016 12:50:44 +0000 (08:50 -0400)
commitd876f71611ad9b720cc890075b3c4bec25bd54b5
tree2cf825e40aa635a1796a17d480bc7aa69cbc223c
parent58d550f06dfefe06ae1afed7a2ffaa333d19dfec
nfsd4: fix bad bounds checking

[ Upstream commit 4aed9c46afb80164401143aa0fdcfe3798baa9d5 ]

A number of spots in the xdr decoding follow a pattern like

n = be32_to_cpup(p++);
READ_BUF(n + 4);

where n is a u32.  The only bounds checking is done in READ_BUF itself,
but since it's checking (n + 4), it won't catch cases where n is very
large, (u32)(-4) or higher.  I'm not sure exactly what the consequences
are, but we've seen crashes soon after.

Instead, just break these up into two READ_BUF()s.

Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
fs/nfsd/nfs4xdr.c