]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: improve lease break when handling overwrite create disposition
authorRalph Boehme <slow@samba.org>
Fri, 8 Aug 2025 11:52:59 +0000 (13:52 +0200)
committerVolker Lendecke <vl@samba.org>
Fri, 15 Aug 2025 16:51:05 +0000 (16:51 +0000)
If the contending create uses overwrite create disposition, but has caused a
sharing violation and the existing create has a SMB2_LEASE_HANDLE, then the
server should just send break the SMB2_LEASE_HANDLE.

The break will then either result in a close and the contending open succeeds,
or a STATUS_SHARING_VIOLATION. Either way, there's no need to additionally break
SMB2_LEASE_READ or SMB2_LEASE_WRITE.

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>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Fri Aug 15 16:51:05 UTC 2025 on atb-devel-224

selftest/knownfail.d/samba3.smb2.lease [deleted file]
source3/smbd/open.c

diff --git a/selftest/knownfail.d/samba3.smb2.lease b/selftest/knownfail.d/samba3.smb2.lease
deleted file mode 100644 (file)
index b9c36e5..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba3.smb2.lease.sharing_violation\(fileserver\)
index 01c06f69c9d3831749661b7ab0de7d5b7e0bb91e..e898829c52c83e43ef3c0635473f437941c5679b 100644 (file)
@@ -2269,7 +2269,7 @@ static bool delay_for_oplock_fn(
 
        break_to = e_lease_type & ~state->delay_mask;
 
-       if (state->will_overwrite) {
+       if (state->will_overwrite && !(state->delay_mask & SMB2_LEASE_HANDLE)) {
                break_to &= ~(SMB2_LEASE_HANDLE|SMB2_LEASE_READ);
        }
 
@@ -2288,7 +2288,7 @@ static bool delay_for_oplock_fn(
                return false;
        }
 
-       if (state->will_overwrite) {
+       if (state->will_overwrite && !(state->delay_mask & SMB2_LEASE_HANDLE)) {
                /*
                 * If we break anyway break to NONE directly.
                 * Otherwise vfs_set_filelen() will trigger the