From: Ralph Boehme Date: Thu, 2 Jul 2020 12:47:12 +0000 (+0200) Subject: smbd: check for stale pid in get_lease_type() X-Git-Tag: samba-4.13.0rc1~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05d4466a6d1ad048fa86aea09ec0a56a7b961369;p=thirdparty%2Fsamba.git smbd: check for stale pid in get_lease_type() 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 a 0 lease state. In any other case, log a debug messages and panic. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14428 Signed-off-by: Ralph Boehme Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Thu Jul 2 16:45:42 UTC 2020 on sn-devel-184 --- diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c index 97ab05b2ba6..1c1510f3aab 100644 --- a/source3/smbd/oplock.c +++ b/source3/smbd/oplock.c @@ -171,6 +171,8 @@ static void downgrade_file_oplock(files_struct *fsp) uint32_t get_lease_type(struct share_mode_entry *e, struct file_id id) { + struct GUID_txt_buf guid_strbuf; + struct file_id_buf file_id_strbuf; NTSTATUS status; uint32_t current_state; @@ -187,8 +189,22 @@ uint32_t get_lease_type(struct share_mode_entry *e, struct file_id id) NULL, /* breaking_to_required */ NULL, /* lease_version */ NULL); /* epoch */ - SMB_ASSERT(NT_STATUS_IS_OK(status)); - return current_state; + if (NT_STATUS_IS_OK(status)) { + return current_state; + } + + if (share_entry_stale_pid(e)) { + return 0; + } + 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(id, &file_id_strbuf), + nt_errstr(status)); + smb_panic("leases_db_get() failed"); } /****************************************************************************