]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: check if inode ref is dir before proceeding with lookup
authorDhairya Parmar <dparmar@redhat.com>
Tue, 8 Apr 2025 13:53:48 +0000 (19:23 +0530)
committerJos Collin <jcollin@redhat.com>
Wed, 27 Aug 2025 06:43:12 +0000 (12:13 +0530)
Lookup on non-dir inode is incorrect. Client::_lookup did check for it
but the order needed to be correct i.e. check for non-dir inode before
anything.

Fixes: https://tracker.ceph.com/issues/70553
Signed-off-by: Dhairya Parmar <dparmar@redhat.com>
(cherry picked from commit aa6ffa5159f6c9e14000a7501a394b1185b63078)

src/client/Client.cc

index d80c8c9db2578103d101d84fdc07b089345214d2..15cd89d28eb2af8e5f8650a3e74c60f0456ead98 100644 (file)
@@ -7518,6 +7518,11 @@ int Client::_lookup(const InodeRef& dir, const std::string& name, std::string& a
   mask &= CEPH_CAP_ANY_SHARED | CEPH_STAT_RSTAT;
   std::string dname = name;
 
+  if (!dir->is_dir()) {
+    r = -ENOTDIR;
+    goto done;
+  }
+
   if (dname == ".."sv) {
     if (dir->dentries.empty()) {
       MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPPARENT);
@@ -7544,11 +7549,6 @@ int Client::_lookup(const InodeRef& dir, const std::string& name, std::string& a
     goto done;
   }
 
-  if (!dir->is_dir()) {
-    r = -ENOTDIR;
-    goto done;
-  }
-
   if (dname.size() > NAME_MAX) {
     r = -ENAMETOOLONG;
     goto done;