ceph: return -ERANGE if virtual xattr value didn't fit in buffer
authorJeff Layton <jlayton@kernel.org>
Thu, 13 Jun 2019 19:17:00 +0000 (15:17 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 6 Aug 2019 16:29:36 +0000 (18:29 +0200)
commit679ff6a3e4ccb02efabf6f8564d11a3681a8c150
treea62d5a0a313cb48fb3d9dd38e8ef3e7d8d77cf03
parent4e064062d391df79d62eb8a0309c94636e303ccd
ceph: return -ERANGE if virtual xattr value didn't fit in buffer

[ Upstream commit 3b421018f48c482bdc9650f894aa1747cf90e51d ]

The getxattr manpage states that we should return ERANGE if the
destination buffer size is too small to hold the value.
ceph_vxattrcb_layout does this internally, but we should be doing
this for all vxattrs.

Fix the only caller of getxattr_cb to check the returned size
against the buffer length and return -ERANGE if it doesn't fit.
Drop the same check in ceph_vxattrcb_layout and just rely on the
caller to handle it.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Acked-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ceph/xattr.c