]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
ceph: handle zero-length feature mask in session messages
authorJeff Layton <jlayton@kernel.org>
Tue, 4 Aug 2020 16:31:56 +0000 (12:31 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Aug 2020 11:05:28 +0000 (13:05 +0200)
commit 02e37571f9e79022498fd0525c073b07e9d9ac69 upstream.

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

Commit 0fa8263367db ("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: 0fa8263367db ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ceph/mds_client.c

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