From: Igor Golikov Date: Wed, 27 May 2026 13:18:44 +0000 (+0300) Subject: client: add assert to catch dentry ref drop during unlink X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=227b558f203e8ccedcea742591c78c0e1a8079ef;p=ceph.git client: add assert to catch dentry ref drop during unlink Add ceph_assert(dn->ref > 0) after Dentry::unlink() in Client::unlink() to catch the case where internal put() calls drop the dentry reference to zero before we proceed to detach/lru_remove. This turns a silent use-after-free into a clean assertion failure with a full stack trace, making it possible to catch the exact conditions in a test environment. Signed-off-by: Igor Golikov Fixes: https://tracker.ceph.com/issues/74625 --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 3a2041a8753..5d1464b3a3b 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -3800,6 +3800,7 @@ void Client::unlink(Dentry *dn, bool keepdir, bool keepdentry) dec_dentry_nr(); ldout(cct, 20) << "unlink inode " << in << " parents now " << in->dentries << dendl; } + ceph_assert(dn->ref > 0); if (keepdentry) { dn->lease_mds = -1;