Lines Matching +full:tcon +full:- +full:channel
1 // SPDX-License-Identifier: LGPL-2.1
24 __u64 wire_mid = le64_to_cpu(shdr->MessageId); in check_smb2_hdr()
30 if ((shdr->ProtocolId == SMB2_PROTO_NUMBER) && in check_smb2_hdr()
32 if (shdr->Flags & SMB2_FLAGS_SERVER_TO_REDIR) in check_smb2_hdr()
36 if (shdr->Command == SMB2_OPLOCK_BREAK) in check_smb2_hdr()
42 if (shdr->ProtocolId != SMB2_PROTO_NUMBER) in check_smb2_hdr()
44 le32_to_cpu(shdr->ProtocolId)); in check_smb2_hdr()
94 neg_count = le16_to_cpu(pneg_rsp->NegotiateContextCount); in get_neg_ctxt_len()
96 (pneg_rsp->DialectRevision != cpu_to_le16(SMB311_PROT_ID))) in get_neg_ctxt_len()
104 nc_offset = le32_to_cpu(pneg_rsp->NegotiateContextOffset); in get_neg_ctxt_len()
106 * non_ctxlen is at least shdr->StructureSize + pdu->StructureSize2 in get_neg_ctxt_len()
107 * and the latter is 1 byte bigger than the fix-sized area of the in get_neg_ctxt_len()
118 size_of_pad_before_neg_ctxts = nc_offset - non_ctxlen + 1; in get_neg_ctxt_len()
120 size_of_pad_before_neg_ctxts = nc_offset - non_ctxlen; in get_neg_ctxt_len()
129 len - nc_offset, size_of_pad_before_neg_ctxts); in get_neg_ctxt_len()
132 return (len - nc_offset) + size_of_pad_before_neg_ctxts; in get_neg_ctxt_len()
147 /* If server is a channel, select the primary channel */ in smb2_check_message()
148 pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; in smb2_check_message()
154 if (shdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM) { in smb2_check_message()
162 list_for_each_entry(iter, &pserver->smb_ses_list, smb_ses_list) { in smb2_check_message()
163 if (iter->Suid == le64_to_cpu(thdr->SessionId)) { in smb2_check_message()
170 cifs_dbg(VFS, "no decryption - session id not found\n"); in smb2_check_message()
175 mid = le64_to_cpu(shdr->MessageId); in smb2_check_message()
179 if (shdr->StructureSize != SMB2_HEADER_STRUCTURE_SIZE) { in smb2_check_message()
181 le16_to_cpu(shdr->StructureSize)); in smb2_check_message()
185 command = le16_to_cpu(shdr->Command); in smb2_check_message()
193 && (shdr->Status != 0)) { in smb2_check_message()
194 pdu->StructureSize2 = 0; in smb2_check_message()
211 if (smb2_rsp_struct_sizes[command] != pdu->StructureSize2) { in smb2_check_message()
212 if (command != SMB2_OPLOCK_BREAK_HE && (shdr->Status == 0 || in smb2_check_message()
213 pdu->StructureSize2 != SMB2_ERROR_STRUCTURE_SIZE2_LE)) { in smb2_check_message()
216 le16_to_cpu(pdu->StructureSize2), command); in smb2_check_message()
219 && (shdr->Status == 0) in smb2_check_message()
220 && (le16_to_cpu(pdu->StructureSize2) != 44) in smb2_check_message()
221 && (le16_to_cpu(pdu->StructureSize2) != 36)) { in smb2_check_message()
224 le16_to_cpu(pdu->StructureSize2)); in smb2_check_message()
242 shdr->Status == STATUS_STOPPED_ON_SYMLINK) in smb2_check_message()
323 if (shdr->Status && shdr->Status != STATUS_MORE_PROCESSING_REQUIRED && in smb2_get_data_area_len()
324 (((struct smb2_err_rsp *)shdr)->StructureSize) == in smb2_get_data_area_len()
333 switch (shdr->Command) { in smb2_get_data_area_len()
336 ((struct smb2_negotiate_rsp *)shdr)->SecurityBufferOffset); in smb2_get_data_area_len()
338 ((struct smb2_negotiate_rsp *)shdr)->SecurityBufferLength); in smb2_get_data_area_len()
342 ((struct smb2_sess_setup_rsp *)shdr)->SecurityBufferOffset); in smb2_get_data_area_len()
344 ((struct smb2_sess_setup_rsp *)shdr)->SecurityBufferLength); in smb2_get_data_area_len()
348 ((struct smb2_create_rsp *)shdr)->CreateContextsOffset); in smb2_get_data_area_len()
350 ((struct smb2_create_rsp *)shdr)->CreateContextsLength); in smb2_get_data_area_len()
354 ((struct smb2_query_info_rsp *)shdr)->OutputBufferOffset); in smb2_get_data_area_len()
356 ((struct smb2_query_info_rsp *)shdr)->OutputBufferLength); in smb2_get_data_area_len()
360 *off = ((struct smb2_read_rsp *)shdr)->DataOffset; in smb2_get_data_area_len()
361 *len = le32_to_cpu(((struct smb2_read_rsp *)shdr)->DataLength); in smb2_get_data_area_len()
365 ((struct smb2_query_directory_rsp *)shdr)->OutputBufferOffset); in smb2_get_data_area_len()
367 ((struct smb2_query_directory_rsp *)shdr)->OutputBufferLength); in smb2_get_data_area_len()
371 ((struct smb2_ioctl_rsp *)shdr)->OutputOffset); in smb2_get_data_area_len()
373 ((struct smb2_ioctl_rsp *)shdr)->OutputCount); in smb2_get_data_area_len()
377 ((struct smb2_change_notify_rsp *)shdr)->OutputBufferOffset); in smb2_get_data_area_len()
379 ((struct smb2_change_notify_rsp *)shdr)->OutputBufferLength); in smb2_get_data_area_len()
382 cifs_dbg(VFS, "no length check for command %d\n", le16_to_cpu(shdr->Command)); in smb2_get_data_area_len()
414 struct smb2_hdr *shdr = &pdu->hdr; in smb2_calc_size()
418 int len = le16_to_cpu(shdr->StructureSize); in smb2_calc_size()
424 len += le16_to_cpu(pdu->StructureSize2); in smb2_calc_size()
426 if (has_smb2_data_area[le16_to_cpu(shdr->Command)] == false) in smb2_calc_size()
461 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR) in cifs_convert_path_to_utf16()
463 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR) in cifs_convert_path_to_utf16()
474 cifs_sb_master_tcon(cifs_sb)->posix_extensions && in cifs_convert_path_to_utf16()
481 cifs_sb->local_nls, map_type); in cifs_convert_path_to_utf16()
513 rc = SMB2_lease_break(0, tlink_tcon(lw->tlink), lw->lease_key, in cifs_ses_oplock_break()
514 lw->lease_state); in cifs_ses_oplock_break()
517 cifs_put_tlink(lw->tlink); in cifs_ses_oplock_break()
533 INIT_WORK(&lw->lease_break, cifs_ses_oplock_break); in smb2_queue_pending_open_break()
534 lw->tlink = tlink; in smb2_queue_pending_open_break()
535 lw->lease_state = new_lease_state; in smb2_queue_pending_open_break()
536 memcpy(lw->lease_key, lease_key, SMB2_LEASE_KEY_SIZE); in smb2_queue_pending_open_break()
537 queue_work(cifsiod_wq, &lw->lease_break); in smb2_queue_pending_open_break()
541 smb2_tcon_has_lease(struct cifs_tcon *tcon, struct smb2_lease_break *rsp) in smb2_tcon_has_lease() argument
546 int ack_req = le32_to_cpu(rsp->Flags & in smb2_tcon_has_lease()
549 lease_state = le32_to_cpu(rsp->NewLeaseState); in smb2_tcon_has_lease()
551 list_for_each_entry(cfile, &tcon->openFileList, tlist) { in smb2_tcon_has_lease()
552 cinode = CIFS_I(d_inode(cfile->dentry)); in smb2_tcon_has_lease()
554 if (memcmp(cinode->lease_key, rsp->LeaseKey, in smb2_tcon_has_lease()
563 cfile->oplock_break_cancelled = false; in smb2_tcon_has_lease()
565 cfile->oplock_break_cancelled = true; in smb2_tcon_has_lease()
567 set_bit(CIFS_INODE_PENDING_OPLOCK_BREAK, &cinode->flags); in smb2_tcon_has_lease()
569 cfile->oplock_epoch = le16_to_cpu(rsp->Epoch); in smb2_tcon_has_lease()
570 cfile->oplock_level = lease_state; in smb2_tcon_has_lease()
580 smb2_tcon_find_pending_open_lease(struct cifs_tcon *tcon, in smb2_tcon_find_pending_open_lease() argument
583 __u8 lease_state = le32_to_cpu(rsp->NewLeaseState); in smb2_tcon_find_pending_open_lease()
584 int ack_req = le32_to_cpu(rsp->Flags & in smb2_tcon_find_pending_open_lease()
589 list_for_each_entry(open, &tcon->pending_opens, olist) { in smb2_tcon_find_pending_open_lease()
590 if (memcmp(open->lease_key, rsp->LeaseKey, in smb2_tcon_find_pending_open_lease()
602 open->oplock = lease_state; in smb2_tcon_find_pending_open_lease()
614 struct cifs_tcon *tcon; in smb2_is_valid_lease_break() local
619 /* If server is a channel, select the primary channel */ in smb2_is_valid_lease_break()
620 pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; in smb2_is_valid_lease_break()
622 /* look up tcon based on tid & uid */ in smb2_is_valid_lease_break()
624 list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) { in smb2_is_valid_lease_break()
627 list_for_each_entry(tcon, &ses->tcon_list, tcon_list) { in smb2_is_valid_lease_break()
628 spin_lock(&tcon->open_file_lock); in smb2_is_valid_lease_break()
630 &tcon->stats.cifs_stats.num_oplock_brks); in smb2_is_valid_lease_break()
631 if (smb2_tcon_has_lease(tcon, rsp)) { in smb2_is_valid_lease_break()
632 spin_unlock(&tcon->open_file_lock); in smb2_is_valid_lease_break()
636 open = smb2_tcon_find_pending_open_lease(tcon, in smb2_is_valid_lease_break()
642 tlink = cifs_get_tlink(open->tlink); in smb2_is_valid_lease_break()
643 memcpy(lease_key, open->lease_key, in smb2_is_valid_lease_break()
645 spin_unlock(&tcon->open_file_lock); in smb2_is_valid_lease_break()
649 rsp->NewLeaseState); in smb2_is_valid_lease_break()
652 spin_unlock(&tcon->open_file_lock); in smb2_is_valid_lease_break()
654 if (cached_dir_lease_break(tcon, rsp->LeaseKey)) { in smb2_is_valid_lease_break()
661 cifs_dbg(FYI, "Can not process lease break - no lease matched\n"); in smb2_is_valid_lease_break()
662 trace_smb3_lease_not_found(le32_to_cpu(rsp->CurrentLeaseState), in smb2_is_valid_lease_break()
663 le32_to_cpu(rsp->hdr.Id.SyncId.TreeId), in smb2_is_valid_lease_break()
664 le64_to_cpu(rsp->hdr.SessionId), in smb2_is_valid_lease_break()
665 *((u64 *)rsp->LeaseKey), in smb2_is_valid_lease_break()
666 *((u64 *)&rsp->LeaseKey[8])); in smb2_is_valid_lease_break()
677 struct cifs_tcon *tcon; in smb2_is_valid_oplock_break() local
683 if (rsp->hdr.Command != SMB2_OPLOCK_BREAK) in smb2_is_valid_oplock_break()
686 if (rsp->StructureSize != in smb2_is_valid_oplock_break()
688 if (le16_to_cpu(rsp->StructureSize) == 44) in smb2_is_valid_oplock_break()
694 cifs_dbg(FYI, "oplock level 0x%x\n", rsp->OplockLevel); in smb2_is_valid_oplock_break()
696 /* If server is a channel, select the primary channel */ in smb2_is_valid_oplock_break()
697 pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; in smb2_is_valid_oplock_break()
699 /* look up tcon based on tid & uid */ in smb2_is_valid_oplock_break()
701 list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) { in smb2_is_valid_oplock_break()
704 list_for_each_entry(tcon, &ses->tcon_list, tcon_list) { in smb2_is_valid_oplock_break()
706 spin_lock(&tcon->open_file_lock); in smb2_is_valid_oplock_break()
707 list_for_each_entry(cfile, &tcon->openFileList, tlist) { in smb2_is_valid_oplock_break()
708 if (rsp->PersistentFid != in smb2_is_valid_oplock_break()
709 cfile->fid.persistent_fid || in smb2_is_valid_oplock_break()
710 rsp->VolatileFid != in smb2_is_valid_oplock_break()
711 cfile->fid.volatile_fid) in smb2_is_valid_oplock_break()
716 &tcon->stats.cifs_stats.num_oplock_brks); in smb2_is_valid_oplock_break()
717 cinode = CIFS_I(d_inode(cfile->dentry)); in smb2_is_valid_oplock_break()
718 spin_lock(&cfile->file_info_lock); in smb2_is_valid_oplock_break()
720 rsp->OplockLevel == SMB2_OPLOCK_LEVEL_NONE) in smb2_is_valid_oplock_break()
721 cfile->oplock_break_cancelled = true; in smb2_is_valid_oplock_break()
723 cfile->oplock_break_cancelled = false; in smb2_is_valid_oplock_break()
726 &cinode->flags); in smb2_is_valid_oplock_break()
728 cfile->oplock_epoch = 0; in smb2_is_valid_oplock_break()
729 cfile->oplock_level = rsp->OplockLevel; in smb2_is_valid_oplock_break()
731 spin_unlock(&cfile->file_info_lock); in smb2_is_valid_oplock_break()
735 spin_unlock(&tcon->open_file_lock); in smb2_is_valid_oplock_break()
739 spin_unlock(&tcon->open_file_lock); in smb2_is_valid_oplock_break()
744 trace_smb3_oplock_not_found(0 /* no xid */, rsp->PersistentFid, in smb2_is_valid_oplock_break()
745 le32_to_cpu(rsp->hdr.Id.SyncId.TreeId), in smb2_is_valid_oplock_break()
746 le64_to_cpu(rsp->hdr.SessionId)); in smb2_is_valid_oplock_break()
756 struct cifs_tcon *tcon = cancelled->tcon; in smb2_cancelled_close_fid() local
759 if (cancelled->mid) in smb2_cancelled_close_fid()
761 cancelled->mid); in smb2_cancelled_close_fid()
765 rc = SMB2_close(0, tcon, cancelled->fid.persistent_fid, in smb2_cancelled_close_fid()
766 cancelled->fid.volatile_fid); in smb2_cancelled_close_fid()
770 cifs_put_tcon(tcon, netfs_trace_tcon_ref_put_cancelled_close_fid); in smb2_cancelled_close_fid()
775 * Caller should already has an extra reference to @tcon
783 __smb2_handle_cancelled_cmd(struct cifs_tcon *tcon, __u16 cmd, __u64 mid, in __smb2_handle_cancelled_cmd() argument
790 return -ENOMEM; in __smb2_handle_cancelled_cmd()
792 cancelled->fid.persistent_fid = persistent_fid; in __smb2_handle_cancelled_cmd()
793 cancelled->fid.volatile_fid = volatile_fid; in __smb2_handle_cancelled_cmd()
794 cancelled->tcon = tcon; in __smb2_handle_cancelled_cmd()
795 cancelled->cmd = cmd; in __smb2_handle_cancelled_cmd()
796 cancelled->mid = mid; in __smb2_handle_cancelled_cmd()
797 INIT_WORK(&cancelled->work, smb2_cancelled_close_fid); in __smb2_handle_cancelled_cmd()
798 WARN_ON(queue_work(cifsiod_wq, &cancelled->work) == false); in __smb2_handle_cancelled_cmd()
804 smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid, in smb2_handle_cancelled_close() argument
809 cifs_dbg(FYI, "%s: tc_count=%d\n", __func__, tcon->tc_count); in smb2_handle_cancelled_close()
811 if (tcon->tc_count <= 0) { in smb2_handle_cancelled_close()
814 trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count, in smb2_handle_cancelled_close()
816 WARN_ONCE(tcon->tc_count < 0, "tcon refcount is negative"); in smb2_handle_cancelled_close()
819 if (tcon->ses) in smb2_handle_cancelled_close()
820 server = tcon->ses->server; in smb2_handle_cancelled_close()
822 cifs_server_dbg(FYI, "tid=0x%x: tcon is closing, skipping async close retry of fid %llu %llu\n", in smb2_handle_cancelled_close()
823 tcon->tid, persistent_fid, volatile_fid); in smb2_handle_cancelled_close()
827 tcon->tc_count++; in smb2_handle_cancelled_close()
828 trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count, in smb2_handle_cancelled_close()
832 rc = __smb2_handle_cancelled_cmd(tcon, SMB2_CLOSE_HE, 0, in smb2_handle_cancelled_close()
835 cifs_put_tcon(tcon, netfs_trace_tcon_ref_put_cancelled_close); in smb2_handle_cancelled_close()
843 struct smb2_hdr *hdr = mid->resp_buf; in smb2_handle_cancelled_mid()
844 struct smb2_create_rsp *rsp = mid->resp_buf; in smb2_handle_cancelled_mid()
845 struct cifs_tcon *tcon; in smb2_handle_cancelled_mid() local
848 if ((mid->optype & CIFS_CP_CREATE_CLOSE_OP) || hdr->Command != SMB2_CREATE || in smb2_handle_cancelled_mid()
849 hdr->Status != STATUS_SUCCESS) in smb2_handle_cancelled_mid()
852 tcon = smb2_find_smb_tcon(server, le64_to_cpu(hdr->SessionId), in smb2_handle_cancelled_mid()
853 le32_to_cpu(hdr->Id.SyncId.TreeId)); in smb2_handle_cancelled_mid()
854 if (!tcon) in smb2_handle_cancelled_mid()
855 return -ENOENT; in smb2_handle_cancelled_mid()
857 rc = __smb2_handle_cancelled_cmd(tcon, in smb2_handle_cancelled_mid()
858 le16_to_cpu(hdr->Command), in smb2_handle_cancelled_mid()
859 le64_to_cpu(hdr->MessageId), in smb2_handle_cancelled_mid()
860 rsp->PersistentFileId, in smb2_handle_cancelled_mid()
861 rsp->VolatileFileId); in smb2_handle_cancelled_mid()
863 cifs_put_tcon(tcon, netfs_trace_tcon_ref_put_cancelled_mid); in smb2_handle_cancelled_mid()
869 * smb311_update_preauth_hash - update @ses hash with the packet data in @iov
889 if (hdr->Command == SMB2_NEGOTIATE) in smb311_update_preauth_hash()
897 if (server->dialect != SMB311_PROT_ID) in smb311_update_preauth_hash()
900 if (hdr->Command != SMB2_SESSION_SETUP) in smb311_update_preauth_hash()
904 if ((hdr->Flags & SMB2_FLAGS_SERVER_TO_REDIR) in smb311_update_preauth_hash()
905 && (hdr->Status == NT_STATUS_OK in smb311_update_preauth_hash()
906 || (hdr->Status != in smb311_update_preauth_hash()
915 sha512 = server->secmech.sha512; in smb311_update_preauth_hash()
922 rc = crypto_shash_update(sha512, ses->preauth_sha_hash, in smb311_update_preauth_hash()
938 rc = crypto_shash_final(sha512, ses->preauth_sha_hash); in smb311_update_preauth_hash()