From b907a4a8607b52896e4848fd29fdcb7d11031e22 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 19 Jul 2021 09:33:05 -0700 Subject: [PATCH 1/3] s3: smbd: Ensure we set is_fsa inside fsp_bind_smb() as soon as we have called smbXsrv_open_create(). The destructor has been set up at that point and so the correct path in close must be called, either close_normal_file() or close_directory(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14763 Signed-off-by: Jeremy Allison --- source3/smbd/files.c | 2 ++ source3/smbd/open.c | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/smbd/files.c b/source3/smbd/files.c index 413706fee0c..5f5ee33a117 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -129,6 +129,8 @@ NTSTATUS fsp_bind_smb(struct files_struct *fsp, struct smb_request *req) fsp->mid = req->mid; req->chain_fsp = fsp; + fsp->fsp_flags.is_fsa = true; + DBG_DEBUG("fsp [%s] mid [%" PRIu64"]\n", fsp_str_dbg(fsp), fsp->mid); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index c29662b4fd2..ed2982371fe 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -5947,8 +5947,6 @@ static NTSTATUS create_file_unixpath(connection_struct *conn, goto fail; } - fsp->fsp_flags.is_fsa = true; - if ((ea_list != NULL) && ((info == FILE_WAS_CREATED) || (info == FILE_WAS_OVERWRITTEN))) { status = set_ea(conn, fsp, ea_list); -- 2.27.0 From 4c404bd2cb3d10e54b90866044d2ffe75d205203 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Jul 2021 16:26:26 -0700 Subject: [PATCH 2/3] s3: smbd: If we're erroring out an open request by calling close_file(), we may not have created a share mode entry yet. Ensure we don't log DBG_ERR messages inside close_remove_share_mode() in the ERROR_CLOSE case if we can't find the share mode entry. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14763 Signed-off-by: Jeremy Allison --- source3/smbd/close.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 191626557dc..c571f100a68 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -308,8 +308,10 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp, lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id); if (lck == NULL) { - DEBUG(0, ("close_remove_share_mode: Could not get share mode " - "lock for file %s\n", fsp_str_dbg(fsp))); + if (close_type != ERROR_CLOSE) { + DBG_ERR("Could not get share mode " + "lock for file %s\n", fsp_str_dbg(fsp)); + } return NT_STATUS_INVALID_PARAMETER; } -- 2.27.0 From b1bd1f21fc5c8fd3924f2f5785967762d74572e1 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 22 Jul 2021 19:23:56 -0700 Subject: [PATCH 3/3] s3: smbd: If we're erroring out an open request by calling close_file(), we may not have created a share mode entry yet. Ensure we don't log DBG_ERR messages inside close_directory() in the ERROR_CLOSE case if we can't find the share mode entry. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14763 Signed-off-by: Jeremy Allison --- source3/smbd/close.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source3/smbd/close.c b/source3/smbd/close.c index c571f100a68..b24972bdbdc 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -1325,8 +1325,10 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id); if (lck == NULL) { - DEBUG(0, ("close_directory: Could not get share mode lock for " - "%s\n", fsp_str_dbg(fsp))); + if (close_type != ERROR_CLOSE) { + DBG_ERR("Could not get share mode " + "lock for directory %s\n", fsp_str_dbg(fsp)); + } file_free(req, fsp); return NT_STATUS_INVALID_PARAMETER; } -- 2.27.0