mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] ceph: Fix r_parent staleness race and related deadlock
@ 2025-08-04  9:59 Alex Markuze
  2025-08-04  9:59 ` [PATCH v2 1/2] ceph: fix client race condition validating r_parent before applying state Alex Markuze
  2025-08-04  9:59 ` [PATCH v2 2/2] ceph: fix client race condition where r_parent becomes stale before sending message Alex Markuze
  0 siblings, 2 replies; 6+ messages in thread
From: Alex Markuze @ 2025-08-04  9:59 UTC (permalink / raw)
  To: ceph-devel; +Cc: linux-kernel, Slava.Dubeyko, idryomov, Alex Markuze

Hi,

This patchset addresses two related issues in CephFS client request handling.

**Patch 1/2 ("ceph: fix client race condition where r_parent becomes stale before sending message")**

This patch fixes a race condition where the `req->r_parent` inode reference can become stale. Under specific conditions (e.g., expired dentry leases), the client can perform lockless lookups, creating a window where a concurrent `rename` operation can invalidate `req->r_parent` between initial VFS lookup and MDS request message creation. The MDS reply handler (`create_request_message`) previously trusted the cached `r_parent` without verification. This patch enhances path-building functions to track the full `ceph_vino` and adds a validation step in `create_request_message` to compare and correct `req->r_parent` if a mismatch is detected (when the parent wasn't locked).

**Patch 2/2 ("ceph: fix deadlock in ceph_readdir_prepopulate due to snap_rwsem")**

This patch fixes a deadlock in `ceph_readdir_prepopulate`. The function holds `mdsc->snap_rwsem` (read lock) while calling `ceph_get_inode`, which can potentially block on inode operations that might require the `snap_rwsem` write lock, leading to a classic reader/writer deadlock. This patch releases `mdsc->snap_rwsem` before calling `ceph_get_inode` and re-acquires it afterwards, breaking the deadlock cycle.

Together, these patches improve the robustness and stability of CephFS client request handling by fixing a correctness race and a critical deadlock.


Alex Markuze (2):
  ceph: fix client race condition validating r_parent before applying
    state
  ceph: fix client race condition where r_parent becomes stale before
    sending message

 fs/ceph/inode.c      | 44 +++++++++++++++++++++++++++--
 fs/ceph/mds_client.c | 67 +++++++++++++++++++++++++++++++-------------
 2 files changed, 89 insertions(+), 22 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-05 12:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-04  9:59 [PATCH 0/2] ceph: Fix r_parent staleness race and related deadlock Alex Markuze
2025-08-04  9:59 ` [PATCH v2 1/2] ceph: fix client race condition validating r_parent before applying state Alex Markuze
2025-08-04 21:44   ` Viacheslav Dubeyko
2025-08-04  9:59 ` [PATCH v2 2/2] ceph: fix client race condition where r_parent becomes stale before sending message Alex Markuze
2025-08-04 21:58   ` Viacheslav Dubeyko
2025-08-05 12:28     ` Alex Markuze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®