]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
client: fix Dentry UAF by holding DentryRef across unlink 69021/head
authorIgor Golikov <igolikov@ibm.com>
Wed, 27 May 2026 13:19:25 +0000 (16:19 +0300)
committerVenky Shankar <vshankar@redhat.com>
Wed, 1 Jul 2026 05:34:38 +0000 (11:04 +0530)
commitad95bb54505161696e624646daee4eceec0a9d2e
tree6be1908931da88e15200a20b6249d92b3bf6540c
parent227b558f203e8ccedcea742591c78c0e1a8079ef
client: fix Dentry UAF by holding DentryRef across unlink

Hold a function-scoped DentryRef in Client::unlink() to keep the dentry
alive through the entire teardown sequence.

Without the O_DIRECTORY dentry pin (PR #60909, merged after v19.2.1),
opening a directory does not call _ll_get(), so the dentry stays at
ref=1 while inode->dir is still active. When trim_cache() evicts this
dentry, Dentry::unlink() calls put() for the dir pin, ref drops to 0,
and the dentry is freed while Client::unlink() still needs it for
detach/lru_remove.

A function-scoped DentryRef guarantees the dentry survives until after
it has been properly removed from the dir and LRU, regardless of pin
state.

Signed-off-by: Igor Golikov <igolikov@ibm.com>
Fixes: https://tracker.ceph.com/issues/74625
src/client/Client.cc