]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/locking: fix checking for byterange locks when granting RH lease
authorRalph Boehme <slow@samba.org>
Thu, 7 Aug 2025 16:44:27 +0000 (18:44 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 15 Aug 2025 15:46:35 +0000 (15:46 +0000)
From MS-FSA 2.1.5.18 "Server Requests an Oplock":

...

* Else If Type is LEVEL_GRANULAR:
    * If RequestedOplockLevel is READ_CACHING or (READ_CACHING|HANDLE_CACHING):
        * The operation MUST be failed with STATUS_OPLOCK_NOT_GRANTED under either of the
          following conditions:
            * Open.Stream.ByteRangeLockList is not empty and Open.Stream.AllocationSize
              is greater than any ByteRangeLock.LockOffset in
              Open.Stream.ByteRangeLockList.

...

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15894

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
selftest/knownfail.d/samba3.smb2.lease [deleted file]
source3/locking/brlock.c

diff --git a/selftest/knownfail.d/samba3.smb2.lease b/selftest/knownfail.d/samba3.smb2.lease
deleted file mode 100644 (file)
index ea03e66..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba3.smb2.lease.lock2\(fileserver\)
index 2560df1fb0e9b34135738308cef82de51cd62b3f..e0f5c14c30221c34b2877b211cae1cc55613a461 100644 (file)
@@ -2002,11 +2002,24 @@ void brl_set_modified(struct byte_range_lock *br_lck, bool modified)
 bool file_has_brlocks(files_struct *fsp)
 {
        struct byte_range_lock *br_lck = NULL;
+       uint i, num_locks;
 
        br_lck = brl_get_locks_readonly(fsp);
        if (br_lck == NULL) {
                return false;
        }
 
-       return (brl_num_locks(br_lck) > 0);
+       num_locks = brl_num_locks(br_lck);
+       if (num_locks == 0) {
+               return false;
+       }
+
+       for (i = 0; i < num_locks; i++) {
+               struct lock_struct *l = &br_lck->lock_data[i];
+
+               if (l->start < fsp->fsp_name->st.st_ex_size) {
+                       return true;
+               }
+       }
+       return false;
 }