[PATCH samba 1/1] smbd: remove redundant rename destination open check

ChenXiaoSong chenxiaosong at chenxiaosong.com
Thu Aug 6 00:46:01 UTC 2026


From: ChenXiaoSong <chenxiaosong at kylinos.cn>

It already checks the destination in smbd_smb2_setinfo_rename_dst_check()
or smbd_smb2_setinfo_rename_dst_delay_done().

Link[1]: https://lore.kernel.org/linux-cifs/0f6a5c9c-2c65-480e-aa44-facdf11fecc0@samba.org/
Link[2]: https://lore.kernel.org/linux-cifs/a6a6913b-7a85-48a8-ba65-13fae188c33b@samba.org/
Suggested-by: Ralph Boehme <slow at samba.org>
Signed-off-by: ChenXiaoSong <chenxiaosong at kylinos.cn>
---
 source3/smbd/smb2_reply.c | 43 ---------------------------------------
 1 file changed, 43 deletions(-)

diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c
index 6bdc02c2374..5209c0046de 100644
--- a/source3/smbd/smb2_reply.c
+++ b/source3/smbd/smb2_reply.c
@@ -1312,31 +1312,6 @@ static void notify_rename(struct connection_struct *conn,
 	TALLOC_FREE(parent_dir_dst);
 }
 
-struct rename_check_open_state {
-	struct files_struct *dst_fsp;
-	struct file_id fileid;
-};
-
-static struct files_struct *rename_check_open_fn(struct files_struct *fsp,
-						 void *private_data)
-{
-	struct rename_check_open_state *state = private_data;
-
-	if (fsp == state->dst_fsp) {
-		return NULL;
-	}
-
-	if (!fsp->fsp_flags.is_fsa) {
-		return NULL;
-	}
-
-	if (!file_id_equal(&fsp->file_id, &state->fileid)) {
-		return NULL;
-	}
-
-	return fsp;
-}
-
 /****************************************************************************
  Rename an open file - given an fsp.
 ****************************************************************************/
@@ -1483,12 +1458,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
 	}
 
 	if (VALID_STAT(smb_fname_dst->st)) {
-
-		struct rename_check_open_state check_state = {
-			.dst_fsp = smb_fname_dst->fsp,
-		};
-		struct files_struct *found_open = NULL;
-
 		if (!replace_if_exists) {
 			DBG_NOTICE("dest exists doing rename "
 				   "%s -> %s\n",
@@ -1497,18 +1466,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
 			status = NT_STATUS_OBJECT_NAME_COLLISION;
 			goto out;
 		}
-
-		check_state.fileid = vfs_file_id_from_sbuf(conn,
-							   &smb_fname_dst->st);
-
-		found_open = files_forall(conn->sconn,
-					  rename_check_open_fn,
-					  &check_state);
-		if (found_open != NULL) {
-			DBG_NOTICE("Target file open\n");
-			status = NT_STATUS_ACCESS_DENIED;
-			goto out;
-		}
 	}
 
 	status = can_rename(conn, fsp, attrs);
-- 
2.54.0




More information about the samba-technical mailing list