The branch, master has been updated
       via  58adf349edf s3:smbd: check for stale pid in delay_for_oplock_fn() 
when leases_db_get() fails
       via  217693682d5 s3:leases: log errors with level 0 in 
leases_db_do_locked_fn()
      from  8bd7669d8d2 dsdb/password_hash: don't double assign variables (CID 
1363048, 1034720)

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 58adf349edfd3001ad071cc7ed8cfc551f67f8a2
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 6 08:58:22 2020 +0200

    s3:smbd: check for stale pid in delay_for_oplock_fn() when leases_db_get() 
fails
    
    If leases_db_get() failed the leases_db record might have been cleaned up 
for
    stale processes. Check if the share-mode-entry owner is stale in this case 
and
    return ignore the entry. In any other case, log a debug messages and panic.
    
    Commit 05d4466a6d1ad048fa86aea09ec0a56a7b961369
    "smbd: check for stale pid in get_lease_type()" fixed only one half of
    this.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14428
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Tue Jul  7 02:47:46 UTC 2020 on sn-devel-184

commit 217693682d5bbd0f2d6b5331f47b2a6348840898
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 6 14:03:39 2020 +0200

    s3:leases: log errors with level 0 in leases_db_do_locked_fn()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14428
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/locking/leases_db.c |  8 ++++----
 source3/smbd/open.c         | 37 ++++++++++++++++++++++++++++++++++++-
 2 files changed, 40 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/locking/leases_db.c b/source3/locking/leases_db.c
index 2e2ccb150ac..855d6143ad7 100644
--- a/source3/locking/leases_db.c
+++ b/source3/locking/leases_db.c
@@ -121,7 +121,7 @@ static void leases_db_do_locked_fn(
                        value,
                        (ndr_pull_flags_fn_t)ndr_pull_leases_db_value);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-                       DBG_DEBUG("ndr_pull_struct_blob_failed: %s\n",
+                       DBG_ERR("ndr_pull_struct_blob_failed: %s\n",
                                  ndr_errstr(ndr_err));
                        state->status = ndr_map_error2ntstatus(ndr_err);
                        goto done;
@@ -137,7 +137,7 @@ static void leases_db_do_locked_fn(
        if (value->num_files == 0) {
                state->status = dbwrap_record_delete(rec);
                if (!NT_STATUS_IS_OK(state->status)) {
-                       DBG_DEBUG("dbwrap_record_delete returned %s\n",
+                       DBG_ERR("dbwrap_record_delete returned %s\n",
                                  nt_errstr(state->status));
                }
                goto done;
@@ -149,7 +149,7 @@ static void leases_db_do_locked_fn(
                value,
                (ndr_push_flags_fn_t)ndr_push_leases_db_value);
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-               DBG_DEBUG("ndr_push_struct_blob_failed: %s\n",
+               DBG_ERR("ndr_push_struct_blob_failed: %s\n",
                          ndr_errstr(ndr_err));
                state->status = ndr_map_error2ntstatus(ndr_err);
                goto done;
@@ -164,7 +164,7 @@ static void leases_db_do_locked_fn(
 
        state->status = dbwrap_record_store(rec, db_value, 0);
        if (!NT_STATUS_IS_OK(state->status)) {
-               DBG_DEBUG("dbwrap_record_store returned %s\n",
+               DBG_ERR("dbwrap_record_store returned %s\n",
                          nt_errstr(state->status));
        }
 
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 8f6d293c06f..fa3d21fe38e 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2463,7 +2463,42 @@ static bool delay_for_oplock_fn(
                        NULL, /* breaking_to_required */
                        NULL, /* lease_version */
                        NULL); /* epoch */
-               SMB_ASSERT(NT_STATUS_IS_OK(status));
+
+               /*
+                * leases_db_get() can return NT_STATUS_NOT_FOUND
+                * if the share_mode_entry e is stale and the
+                * lease record was already removed. In this case return
+                * false so the traverse continues.
+                */
+
+               if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND) &&
+                   share_entry_stale_pid(e))
+               {
+                       struct GUID_txt_buf guid_strbuf;
+                       struct file_id_buf file_id_strbuf;
+                       DBG_DEBUG("leases_db_get for client_guid [%s] "
+                                 "lease_key [%"PRIu64"/%"PRIu64"] "
+                                 "file_id [%s] failed for stale "
+                                 "share_mode_entry\n",
+                                 GUID_buf_string(&e->client_guid, 
&guid_strbuf),
+                                 e->lease_key.data[0],
+                                 e->lease_key.data[1],
+                                 file_id_str_buf(fsp->file_id, 
&file_id_strbuf));
+                       return false;
+               }
+               if (!NT_STATUS_IS_OK(status)) {
+                       struct GUID_txt_buf guid_strbuf;
+                       struct file_id_buf file_id_strbuf;
+                       DBG_ERR("leases_db_get for client_guid [%s] "
+                               "lease_key [%"PRIu64"/%"PRIu64"] "
+                               "file_id [%s] failed: %s\n",
+                               GUID_buf_string(&e->client_guid, &guid_strbuf),
+                               e->lease_key.data[0],
+                               e->lease_key.data[1],
+                               file_id_str_buf(fsp->file_id, &file_id_strbuf),
+                               nt_errstr(status));
+                       smb_panic("leases_db_get() failed");
+               }
        }
 
        if (!state->got_handle_lease &&


-- 
Samba Shared Repository

Reply via email to