ceph: handle zero-length feature mask in session messages

Most session messages contain a feature mask, but the MDS will
routinely send a REJECT message with one that is zero-length.

Commit 0fa8263367 ("ceph: fix endianness bug when handling MDS
session feature bits") fixed the decoding of the feature mask,
but failed to account for the MDS sending a zero-length feature
mask. This causes REJECT message decoding to fail.

Skip trying to decode a feature mask if the word count is zero.

Cc: stable@vger.kernel.org
URL: https://tracker.ceph.com/issues/46823
Fixes: 0fa8263367 ("ceph: fix endianness bug when handling MDS session feature bits")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
Tested-by: Patrick Donnelly <pdonnell@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
Jeff Layton 2020-08-04 12:31:56 -04:00 committed by Ilya Dryomov
parent 224c7b6778
commit 02e37571f9

View File

@ -3358,8 +3358,10 @@ static void handle_session(struct ceph_mds_session *session,
goto bad; goto bad;
/* version >= 3, feature bits */ /* version >= 3, feature bits */
ceph_decode_32_safe(&p, end, len, bad); ceph_decode_32_safe(&p, end, len, bad);
ceph_decode_64_safe(&p, end, features, bad); if (len) {
p += len - sizeof(features); ceph_decode_64_safe(&p, end, features, bad);
p += len - sizeof(features);
}
} }
mutex_lock(&mdsc->mutex); mutex_lock(&mdsc->mutex);