1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

s3:smbd: avoid false positives for got_oplock and have_other_lease in delay_for_oplock_fn

stat opens should not cause a oplock/lease downgrade if
they don't have a lease attached to itself.

Note that opens broken to NONE still count if they are
non-stat opens...

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

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Thu Oct 10 13:59:18 UTC 2024 on atb-devel-224

(cherry picked from commit dd5b9e08c7)

Autobuild-User(v4-20-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-20-test): Mon Oct 14 10:52:03 UTC 2024 on atb-devel-224
This commit is contained in:
Stefan Metzmacher 2024-08-30 14:16:12 +02:00 committed by Jule Anger
parent 1e9bd54ef0
commit 24e89430b1
3 changed files with 20 additions and 9 deletions

View File

@ -219,7 +219,6 @@
^samba3.smb2.compound.interim2 # wrong return code (STATUS_CANCELLED)
^samba3.smb2.compound.aio.interim2 # wrong return code (STATUS_CANCELLED)
^samba3.smb2.lock.*replay_broken_windows # This tests the windows behaviour
^samba3.smb2.lease.statopen3
^samba3.smb2.lease.unlink # we currently do not downgrade RH lease to R after unlink
^samba4.smb2.ioctl.compress_notsup.*\(ad_dc_ntvfs\)
^samba3.raw.session.*reauth2 # maybe fix this?

View File

@ -1,2 +0,0 @@
^samba3.smb2.durable-v2-open.stat-and-lease
^samba3.smb2.durable-v2-open.nonstat-and-lease

View File

@ -2449,7 +2449,7 @@ struct delay_for_oplock_state {
bool first_open_attempt;
bool got_handle_lease;
bool got_oplock;
bool have_other_lease;
bool disallow_write_lease;
uint32_t total_lease_types;
bool delay;
struct blocker_debug_state *blocker_debug_state;
@ -2557,15 +2557,27 @@ static bool delay_for_oplock_fn(
}
if (!state->got_oplock &&
(e->op_type != NO_OPLOCK) &&
(e->op_type != LEASE_OPLOCK) &&
!share_entry_stale_pid(e)) {
state->got_oplock = true;
}
if (!state->have_other_lease &&
/*
* Two things prevent a write lease
* to be granted:
*
* 1. Any oplock or lease (even broken to NONE)
* 2. An open with an access mask other than
* FILE_READ_ATTRIBUTES, FILE_WRITE_ATTRIBUTES
* or SYNCHRONIZE_ACCESS
*/
if (!state->disallow_write_lease &&
(e->op_type != NO_OPLOCK || !is_oplock_stat_open(e->access_mask)) &&
!is_same_lease(fsp, e, lease) &&
!share_entry_stale_pid(e)) {
state->have_other_lease = true;
!share_entry_stale_pid(e))
{
state->disallow_write_lease = true;
}
if (e_is_lease && is_lease_stat_open(fsp->access_mask)) {
@ -2799,9 +2811,11 @@ grant:
granted &= ~SMB2_LEASE_READ;
}
if (state.have_other_lease) {
if (state.disallow_write_lease) {
/*
* Can grant only one writer
* Can grant only a write lease
* if there are no other leases
* and no other non-stat opens.
*/
granted &= ~SMB2_LEASE_WRITE;
}