nfs: Fix getxattr kernel panic and memory overflow
commit75cf7f895f563e14c82c1aeea0362dc155b5baf3
authorJeffrey Mitchell <jeffrey.mitchell@starlab.io>
Wed, 5 Aug 2020 17:23:19 +0000 (5 12:23 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 11:05:37 +0000 (21 13:05 +0200)
tree8139dd63f64f253399144b1183aae9343a5997b4
parentd09d6dca89e948ddddf2b0c509b05b8cd71626de
nfs: Fix getxattr kernel panic and memory overflow

[ Upstream commit b4487b93545214a9db8cbf32e86411677b0cca21 ]

Move the buffer size check to decode_attr_security_label() before memcpy()
Only call memcpy() if the buffer is large enough

Fixes: aa9c2669626c ("NFS: Client implementation of Labeled-NFS")
Signed-off-by: Jeffrey Mitchell <jeffrey.mitchell@starlab.io>
[Trond: clean up duplicate test of label->len != 0]
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/nfs4proc.c
fs/nfs/nfs4xdr.c