From: Dhairya Parmar Date: Tue, 8 Apr 2025 13:53:48 +0000 (+0530) Subject: client: check if inode ref is dir before proceeding with lookup X-Git-Tag: testing/wip-jcollin-testing-20251001.024604-squid~4^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6dc55fcda3b9280a8ae3cdcc681a9d1fa0f7148d;p=ceph-ci.git client: check if inode ref is dir before proceeding with lookup 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 (cherry picked from commit aa6ffa5159f6c9e14000a7501a394b1185b63078) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 74933349247..e4a1a3be90f 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -7503,6 +7503,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); @@ -7529,11 +7534,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;