[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Tue Dec 10 21:58:02 UTC 2019


The branch, master has been updated
       via  fbd97ee8223 smbd: Fix a leases.tdb record leak
       via  7535359602e torture: Run durable_v2_reconnect_delay_msec with leases
       via  79b2ee8dc23 torture4: Use generate_random_u64() instead of random()
      from  20b9cae63d5 lib:crypto: Build intel aes-ni only if GnuTLS doesn't provide AES CMAC

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


- Log -----------------------------------------------------------------
commit fbd97ee822337534006ffcd14e08c8068e178266
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Dec 10 10:56:44 2019 +0100

    smbd: Fix a leases.tdb record leak
    
    If we set e->stale=true in the share_mode_forall_entries() callback,
    the share entry will be removed directly. Thus further down
    share_mode_forall_leases() won't find anything anymore. Only find
    possibly still connected entries in the first walk, and then remove
    the share_entries.tdb record straight away after the leases and
    brlocks have been removed.
    
    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): Tue Dec 10 21:57:05 UTC 2019 on sn-devel-184

commit 7535359602e8b33e38ef1e0e38dc070773a39ea8
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Dec 10 11:48:07 2019 +0100

    torture: Run durable_v2_reconnect_delay_msec with leases
    
    This will show a leases.tdb record leak. If you SIGSTOP the smbtorture
    process while it's in the 10-second wait, you will find locking.tdb
    and share_entries.tdb empty after the scavenger has cleaned up. But
    there will be an entry in leases.tdb left.
    
    I have no clue how to test this properly, or how to have a reasonably
    cheap assert in smbd during normal operations. The problem is that
    this leak can't really be distinguished from a "normal" leak that a
    crashed smbd would leave behind. Possibly we need a background job
    walking leases.tdb to clean this up properly.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 79b2ee8dc2382354750601ee3d57912442c09817
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Dec 10 11:31:22 2019 +0100

    torture4: Use generate_random_u64() instead of random()
    
    random() returns an int, which is not necessarily a uint64
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 selftest/knownfail.d/durable-v2-delay  |  2 ++
 source3/locking/share_mode_lock.c      | 17 +++++++++++++----
 source4/torture/smb2/durable_v2_open.c | 15 ++++++++++-----
 3 files changed, 25 insertions(+), 9 deletions(-)
 create mode 100644 selftest/knownfail.d/durable-v2-delay


Changeset truncated at 500 lines:

diff --git a/selftest/knownfail.d/durable-v2-delay b/selftest/knownfail.d/durable-v2-delay
new file mode 100644
index 00000000000..2a84749b0eb
--- /dev/null
+++ b/selftest/knownfail.d/durable-v2-delay
@@ -0,0 +1,2 @@
+# In the ad_dc env leases are disabled
+^samba3.smb2.durable-v2-delay.durable_v2_reconnect_delay_msec\(ad_dc\)
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index dacb5efab85..cf972fc4b61 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -1217,7 +1217,7 @@ static bool cleanup_disconnected_lease(struct share_mode_entry *e,
 	return false;
 }
 
-static bool share_mode_cleanup_disconnected_fn(
+static bool share_mode_find_connected_fn(
 	struct share_mode_entry *e,
 	bool *modified,
 	void *private_data)
@@ -1265,8 +1265,6 @@ static bool share_mode_cleanup_disconnected_fn(
 		return true;
 	}
 
-	e->stale = true;
-
 	return false;
 }
 
@@ -1280,6 +1278,7 @@ bool share_mode_cleanup_disconnected(struct file_id fid,
 	bool ret = false;
 	TALLOC_CTX *frame = talloc_stackframe();
 	struct file_id_buf idbuf;
+	NTSTATUS status;
 	bool ok;
 
 	state.lck = get_existing_share_mode_lock(frame, fid);
@@ -1291,7 +1290,7 @@ bool share_mode_cleanup_disconnected(struct file_id fid,
 	data = state.lck->data;
 
 	ok = share_mode_forall_entries(
-		state.lck, share_mode_cleanup_disconnected_fn, &state);
+		state.lck, share_mode_find_connected_fn, &state);
 	if (!ok) {
 		DBG_DEBUG("share_mode_forall_entries failed\n");
 		goto done;
@@ -1349,6 +1348,16 @@ bool share_mode_cleanup_disconnected(struct file_id fid,
 		  ? "" : data->stream_name,
 		  open_persistent_id);
 
+	/*
+	 * No connected share entries left, wipe them all
+	 */
+	status = dbwrap_delete(share_entries_db, locking_key(&fid));
+	if (!NT_STATUS_IS_OK(status)) {
+		DBG_DEBUG("dbwrap_delete failed: %s\n",
+			  nt_errstr(status));
+		goto done;
+	}
+
 	data->num_share_modes = 0;
 	data->modified = true;
 
diff --git a/source4/torture/smb2/durable_v2_open.c b/source4/torture/smb2/durable_v2_open.c
index 4e70b9bfe17..b2c519db3f6 100644
--- a/source4/torture/smb2/durable_v2_open.c
+++ b/source4/torture/smb2/durable_v2_open.c
@@ -1277,7 +1277,7 @@ bool test_durable_v2_open_reopen2_lease(struct torture_context *tctx,
 
 	smb2_util_unlink(tree, fname);
 
-	lease_key = random();
+	lease_key = generate_random_u64();
 	smb2_lease_create(&io, &ls, false /* dir */, fname,
 			  lease_key, smb2_util_lease_state("RWH"));
 	io.in.durable_open = false;
@@ -2135,6 +2135,7 @@ static bool test_durable_v2_reconnect_delay_msec(
 	struct smb2_handle _h;
 	struct smb2_handle *h = NULL;
 	struct smb2_create io;
+	struct smb2_lease ls;
 	struct GUID create_guid = GUID_random();
 	struct smbcli_options options;
 	uint64_t previous_session_id;
@@ -2152,9 +2153,13 @@ static bool test_durable_v2_reconnect_delay_msec(
 
 	smb2_util_unlink(tree, fname);
 
-	smb2_oplock_create_share(&io, fname,
-				 smb2_util_share_access(""),
-				 smb2_util_oplock_level("b"));
+	smb2_lease_create(
+		&io,
+		&ls,
+		false /* dir */,
+		fname,
+		generate_random_u64(),
+		smb2_util_lease_state("RWH"));
 	io.in.durable_open = false;
 	io.in.durable_open_v2 = true;
 	io.in.persistent_open = false;
@@ -2166,7 +2171,7 @@ static bool test_durable_v2_reconnect_delay_msec(
 
 	_h = io.out.file.handle;
 	h = &_h;
-	CHECK_VAL(io.out.oplock_level, smb2_util_oplock_level("b"));
+	CHECK_VAL(io.out.oplock_level, SMB2_OPLOCK_LEVEL_LEASE);
 	CHECK_VAL(io.out.durable_open_v2, true);
 
 	status = smb2_util_write(tree, *h, &b, 0, 1);


-- 
Samba Shared Repository



More information about the samba-cvs mailing list