[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Tue Jul 1 18:26:05 MDT 2014


The branch, master has been updated
       via  9fc9e48 smbd: Fix some typos
       via  f9bbb1f smbd: Remove an unused variable
       via  7d71e8d smbd: Clarify smb2 lock checks
       via  4709373 torture: Add a check to verify MS-SMB2 3.3.5.14.2
      from  0a7290c libcli: Remove an unused variable

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


- Log -----------------------------------------------------------------
commit 9fc9e4869f1ddcfeea1e286f9caeb8e8a6cc3a9a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jun 30 08:32:29 2014 +0000

    smbd: Fix some typos
    
    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 Jul  2 02:25:47 CEST 2014 on sn-devel-104

commit f9bbb1ff0dc4677d9fd17205cd901ffe8c84011a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jun 30 09:44:26 2014 +0000

    smbd: Remove an unused variable
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7d71e8d6575f6893b590f1a86c34541ebbb74740
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jun 30 09:39:20 2014 +0000

    smbd: Clarify smb2 lock checks
    
    When reading the code it was not immediately clear to me how one of the
    conditions in [MS-SMB2] 3.3.5.14.2 was satisfied. A separate loop to me
    is clearer and given that we don't expect thousands of locks in a single
    call also not significantly less efficient.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4709373cdf75d9a84eaaf1f23cf4bf07b8cb63c5
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jun 30 09:37:47 2014 +0000

    torture: Add a check to verify MS-SMB2 3.3.5.14.2
    
    If we have more than one lock and there is any blocking lock, we need
    to fail with NT_STATUS_INVALID_PARAMETER. At a quick glance I did not
    find this tested, so add it.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 selftest/knownfail          |    1 +
 source3/smbd/smb2_lock.c    |   30 +++++++++++++++++++++---------
 source4/torture/smb2/lock.c |    6 ++++++
 3 files changed, 28 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/selftest/knownfail b/selftest/knownfail
index 434ce0c..deeb8fa 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -115,6 +115,7 @@
 ^samba4.smb2.oplock.doc
 ^samba4.smb2.compound.related3
 ^samba4.smb2.compound.compound-break
+^samba4.smb2.lock.valid-request
 ^samba4.*base.delaywrite.*update of write time and SMBwrite truncate\(.*\)$
 ^samba4.*base.delaywrite.*update of write time and SMBwrite truncate expand\(.*\)$
 ^samba4.*base.delaywrite.*delayed update of write time 3a\(.*\)$
diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c
index 23b9913..c25e064 100644
--- a/source3/smbd/smb2_lock.c
+++ b/source3/smbd/smb2_lock.c
@@ -235,6 +235,24 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
 		return tevent_req_post(req, ev);
 	}
 
+	if (!isunlock && (in_lock_count > 1)) {
+
+		/*
+		 * 3.3.5.14.2 says we SHOULD fail with INVALID_PARAMETER if we
+		 * have more than one lock and one of those is blocking.
+		 */
+
+		for (i=0; i<in_lock_count; i++) {
+			uint32_t flags = in_locks[i].flags;
+
+			if ((flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) == 0) {
+				tevent_req_nterror(
+					req, NT_STATUS_INVALID_PARAMETER);
+				return tevent_req_post(req, ev);
+			}
+		}
+	}
+
 	for (i=0; i<in_lock_count; i++) {
 		bool invalid = false;
 
@@ -245,11 +263,6 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
 				invalid = true;
 				break;
 			}
-			if (i > 0) {
-				tevent_req_nterror(req,
-						   NT_STATUS_INVALID_PARAMETER);
-				return tevent_req_post(req, ev);
-			}
 			break;
 
 		case SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY:
@@ -270,8 +283,8 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
 		default:
 			if (isunlock) {
 				/*
-				 * is the first element was a UNLOCK
-				 * we need to deferr the error response
+				 * If the first element was a UNLOCK
+				 * we need to defer the error response
 				 * to the backend, because we need to process
 				 * all unlock elements before
 				 */
@@ -539,7 +552,7 @@ static bool recalc_smb2_brl_timeout(struct smbd_server_connection *sconn)
 }
 
 /****************************************************************
- Get an SMB2 lock reqeust to go async. lock_timeout should
+ Get an SMB2 lock request to go async. lock_timeout should
  always be -1 here.
 *****************************************************************/
 
@@ -648,7 +661,6 @@ bool push_blocking_lock_request_smb2( struct byte_range_lock *br_lck,
 static void remove_pending_lock(struct smbd_smb2_lock_state *state,
 			struct blocking_lock_record *blr)
 {
-	int i;
 	struct byte_range_lock *br_lck = brl_get_locks(
 				state, blr->fsp);
 
diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c
index a27ae90..1886a56 100644
--- a/source4/torture/smb2/lock.c
+++ b/source4/torture/smb2/lock.c
@@ -274,6 +274,12 @@ static bool test_valid_request(struct torture_context *torture,
 	CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
 
 	lck.in.lock_count	= 2;
+	el[0].flags = SMB2_LOCK_FLAG_SHARED|SMB2_LOCK_FLAG_FAIL_IMMEDIATELY;
+	el[1].flags = SMB2_LOCK_FLAG_SHARED;
+	status = smb2_lock(tree, &lck);
+	CHECK_STATUS(status, NT_STATUS_INVALID_PARAMETER);
+
+	lck.in.lock_count	= 2;
 	el[0].flags		= 0;
 	el[1].flags		= 0;
 	status = smb2_lock(tree, &lck);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list