From: Sage Weil Date: Sat, 30 May 2015 01:36:00 +0000 (-0400) Subject: mds/Server: add a few access checks X-Git-Tag: v10.0.0~123^2~94 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f8d4d8047123af465256a736b14f34fb40338ad0;p=ceph.git mds/Server: add a few access checks (incomplete coverage!) Signed-off-by: Sage Weil --- diff --git a/src/mds/Server.cc b/src/mds/Server.cc index c74319fe44b11..56ae21aab2615 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -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();