Lines Matching +full:co +full:- +full:located

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (C) 2018 Samsung Electronics Co., Ltd.
19 if (hdr->Flags & SMB2_FLAGS_SERVER_TO_REDIR) in check_smb2_hdr()
56 * located in different fields for various SMB2 requests. SMB2 requests
98 switch (hdr->Command) { in smb2_get_data_area_len()
100 *off = le16_to_cpu(((struct smb2_sess_setup_req *)hdr)->SecurityBufferOffset); in smb2_get_data_area_len()
101 *len = le16_to_cpu(((struct smb2_sess_setup_req *)hdr)->SecurityBufferLength); in smb2_get_data_area_len()
105 le16_to_cpu(((struct smb2_tree_connect_req *)hdr)->PathOffset), in smb2_get_data_area_len()
107 *len = le16_to_cpu(((struct smb2_tree_connect_req *)hdr)->PathLength); in smb2_get_data_area_len()
113 le16_to_cpu(((struct smb2_create_req *)hdr)->NameOffset), in smb2_get_data_area_len()
116 le16_to_cpu(((struct smb2_create_req *)hdr)->NameLength); in smb2_get_data_area_len()
118 if (((struct smb2_create_req *)hdr)->CreateContextsLength) { in smb2_get_data_area_len()
120 hdr)->CreateContextsOffset); in smb2_get_data_area_len()
122 hdr)->CreateContextsLength); in smb2_get_data_area_len()
136 le16_to_cpu(((struct smb2_query_info_req *)hdr)->InputBufferOffset), in smb2_get_data_area_len()
138 *len = le32_to_cpu(((struct smb2_query_info_req *)hdr)->InputBufferLength); in smb2_get_data_area_len()
142 le16_to_cpu(((struct smb2_set_info_req *)hdr)->BufferOffset), in smb2_get_data_area_len()
144 *len = le32_to_cpu(((struct smb2_set_info_req *)hdr)->BufferLength); in smb2_get_data_area_len()
147 *off = le16_to_cpu(((struct smb2_read_req *)hdr)->ReadChannelInfoOffset); in smb2_get_data_area_len()
148 *len = le16_to_cpu(((struct smb2_read_req *)hdr)->ReadChannelInfoLength); in smb2_get_data_area_len()
151 if (((struct smb2_write_req *)hdr)->DataOffset || in smb2_get_data_area_len()
152 ((struct smb2_write_req *)hdr)->Length) { in smb2_get_data_area_len()
154 le16_to_cpu(((struct smb2_write_req *)hdr)->DataOffset), in smb2_get_data_area_len()
156 *len = le32_to_cpu(((struct smb2_write_req *)hdr)->Length); in smb2_get_data_area_len()
160 *off = le16_to_cpu(((struct smb2_write_req *)hdr)->WriteChannelInfoOffset); in smb2_get_data_area_len()
161 *len = le16_to_cpu(((struct smb2_write_req *)hdr)->WriteChannelInfoLength); in smb2_get_data_area_len()
165 le16_to_cpu(((struct smb2_query_directory_req *)hdr)->FileNameOffset), in smb2_get_data_area_len()
167 *len = le16_to_cpu(((struct smb2_query_directory_req *)hdr)->FileNameLength); in smb2_get_data_area_len()
173 lock_count = le16_to_cpu(((struct smb2_lock_req *)hdr)->LockCount); in smb2_get_data_area_len()
182 le32_to_cpu(((struct smb2_ioctl_req *)hdr)->InputOffset), in smb2_get_data_area_len()
184 *len = le32_to_cpu(((struct smb2_ioctl_req *)hdr)->InputCount); in smb2_get_data_area_len()
193 ret = -EINVAL; in smb2_get_data_area_len()
197 ret = -EINVAL; in smb2_get_data_area_len()
210 struct smb2_hdr *hdr = &pdu->hdr; in smb2_calc_size()
216 *len = le16_to_cpu(hdr->StructureSize); in smb2_calc_size()
222 *len += le16_to_cpu(pdu->StructureSize2); in smb2_calc_size()
229 if (hdr->Command == SMB2_LOCK) in smb2_calc_size()
230 *len -= sizeof(struct smb2_lock_element); in smb2_calc_size()
232 if (has_smb2_data_area[le16_to_cpu(hdr->Command)] == false) in smb2_calc_size()
252 return -EINVAL; in smb2_calc_size()
265 return le32_to_cpu(h->InputBufferLength) + in smb2_query_info_req_len()
266 le32_to_cpu(h->OutputBufferLength); in smb2_query_info_req_len()
271 return le32_to_cpu(h->BufferLength); in smb2_set_info_req_len()
276 return le32_to_cpu(h->Length); in smb2_read_req_len()
281 return le32_to_cpu(h->Length); in smb2_write_req_len()
286 return le32_to_cpu(h->OutputBufferLength); in smb2_query_dir_req_len()
291 return le32_to_cpu(h->InputCount) + in smb2_ioctl_req_len()
292 le32_to_cpu(h->OutputCount); in smb2_ioctl_req_len()
297 return le32_to_cpu(h->MaxInputResponse) + in smb2_ioctl_resp_len()
298 le32_to_cpu(h->MaxOutputResponse); in smb2_ioctl_resp_len()
305 unsigned short credit_charge = le16_to_cpu(hdr->CreditCharge); in smb2_validate_credit_charge()
309 switch (hdr->Command) { in smb2_validate_credit_charge()
344 } else if (credit_charge > conn->vals->max_credits) { in smb2_validate_credit_charge()
349 spin_lock(&conn->credits_lock); in smb2_validate_credit_charge()
350 if (credit_charge > conn->total_credits) { in smb2_validate_credit_charge()
352 credit_charge, conn->total_credits); in smb2_validate_credit_charge()
356 if ((u64)conn->outstanding_credits + credit_charge > conn->total_credits) { in smb2_validate_credit_charge()
358 credit_charge, conn->outstanding_credits); in smb2_validate_credit_charge()
361 conn->outstanding_credits += credit_charge; in smb2_validate_credit_charge()
363 spin_unlock(&conn->credits_lock); in smb2_validate_credit_charge()
371 struct smb2_hdr *hdr = &pdu->hdr; in ksmbd_smb2_check_message()
374 __u32 len = get_rfc1002_len(work->request_buf); in ksmbd_smb2_check_message()
375 __u32 req_struct_size, next_cmd = le32_to_cpu(hdr->NextCommand); in ksmbd_smb2_check_message()
377 if ((u64)work->next_smb2_rcv_hdr_off + next_cmd > len) { in ksmbd_smb2_check_message()
385 else if (work->next_smb2_rcv_hdr_off) in ksmbd_smb2_check_message()
386 len -= work->next_smb2_rcv_hdr_off; in ksmbd_smb2_check_message()
391 if (hdr->StructureSize != SMB2_HEADER_STRUCTURE_SIZE) { in ksmbd_smb2_check_message()
393 le16_to_cpu(hdr->StructureSize)); in ksmbd_smb2_check_message()
397 command = le16_to_cpu(hdr->Command); in ksmbd_smb2_check_message()
403 if (smb2_req_struct_sizes[command] != pdu->StructureSize2) { in ksmbd_smb2_check_message()
405 (le16_to_cpu(pdu->StructureSize2) == OP_BREAK_STRUCT_SIZE_20 || in ksmbd_smb2_check_message()
406 le16_to_cpu(pdu->StructureSize2) == OP_BREAK_STRUCT_SIZE_21))) { in ksmbd_smb2_check_message()
410 le16_to_cpu(pdu->StructureSize2), command); in ksmbd_smb2_check_message()
415 req_struct_size = le16_to_cpu(pdu->StructureSize2) + in ksmbd_smb2_check_message()
418 req_struct_size -= sizeof(struct smb2_lock_element); in ksmbd_smb2_check_message()
451 if (clc_len < len && (len - clc_len) <= 8) in ksmbd_smb2_check_message()
457 le64_to_cpu(hdr->MessageId)); in ksmbd_smb2_check_message()
463 if ((work->conn->vals->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU) && in ksmbd_smb2_check_message()
464 smb2_validate_credit_charge(work->conn, hdr)) in ksmbd_smb2_check_message()