s3:smbd: let close_directory() hold the lock during delete_all_streams/rmdir_internals
authorStefan Metzmacher <metze@samba.org>
Mon, 12 Sep 2022 17:15:58 +0000 (19:15 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 20 Sep 2022 00:34:36 +0000 (00:34 +0000)
Now that we're using g_lock, it doesn't mean we're holding a tdb
chainlock.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/close.c

index b1db60bac77e3c762e8bd7b95ee906b3beb89d6b..f951a7c298675f091e39b448d36373e4002694bc 100644 (file)
@@ -1436,13 +1436,6 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
                                del_token->groups,
                                del_nt_token);
 
-               if (!del_share_mode(lck, fsp)) {
-                       DEBUG(0, ("close_directory: Could not delete share entry for "
-                                 "%s\n", fsp_str_dbg(fsp)));
-               }
-
-               TALLOC_FREE(lck);
-
                if ((fsp->conn->fs_capabilities & FILE_NAMED_STREAMS)
                    && !is_ntfs_stream_smb_fname(fsp->fsp_name)) {
 
@@ -1473,15 +1466,15 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
                if (NT_STATUS_IS_OK(status)) {
                        notify_status = NT_STATUS_DELETE_PENDING;
                }
-       } else {
-               if (!del_share_mode(lck, fsp)) {
-                       DEBUG(0, ("close_directory: Could not delete share entry for "
-                                 "%s\n", fsp_str_dbg(fsp)));
-               }
+       }
 
-               TALLOC_FREE(lck);
+       if (!del_share_mode(lck, fsp)) {
+               DEBUG(0, ("close_directory: Could not delete share entry for "
+                         "%s\n", fsp_str_dbg(fsp)));
        }
 
+       TALLOC_FREE(lck);
+
        remove_pending_change_notify_requests_by_fid(fsp, notify_status);
 
        status1 = fd_close(fsp);