[PATCH] A few more patches from brlock

Volker Lendecke Volker.Lendecke at SerNet.DE
Mon Jun 30 23:13:13 MDT 2014


Hi!

Review&push would be appreciated!

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 4dc60705f9440ddc2cfe9dee4d40fd2fc948cafa Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 30 Jun 2014 09:37:47 +0000
Subject: [PATCH 1/4] 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>
---
 selftest/knownfail          |    1 +
 source4/torture/smb2/lock.c |    6 ++++++
 2 files changed, 7 insertions(+)

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/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);
-- 
1.7.9.5


From f79c4a633e53e6d47a7199d7c1db92cdeb99f423 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 30 Jun 2014 09:39:20 +0000
Subject: [PATCH 2/4] 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>
---
 source3/smbd/smb2_lock.c |   23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c
index 23b9913..c4a40a5 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:
-- 
1.7.9.5


From 0d0c2ca7b798ba31974b648f674f4e964f14984f Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 30 Jun 2014 09:44:26 +0000
Subject: [PATCH 3/4] smbd: Remove an unused variable

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/smb2_lock.c |    1 -
 1 file changed, 1 deletion(-)

diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c
index c4a40a5..5d32ea7 100644
--- a/source3/smbd/smb2_lock.c
+++ b/source3/smbd/smb2_lock.c
@@ -661,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);
 
-- 
1.7.9.5


From be7208d4ea1a66a948ce6652b423a5acd600388a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Mon, 30 Jun 2014 08:32:29 +0000
Subject: [PATCH 4/4] smbd: Fix some typos

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/smb2_lock.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c
index 5d32ea7..c25e064 100644
--- a/source3/smbd/smb2_lock.c
+++ b/source3/smbd/smb2_lock.c
@@ -283,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
 				 */
@@ -552,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.
 *****************************************************************/
 
-- 
1.7.9.5



More information about the samba-technical mailing list