[SCM] Samba Shared Repository - branch master updated

Andrew Tridgell tridge at samba.org
Fri Nov 27 01:42:25 MST 2009


The branch, master has been updated
       via  d524082... s4-selftest: s4 passes all the SMB2-LOCK tests now
       via  9f3ac81... s4-torture: fixed error code for s4 in SMB2-LOCK test
       via  b3115f5... s4-ntvfs: win7 does not check for the NONE smb2 lock flag on unlock
       via  af087f9... s4-selftest: s4 passes this test now
       via  7359a22... s4-torture: mark s4 as doing valid lock range tests on SMB
       via  186ea09... s4-ntvfs: move valid lock range test from smb2 layer to generic code
      from  b62964d... s4:smb_server/smb2: don't reset highest_smb2_seqnum on SMB2 Cancel

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


- Log -----------------------------------------------------------------
commit d5240822a58bdc69d37aa4119bcae807a4e6b0b5
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Nov 27 19:11:28 2009 +1100

    s4-selftest: s4 passes all the SMB2-LOCK tests now

commit 9f3ac810a64a4ad1f60038b61659c59efe699559
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Nov 27 19:10:50 2009 +1100

    s4-torture: fixed error code for s4 in SMB2-LOCK test
    
    s4 returns NETWORK_NAME_DELETED if you attempt to use an invalid tree connection
    for a lock. This test (correctly I think) happens before we validate the file handle.
    That implies that when you pass both a closed handle and a invalid tree you
    should get NT_STATUS_NETWORK_NAME_DELETED.

commit b3115f5cdc558ed71e11141e4f515511f3c6df5a
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Nov 27 19:09:10 2009 +1100

    s4-ntvfs: win7 does not check for the NONE smb2 lock flag on unlock

commit af087f98ab87be858c97e273f31c5dae6d49ef02
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Nov 27 18:10:01 2009 +1100

    s4-selftest: s4 passes this test now

commit 7359a2221937f6ff8a70db08ba8fc299e0adb738
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Nov 27 18:09:50 2009 +1100

    s4-torture: mark s4 as doing valid lock range tests on SMB

commit 186ea099c5d07c8f229909bd94fafc179f8dcc2a
Author: Andrew Tridgell <tridge at samba.org>
Date:   Fri Nov 27 18:08:51 2009 +1100

    s4-ntvfs: move valid lock range test from smb2 layer to generic code
    
    win7 also fails invalid lock ranges on SMB

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

Summary of changes:
 source4/ntvfs/common/brlock_tdb.c |   19 +++++++++++++++++++
 source4/ntvfs/ntvfs_generic.c     |    9 ++-------
 source4/selftest/knownfail        |    3 ---
 source4/torture/raw/lock.c        |    3 ++-
 source4/torture/smb2/lock.c       |    9 ++++++++-
 5 files changed, 31 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/ntvfs/common/brlock_tdb.c b/source4/ntvfs/common/brlock_tdb.c
index 299400b..df95d4c 100644
--- a/source4/ntvfs/common/brlock_tdb.c
+++ b/source4/ntvfs/common/brlock_tdb.c
@@ -80,6 +80,13 @@ struct brl_handle {
 	struct lock_struct last_lock;
 };
 
+/* see if we have wrapped locks, which are no longer allowed (windows
+ * changed this in win7 */
+static bool brl_invalid_lock_range(uint64_t start, uint64_t size)
+{
+	return (size > 1 && (start + size < start));
+}
+
 /*
   Open up the brlock.tdb database. Close it down using
   talloc_free(). We need the messaging_ctx to allow for
@@ -299,6 +306,10 @@ static NTSTATUS brl_tdb_lock(struct brl_context *brl,
 	kbuf.dptr = brlh->key.data;
 	kbuf.dsize = brlh->key.length;
 
+	if (brl_invalid_lock_range(start, size)) {
+		return NT_STATUS_INVALID_LOCK_RANGE;
+	}
+
 	if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
 		return NT_STATUS_INTERNAL_DB_CORRUPTION;
 	}
@@ -449,6 +460,10 @@ static NTSTATUS brl_tdb_unlock(struct brl_context *brl,
 	kbuf.dptr = brlh->key.data;
 	kbuf.dsize = brlh->key.length;
 
+	if (brl_invalid_lock_range(start, size)) {
+		return NT_STATUS_INVALID_LOCK_RANGE;
+	}
+
 	if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
 		return NT_STATUS_INTERNAL_DB_CORRUPTION;
 	}
@@ -620,6 +635,10 @@ static NTSTATUS brl_tdb_locktest(struct brl_context *brl,
 	kbuf.dptr = brlh->key.data;
 	kbuf.dsize = brlh->key.length;
 
+	if (brl_invalid_lock_range(start, size)) {
+		return NT_STATUS_INVALID_LOCK_RANGE;
+	}
+
 	dbuf = tdb_fetch(brl->w->tdb, kbuf);
 	if (dbuf.dptr == NULL) {
 		return NT_STATUS_OK;
diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c
index d564db7..059145b 100644
--- a/source4/ntvfs/ntvfs_generic.c
+++ b/source4/ntvfs/ntvfs_generic.c
@@ -1116,13 +1116,8 @@ NTSTATUS ntvfs_map_lock(struct ntvfs_module_context *ntvfs,
 			isunlock = false;
 		}
 		for (i=0;i<lck->smb2.in.lock_count;i++) {
-			if (lck->smb2.in.locks[i].length > 1 &&
-			    lck->smb2.in.locks[i].offset +
-			    lck->smb2.in.locks[i].length <
-			    lck->smb2.in.locks[i].offset) {
-				return NT_STATUS_INVALID_LOCK_RANGE;
-			}
-			if (lck->smb2.in.locks[i].flags == SMB2_LOCK_FLAG_NONE) {
+			if (!isunlock &&
+			    lck->smb2.in.locks[i].flags == SMB2_LOCK_FLAG_NONE) {
 				return NT_STATUS_INVALID_PARAMETER;
 			}
 
diff --git a/source4/selftest/knownfail b/source4/selftest/knownfail
index 3528ff6..2f75760 100644
--- a/source4/selftest/knownfail
+++ b/source4/selftest/knownfail
@@ -63,6 +63,3 @@ samba4.ntvfs.cifs.base.createx_sharemodes_dir
 samba4.ntvfs.cifs.base.maximum_allowed
 samba4.base.createx_access # this test is broken for non-administrator users
 samba4.smb2.oplock # oplocks in the s4 SMB2 server are a mess
-samba4.smb2.lock.*.VALID-REQUEST # the s4 SMB2 server doesn't check lock ranges
-samba4.smb2.lock.*.CANCEL-TDIS # wrong error code
-samba4.smb2.lock.*.CANCEL-LOGOFF # wrong error code
diff --git a/source4/torture/raw/lock.c b/source4/torture/raw/lock.c
index 0228837..8b49df5 100644
--- a/source4/torture/raw/lock.c
+++ b/source4/torture/raw/lock.c
@@ -72,6 +72,7 @@
 #define TARGET_IS_W2K8(_tctx) (torture_setting_bool(_tctx, "w2k8", false))
 #define TARGET_IS_WIN7(_tctx) (torture_setting_bool(_tctx, "win7", false))
 #define TARGET_IS_SAMBA3(_tctx) (torture_setting_bool(_tctx, "samba3", false))
+#define TARGET_IS_SAMBA4(_tctx) (torture_setting_bool(_tctx, "samba4", false))
 
 /*
   test SMBlock and SMBunlock ops
@@ -365,7 +366,7 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli)
 	lock[0].pid++;
 	lock[0].count = 2;
 	status = smb_raw_lock(cli->tree, &io);
-	if (TARGET_IS_WIN7(tctx))
+	if (TARGET_IS_WIN7(tctx) || TARGET_IS_SAMBA4(tctx))
 		CHECK_STATUS(status, NT_STATUS_INVALID_LOCK_RANGE);
 	else
 		CHECK_STATUS(status, NT_STATUS_OK);
diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c
index e3473ec..95b825e 100644
--- a/source4/torture/smb2/lock.c
+++ b/source4/torture/smb2/lock.c
@@ -1056,7 +1056,14 @@ static bool test_cancel_tdis(struct torture_context *torture,
 	lck.in.file.handle	= h;
 	el[0].flags		= SMB2_LOCK_FLAG_UNLOCK;
 	status = smb2_lock(tree, &lck);
-	CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
+	if (torture_setting_bool(torture, "samba4", false)) {
+		/* checking if the tcon supplied are still valid
+		 * should happen before you validate a file handle,
+		 * so we should return USER_SESSION_DELETED */
+		CHECK_STATUS(status, NT_STATUS_NETWORK_NAME_DELETED);
+	} else {
+		CHECK_STATUS(status, NT_STATUS_FILE_CLOSED);
+	}
 
 done:
 	smb2_util_close(tree, h2);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list