]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: don't allow access to MDS-private inodes
authorXiubo Li <xiubli@redhat.com>
Wed, 7 Apr 2021 11:37:26 +0000 (19:37 +0800)
committerNathan Cutler <ncutler@suse.com>
Wed, 26 May 2021 12:20:21 +0000 (14:20 +0200)
Fixes: https://tracker.ceph.com/issues/50112
Signed-off-by: Xiubo Li <xiubli@redhat.com>
(cherry picked from commit 89c511356125f892477ef42bd14c0b447ff06106)

Conflicts:
src/client/Client.cc
- octopus wants ESTALE instead of CEPHFS_ESTALE

src/client/Client.cc
src/client/Client.h

index 85686e703a0958cc035923ce8d17fef510ef8ed7..19a3ea679b614135a446833a8380ebbf0c763eb5 100755 (executable)
@@ -132,6 +132,14 @@ void client_flush_set_callback(void *p, ObjectCacher::ObjectSet *oset)
   client->flush_set_callback(oset);
 }
 
+bool Client::is_reserved_vino(vinodeno_t &vino) {
+  if (vino.ino < MDS_INO_SYSTEM_BASE && vino.ino != MDS_INO_ROOT) {
+    ldout(cct, -1) << __func__ << "attempt to access reserved inode number " << vino << dendl;
+    return true;
+  }
+  return false;
+}
+
 
 // -------------
 
@@ -8715,6 +8723,9 @@ int Client::_lookup_vino(vinodeno_t vino, const UserPerm& perms, Inode **inode)
   if (unmounting)
     return -ENOTCONN;
 
+  if (is_reserved_vino(vino))
+    return -ESTALE;
+
   MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPINO);
   filepath path(vino.ino);
   req->set_filepath(path);
@@ -10914,6 +10925,9 @@ int Client::ll_lookup_vino(
   if (unmounting)
     return -ENOTCONN;
 
+  if (is_reserved_vino(vino))
+    return -ESTALE;
+
   std::lock_guard lock(client_lock);
   ldout(cct, 3) << __func__ << vino << dendl;
    
@@ -11165,6 +11179,9 @@ Inode *Client::ll_get_inode(vinodeno_t vino)
   if (unmounting)
     return NULL;
 
+  if (is_reserved_vino(vino))
+    return NULL;
+
   unordered_map<vinodeno_t,Inode*>::iterator p = inode_map.find(vino);
   if (p == inode_map.end())
     return NULL;
index 13bbc29b235c21543d20413cb7f78b248d3feb39..e4e651554b8d57846bb2556f688328a9d3c31053 100644 (file)
@@ -1014,6 +1014,7 @@ private:
   static const VXattr _common_vxattrs[];
 
 
+  bool is_reserved_vino(vinodeno_t &vino);
 
   void fill_dirent(struct dirent *de, const char *name, int type, uint64_t ino, loff_t next_off);