[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Wed May 15 17:57:02 UTC 2024


The branch, master has been updated
       via  2b495c44a2a smbd: Fix a typo in a few places
       via  a99f2f3ae39 smbd: Modernize a few DEBUGs
       via  df75ae65e63 g_lock: Fix buffer length check in g_lock_parse()
       via  aca70be7829 smbd: Simplify check_parent_access_fsp()
       via  c422002ce5e smbd: Remove an obsolete comment
      from  b71f729698f smbd: Add reparse tag to smb3_posix_cc_info

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 2b495c44a2abcfa9b9c7f520e0989ff72f7b651f
Author: Volker Lendecke <vl at samba.org>
Date:   Wed May 15 16:43:31 2024 +0200

    smbd: Fix a typo in a few places
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed May 15 17:56:24 UTC 2024 on atb-devel-224

commit a99f2f3ae390ddc4d80548a593a3edf50eeb76f3
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 14 16:20:03 2024 +0200

    smbd: Modernize a few DEBUGs
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit df75ae65e6347736c96707c57e736d15662a6846
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Feb 10 11:15:58 2024 +0100

    g_lock: Fix buffer length check in g_lock_parse()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit aca70be7829b97729b18a9c2c5e3add894e323c1
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 14 16:30:21 2024 +0200

    smbd: Simplify check_parent_access_fsp()
    
    We don't need to explicitly call fetch_share_mode_unlocked,
    get_file_infos does it for us behind the scenes
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit c422002ce5ef8ea4dcac69b7167dcf67d5c373d1
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 14 17:01:40 2024 +0200

    smbd: Remove an obsolete comment
    
    notify_fname only sends a message to the notify daemon. There is no
    potential deadlock anymore.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/lib/g_lock.c      |  9 +++++----
 source3/locking/locking.c | 19 +++++++++++--------
 source3/smbd/close.c      | 41 +++++++++++++++--------------------------
 source3/smbd/open.c       | 16 +---------------
 4 files changed, 32 insertions(+), 53 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index 33f088b2a43..77b8287273b 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -58,7 +58,8 @@ static bool g_lock_parse(uint8_t *buf, size_t buflen, struct g_lock *lck)
 	uint64_t unique_data_epoch;
 
 	if (buflen < (SERVER_ID_BUF_LENGTH + /* exclusive */
-		      sizeof(uint64_t) +     /* seqnum */
+		      sizeof(uint64_t) +     /* unique_lock_epoch */
+		      sizeof(uint64_t) +     /* unique_data_epoch */
 		      sizeof(uint32_t))) {   /* num_shared */
 		struct g_lock ret = {
 			.exclusive.pid = 0,
@@ -360,7 +361,7 @@ NTSTATUS g_lock_lock_cb_dump(struct g_lock_lock_cb_state *cb_state,
 {
 	struct g_lock *lck = cb_state->lck;
 
-	/* We allow a cn_fn only for G_LOCK_WRITE for now... */
+	/* We allow a cb_fn only for G_LOCK_WRITE for now... */
 	SMB_ASSERT(lck->num_shared == 0);
 
 	fn(lck->exclusive,
@@ -1018,7 +1019,7 @@ struct tevent_req *g_lock_lock_send(TALLOC_CTX *mem_ctx,
 	};
 
 	/*
-	 * We allow a cn_fn only for G_LOCK_WRITE for now.
+	 * We allow a cb_fn only for G_LOCK_WRITE for now.
 	 *
 	 * It's all we currently need and it makes a few things
 	 * easier to implement.
@@ -1238,7 +1239,7 @@ NTSTATUS g_lock_lock(struct g_lock_ctx *ctx, TDB_DATA key,
 	SMB_ASSERT(!ctx->busy);
 
 	/*
-	 * We allow a cn_fn only for G_LOCK_WRITE for now.
+	 * We allow a cb_fn only for G_LOCK_WRITE for now.
 	 *
 	 * It's all we currently need and it makes a few things
 	 * easier to implement.
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index fa1c85afe91..25735a3083d 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -158,12 +158,14 @@ bool strict_lock_check_default(files_struct *fsp, struct lock_struct *plock)
 		TALLOC_FREE(br_lck);
 	}
 
-	DEBUG(10, ("strict_lock_default: flavour = %s brl start=%ju "
-		   "len=%ju %s for fnum %ju file %s\n",
-		   lock_flav_name(plock->lock_flav),
-		   (uintmax_t)plock->start, (uintmax_t)plock->size,
-		   ret ? "unlocked" : "locked",
-		   (uintmax_t)plock->fnum, fsp_str_dbg(fsp)));
+	DBG_DEBUG("flavour = %s brl start=%" PRIu64 " "
+		  "len=%" PRIu64 " %s for fnum %" PRIu64 " file %s\n",
+		  lock_flav_name(plock->lock_flav),
+		  plock->start,
+		  plock->size,
+		  ret ? "unlocked" : "locked",
+		  plock->fnum,
+		  fsp_str_dbg(fsp));
 
 	return ret;
 }
@@ -583,8 +585,9 @@ bool rename_share_filename(struct messaging_context *msg_ctx,
 	NTSTATUS status;
 	bool ok;
 
-	DEBUG(10, ("rename_share_filename: servicepath %s newname %s\n",
-		   servicepath, smb_fname_dst->base_name));
+	DBG_DEBUG("servicepath %s newname %s\n",
+		  servicepath,
+		  smb_fname_dst->base_name);
 
 	status = share_mode_lock_access_private_data(lck, &d);
 	if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 7c5c4d68bee..5cb2bb6f17c 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -473,8 +473,8 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
 	 */
 	lck_state.cleanup_fn = close_share_mode_lock_cleanup;
 
-	DEBUG(5,("close_remove_share_mode: file %s. Delete on close was set "
-		 "- deleting file.\n", fsp_str_dbg(fsp)));
+	DBG_INFO("%s. Delete on close was set - deleting file.\n",
+		 fsp_str_dbg(fsp));
 
 	/*
 	 * Don't try to update the write time when we delete the file
@@ -486,10 +486,9 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
 	{
 		/* Become the user who requested the delete. */
 
-		DEBUG(5,("close_remove_share_mode: file %s. "
-			"Change user to uid %u\n",
-			fsp_str_dbg(fsp),
-			(unsigned int)lck_state.del_token->uid));
+		DBG_INFO("file %s. Change user to uid %u\n",
+			 fsp_str_dbg(fsp),
+			 (unsigned int)lck_state.del_token->uid);
 
 		if (!push_sec_ctx()) {
 			smb_panic("close_remove_share_mode: file %s. failed to push "
@@ -510,9 +509,10 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
 
 	tmp_status = vfs_stat_fsp(fsp);
 	if (!NT_STATUS_IS_OK(tmp_status)) {
-		DEBUG(5,("close_remove_share_mode: file %s. Delete on close "
+		DBG_INFO("file %s. Delete on close "
 			 "was set and stat failed with error %s\n",
-			 fsp_str_dbg(fsp), nt_errstr(tmp_status)));
+			 fsp_str_dbg(fsp),
+			 nt_errstr(tmp_status));
 		/*
 		 * Don't save the errno here, we ignore this error
 		 */
@@ -523,14 +523,13 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
 
 	if (!file_id_equal(&fsp->file_id, &id)) {
 		struct file_id_buf ftmp1, ftmp2;
-		DEBUG(5,("close_remove_share_mode: file %s. Delete on close "
+		DBG_INFO("file %s. Delete on close "
 			 "was set and dev and/or inode does not match\n",
-			 fsp_str_dbg(fsp)));
-		DEBUG(5,("close_remove_share_mode: file %s. stored file_id %s, "
-			 "stat file_id %s\n",
+			 fsp_str_dbg(fsp));
+		DBG_INFO("file %s. stored file_id %s, stat file_id %s\n",
 			 fsp_str_dbg(fsp),
 			 file_id_str_buf(fsp->file_id, &ftmp1),
-			 file_id_str_buf(id, &ftmp2)));
+			 file_id_str_buf(id, &ftmp2));
 		/*
 		 * Don't save the errno here, we ignore this error
 		 */
@@ -588,9 +587,10 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
 		 * zero.
 		 */
 
-		DEBUG(5,("close_remove_share_mode: file %s. Delete on close "
+		DBG_INFO("file %s. Delete on close "
 			 "was set and unlink failed with error %s\n",
-			 fsp_str_dbg(fsp), strerror(errno)));
+			 fsp_str_dbg(fsp),
+			 strerror(errno));
 
 		status = map_nt_error_from_unix(errno);
 	}
@@ -633,17 +633,6 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
 	}
 
 	if (lck_state.delete_object) {
-		/*
-		 * Do the notification after we released the share
-		 * mode lock. Inside notify_fname we take out another
-		 * tdb lock. With ctdb also accessing our databases,
-		 * this can lead to deadlocks. Putting this notify
-		 * after the TALLOC_FREE(lck) above we avoid locking
-		 * two records simultaneously. Notifies are async and
-		 * informational only, so calling the notify_fname
-		 * without holding the share mode lock should not do
-		 * any harm.
-		 */
 		notify_fname(conn, NOTIFY_ACTION_REMOVED,
 			     FILE_NOTIFY_CHANGE_FILE_NAME,
 			     fsp->fsp_name->base_name);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 68e5eb957f2..04d0e1e0336 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -341,7 +341,6 @@ NTSTATUS check_parent_access_fsp(struct files_struct *fsp,
 	NTSTATUS status;
 	struct security_descriptor *parent_sd = NULL;
 	uint32_t access_granted = 0;
-	struct share_mode_lock *lck = NULL;
 	uint32_t name_hash;
 	bool delete_on_close_set;
 	TALLOC_CTX *frame = talloc_stackframe();
@@ -410,20 +409,7 @@ NTSTATUS check_parent_access_fsp(struct files_struct *fsp,
 		goto out;
 	}
 
-	/*
-	 * Don't take a lock here. We just need a snapshot
-	 * of the current state of delete on close and this is
-	 * called in a codepath where we may already have a lock
-	 * (and we explicitly can't hold 2 locks at the same time
-	 * as that may deadlock).
-	 */
-	lck = fetch_share_mode_unlocked(frame, fsp->file_id);
-	if (lck == NULL) {
-		status = NT_STATUS_OK;
-		goto out;
-	}
-
-	delete_on_close_set = is_delete_on_close_set(lck, name_hash);
+	get_file_infos(fsp->file_id, name_hash, &delete_on_close_set, NULL);
 	if (delete_on_close_set) {
 		status = NT_STATUS_DELETE_PENDING;
 		goto out;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list