Skip to content

smb: client: fix cached-dir and deferred-close unmount races

Siddharth Chintamaneni linux-cifs lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2smb: client: drop dentries for dying cached dirs during unmountfs/smb/client/cached_dir.c+29 -20 replies
2/2smb: client: fix busy dentry on unmount from cancelled deferred closefs/smb/client/misc.c+29 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH v1 0/2] smb: client: fix cached-dir and deferred-close unmount races

While investigating the cifs_kill_sb() unmount busy-dentry race fixed in "smb: client: fix busy dentry and inode on unmount from late oplock break" [1], I wrote a static analysis tool with AI assistance to scan for the same teardown pattern where objects are moved off shared lists and locks are dropped before their underlying dentry references are released.

That scan identified two more unmount races in cifs_kill_sb(), both of which I reproduced in QEMU where cifs_kill_sb() reaches generic_shutdown_super() while dentries are still in use:

- Patch 1 walks cfids->dying under cfids->cfid_list_lock in close_all_cached_dirs() and holds cifs_sb->outstanding_rreq across dput(dentry) in smb2_close_cached_fid() so dentries for dying or concurrently closed cached directories are dropped before kill_anon_super() runs.
- Patch 2 counts cancelled deferred-close handles in cifs_sb->outstanding_rreq while they sit on a local stack list before _cifsFileInfo_put() completes in cifs_close_deferred_file(), cifs_close_all_deferred_files(), and cifs_close_deferred_file_under_dentry().

[1] https://lore.kernel.org/all/[email protected]/

Siddharth Chintamaneni (2):
smb: client: drop dentries for dying cached dirs during unmount
smb: client: fix busy dentry on unmount from cancelled deferred close

 fs/smb/client/cached_dir.c | 31 +++++++++++++++++++++++++++++--
 fs/smb/client/misc.c       | 32 +++++++++++++++++++++++++++++---
 2 files changed, 58 insertions(+), 5 deletions(-)
Signature · 1 line
2.43.0