From 00001286e1d8bd583f676d380b9c335432b0f61d Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 5 Mar 2020 15:12:20 +0100 Subject: [PATCH] smbd: rename is_stat_open() to is_oplock_stat_open() Testing stat opens with with leases reveals that that the access mask SYNCHRONIZE_ACCESS | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES is specific to oplocks. See also: https://lists.samba.org/archive/cifs-protocol/2020-March/003409.html BUG: https://bugzilla.samba.org/show_bug.cgi?id=14357 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- source3/smbd/open.c | 13 ++++++++----- source3/smbd/proto.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source3/smbd/open.c b/source3/smbd/open.c index aa86cef944a..b5160300e48 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1563,7 +1563,10 @@ static bool validate_my_share_entries_fn( } #endif -bool is_stat_open(uint32_t access_mask) +/** + * Allowed access mask for stat opens relevant to oplocks + **/ +bool is_oplock_stat_open(uint32_t access_mask) { const uint32_t stat_open_bits = (SYNCHRONIZE_ACCESS| @@ -1771,7 +1774,7 @@ static NTSTATUS open_mode_check(connection_struct *conn, uint16_t new_flags; bool ok, conflict, have_share_entries; - if (is_stat_open(access_mask)) { + if (is_oplock_stat_open(access_mask)) { /* Stat open that doesn't trigger oplock breaks or share mode * checks... ! JRA. */ return NT_STATUS_OK; @@ -1928,7 +1931,7 @@ static bool validate_oplock_types_fn( return false; } - if (e->op_type == NO_OPLOCK && is_stat_open(e->access_mask)) { + if (e->op_type == NO_OPLOCK && is_oplock_stat_open(e->access_mask)) { /* * We ignore stat opens in the table - they always * have NO_OPLOCK and never get or cause breaks. JRA. @@ -2422,7 +2425,7 @@ static NTSTATUS delay_for_oplock(files_struct *fsp, NTSTATUS status; bool ok; - if (is_stat_open(fsp->access_mask)) { + if (is_oplock_stat_open(fsp->access_mask)) { goto grant; } @@ -3491,7 +3494,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, * FILE_OVERWRITE and FILE_OVERWRITE_IF add in O_TRUNC, * which adds FILE_WRITE_DATA to open_access_mask. */ - if (is_stat_open(open_access_mask) && lease == NULL) { + if (is_oplock_stat_open(open_access_mask) && lease == NULL) { oplock_request = NO_OPLOCK; } } diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 3d9ffaa6898..5713620ab6e 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -713,7 +713,7 @@ NTSTATUS fd_close(files_struct *fsp); void change_file_owner_to_parent(connection_struct *conn, struct smb_filename *inherit_from_dir, files_struct *fsp); -bool is_stat_open(uint32_t access_mask); +bool is_oplock_stat_open(uint32_t access_mask); NTSTATUS send_break_message(struct messaging_context *msg_ctx, const struct file_id *id, const struct share_mode_entry *exclusive, -- 2.47.3