smb: client: fix race with concurrent opens in rename(2)
authorPaulo Alcantara <pc@manguebit.org>
Fri, 8 Aug 2025 14:43:29 +0000 (11:43 -0300)
committerSteve French <stfrench@microsoft.com>
Sun, 10 Aug 2025 17:39:51 +0000 (12:39 -0500)
commitd84291fc7453df7881a970716f8256273aca5747
tree69a0c3f4db40dfa835756089574fc3d58c4c9f8e
parent0af1561b2d60bab2a2b00720a5c7b292ecc549ec
smb: client: fix race with concurrent opens in rename(2)

Besides sending the rename request to the server, the rename process
also involves closing any deferred close, waiting for outstanding I/O
to complete as well as marking all existing open handles as deleted to
prevent them from deferring closes, which increases the race window
for potential concurrent opens on the target file.

Fix this by unhashing the dentry in advance to prevent any concurrent
opens on the target.

Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
Reviewed-by: David Howells <dhowells@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-cifs@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/inode.c