From: Stefan Metzmacher Date: Wed, 10 Aug 2022 08:27:15 +0000 (+0000) Subject: s3:locking: pass lease_key explicitly to set_share_mode() X-Git-Tag: talloc-2.4.0~1393 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8b3b316680221487f84a7cfe14f52e8ffd64ba85;p=thirdparty%2Fsamba.git s3:locking: pass lease_key explicitly to set_share_mode() We should avoid accessing fsp->lease if possible. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15125 Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison --- diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index cf1447d889e..b3f30c0f512 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -1782,6 +1782,7 @@ bool set_share_mode(struct share_mode_lock *lck, uid_t uid, uint64_t mid, uint16_t op_type, + const struct smb2_lease_key *lease_key, uint32_t share_access, uint32_t access_mask) { @@ -1839,7 +1840,7 @@ bool set_share_mode(struct share_mode_lock *lck, if (op_type == LEASE_OPLOCK) { const struct GUID *client_guid = fsp_client_guid(fsp); e.client_guid = *client_guid; - e.lease_key = fsp->lease->lease.lease_key; + e.lease_key = *lease_key; } ok = share_mode_entry_put(&e, &e_buf); diff --git a/source3/locking/share_mode_lock.h b/source3/locking/share_mode_lock.h index bd4e98ccecd..f8693b14b54 100644 --- a/source3/locking/share_mode_lock.h +++ b/source3/locking/share_mode_lock.h @@ -26,6 +26,7 @@ struct share_mode_lock; struct share_mode_entry; struct smb_filename; struct files_struct; +struct smb2_lease_key; bool locking_init(void); bool locking_init_readonly(void); @@ -52,6 +53,7 @@ bool set_share_mode( uid_t uid, uint64_t mid, uint16_t op_type, + const struct smb2_lease_key *lease_key, uint32_t share_access, uint32_t access_mask); bool reset_share_mode_entry( diff --git a/source3/smbd/open.c b/source3/smbd/open.c index e189d418262..5eea89d69c8 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -3548,6 +3548,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, uint32_t existing_dos_attributes = 0; struct share_mode_lock *lck = NULL; uint32_t open_access_mask = access_mask; + const struct smb2_lease_key *lease_key = NULL; NTSTATUS status; SMB_STRUCT_STAT saved_stat = smb_fname->st; struct timespec old_write_time; @@ -4064,6 +4065,10 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, return status; } + if (fsp->oplock_type == LEASE_OPLOCK) { + lease_key = &lease->lease_key; + } + share_mode_flags_restrict(lck, access_mask, share_access, 0); ok = set_share_mode( @@ -4072,6 +4077,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, get_current_uid(fsp->conn), req ? req->mid : 0, fsp->oplock_type, + lease_key, share_access, access_mask); if (!ok) { @@ -4752,6 +4758,7 @@ static NTSTATUS open_directory(connection_struct *conn, get_current_uid(conn), req ? req->mid : 0, NO_OPLOCK, + NULL, share_access, fsp->access_mask); if (!ok) {