nfs: Fix getxattr kernel panic and memory overflow
authorJeffrey Mitchell <jeffrey.mitchell@starlab.io>
Wed, 5 Aug 2020 17:23:19 +0000 (12:23 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 07:48:22 +0000 (09:48 +0200)
commite4ddf4e58946c7dfe8568a21ee3d27b03d96bc56
tree120fde0ba7789bd49a2cf9453a4966ed314e0960
parentd9836942b4388a07e06b4adab253b8cb381ef385
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