]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: reject lookup ino requests for mds dirs
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 24 Mar 2021 20:54:17 +0000 (13:54 -0700)
committerNathan Cutler <ncutler@suse.com>
Wed, 16 Jun 2021 10:10:43 +0000 (12:10 +0200)
Fixes: https://tracker.ceph.com/issues/49922
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit 682a55e8a22a137f80855f2cdd98f6f230d67fce)

Conflicts:
        src/mds/Server.cc
- octopus wants ESTALE instead of CEPHFS_ESTALE
- octopus wants CEPH_INO_ROOT instead of MDS_INO_ROOT

src/mds/Server.cc

index e4b9c28e3fe1eddf1086c486635cadf800b9e4bb..0583e3c28f8369061f1ca07d4f9234f90f5d9131 100644 (file)
@@ -3863,6 +3863,19 @@ void Server::handle_client_lookup_ino(MDRequestRef& mdr,
     return _lookup_snap_ino(mdr);
 
   inodeno_t ino = req->get_filepath().get_ino();
+  auto _ino = ino.val;
+
+  /* It's been observed [1] that a client may lookup a private ~mdsdir inode.
+   * I do not have an explanation for how that happened organically but this
+   * check will ensure that the client can no longer do that.
+   *
+   * [1] https://tracker.ceph.com/issues/49922
+   */
+  if (_ino < MDS_INO_SYSTEM_BASE && _ino != CEPH_INO_ROOT) {
+    respond_to_request(mdr, -ESTALE);
+    return;
+  }
+
   CInode *in = mdcache->get_inode(ino);
   if (in && in->state_test(CInode::STATE_PURGING)) {
     respond_to_request(mdr, -ESTALE);