]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/Server: add a few access checks
authorSage Weil <sage@redhat.com>
Sat, 30 May 2015 01:36:00 +0000 (21:36 -0400)
committerSage Weil <sage@redhat.com>
Thu, 1 Oct 2015 13:39:29 +0000 (09:39 -0400)
(incomplete coverage!)

Signed-off-by: Sage Weil <sage@redhat.com>
src/mds/Server.cc

index c74319fe44b110b404cffbca604c1b4af7cbdc78..56ae21aab2615f2c13ac2e0bb27e5d0aa0f2de58 100644 (file)
@@ -2692,6 +2692,9 @@ void Server::handle_client_getattr(MDRequestRef& mdr, bool is_lookup)
   if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
     return;
 
+  if (!check_access(mdr, ref, MAY_READ))
+    return;
+
   // note which caps are requested, so we return at least a snapshot
   // value for them.  (currently this matters for xattrs and inline data)
   mdr->getattr_caps = mask;
@@ -2740,6 +2743,11 @@ void Server::handle_client_lookup_ino(MDRequestRef& mdr,
     return;
   }
 
+  // check for nothing (not read or write); this still applies the
+  // path check.
+  if (!check_access(mdr, in, 0))
+    return;
+
   CDentry *dn = in->get_projected_parent_dn();
   CInode *diri = dn ? dn->get_dir()->inode : NULL;
   if (dn && (want_parent || want_dentry)) {
@@ -2748,6 +2756,10 @@ void Server::handle_client_lookup_ino(MDRequestRef& mdr,
     rdlocks.insert(&dn->lock);
     if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
       return;
+
+    // need read access to directory inode
+    if (!check_access(mdr, diri, MAY_READ))
+      return;
   }
 
   if (want_parent) {
@@ -2911,6 +2923,12 @@ void Server::handle_client_open(MDRequestRef& mdr)
   if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
     return;
 
+  int mask = MAY_READ;
+  if (cmode & CEPH_FILE_MODE_WR)
+    mask |= MAY_WRITE;
+  if (!check_access(mdr, cur, mask))
+    return;
+
   if (cur->is_file() || cur->is_dir()) {
     if (mdr->snapid == CEPH_NOSNAP) {
       // register new cap
@@ -3578,6 +3596,9 @@ void Server::handle_client_setattr(MDRequestRef& mdr)
   if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks))
     return;
 
+  if (!check_access(mdr, cur, MAY_WRITE))
+    return;
+
   // trunc from bigger -> smaller?
   inode_t *pi = cur->get_projected_inode();