138c8a9a5SSteve French // SPDX-License-Identifier: GPL-2.0-or-later 238c8a9a5SSteve French /* 338c8a9a5SSteve French * Copyright (C) 2018 Samsung Electronics Co., Ltd. 438c8a9a5SSteve French * Copyright (C) 2018 Namjae Jeon <linkinjeon@kernel.org> 538c8a9a5SSteve French */ 638c8a9a5SSteve French 738c8a9a5SSteve French #include <linux/user_namespace.h> 838c8a9a5SSteve French 938c8a9a5SSteve French #include "smb_common.h" 1038c8a9a5SSteve French #include "server.h" 1138c8a9a5SSteve French #include "misc.h" 1238c8a9a5SSteve French #include "smbstatus.h" 1338c8a9a5SSteve French #include "connection.h" 1438c8a9a5SSteve French #include "ksmbd_work.h" 1538c8a9a5SSteve French #include "mgmt/user_session.h" 1638c8a9a5SSteve French #include "mgmt/user_config.h" 1738c8a9a5SSteve French #include "mgmt/tree_connect.h" 1838c8a9a5SSteve French #include "mgmt/share_config.h" 1938c8a9a5SSteve French 2038c8a9a5SSteve French /*for shortname implementation */ 2138c8a9a5SSteve French static const char basechars[43] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_-!@#$%"; 2238c8a9a5SSteve French #define MANGLE_BASE (sizeof(basechars) / sizeof(char) - 1) 2338c8a9a5SSteve French #define MAGIC_CHAR '~' 2438c8a9a5SSteve French #define PERIOD '.' 2538c8a9a5SSteve French #define mangle(V) ((char)(basechars[(V) % MANGLE_BASE])) 2638c8a9a5SSteve French 2738c8a9a5SSteve French struct smb_protocol { 2838c8a9a5SSteve French int index; 2938c8a9a5SSteve French char *name; 3038c8a9a5SSteve French char *prot; 3138c8a9a5SSteve French __u16 prot_id; 3238c8a9a5SSteve French }; 3338c8a9a5SSteve French 3438c8a9a5SSteve French static struct smb_protocol smb1_protos[] = { 3538c8a9a5SSteve French { 3638c8a9a5SSteve French SMB21_PROT, 3738c8a9a5SSteve French "\2SMB 2.1", 3838c8a9a5SSteve French "SMB2_10", 3938c8a9a5SSteve French SMB21_PROT_ID 4038c8a9a5SSteve French }, 4138c8a9a5SSteve French { 4238c8a9a5SSteve French SMB2X_PROT, 4338c8a9a5SSteve French "\2SMB 2.???", 4438c8a9a5SSteve French "SMB2_22", 4538c8a9a5SSteve French SMB2X_PROT_ID 4638c8a9a5SSteve French }, 4738c8a9a5SSteve French }; 4838c8a9a5SSteve French 4938c8a9a5SSteve French static struct smb_protocol smb2_protos[] = { 5038c8a9a5SSteve French { 5138c8a9a5SSteve French SMB21_PROT, 5238c8a9a5SSteve French "\2SMB 2.1", 5338c8a9a5SSteve French "SMB2_10", 5438c8a9a5SSteve French SMB21_PROT_ID 5538c8a9a5SSteve French }, 5638c8a9a5SSteve French { 5738c8a9a5SSteve French SMB30_PROT, 5838c8a9a5SSteve French "\2SMB 3.0", 5938c8a9a5SSteve French "SMB3_00", 6038c8a9a5SSteve French SMB30_PROT_ID 6138c8a9a5SSteve French }, 6238c8a9a5SSteve French { 6338c8a9a5SSteve French SMB302_PROT, 6438c8a9a5SSteve French "\2SMB 3.02", 6538c8a9a5SSteve French "SMB3_02", 6638c8a9a5SSteve French SMB302_PROT_ID 6738c8a9a5SSteve French }, 6838c8a9a5SSteve French { 6938c8a9a5SSteve French SMB311_PROT, 7038c8a9a5SSteve French "\2SMB 3.1.1", 7138c8a9a5SSteve French "SMB3_11", 7238c8a9a5SSteve French SMB311_PROT_ID 7338c8a9a5SSteve French }, 7438c8a9a5SSteve French }; 7538c8a9a5SSteve French 7638c8a9a5SSteve French unsigned int ksmbd_server_side_copy_max_chunk_count(void) 7738c8a9a5SSteve French { 7838c8a9a5SSteve French return 256; 7938c8a9a5SSteve French } 8038c8a9a5SSteve French 8138c8a9a5SSteve French unsigned int ksmbd_server_side_copy_max_chunk_size(void) 8238c8a9a5SSteve French { 8338c8a9a5SSteve French return (2U << 30) - 1; 8438c8a9a5SSteve French } 8538c8a9a5SSteve French 8638c8a9a5SSteve French unsigned int ksmbd_server_side_copy_max_total_size(void) 8738c8a9a5SSteve French { 8838c8a9a5SSteve French return (2U << 30) - 1; 8938c8a9a5SSteve French } 9038c8a9a5SSteve French 9138c8a9a5SSteve French inline int ksmbd_min_protocol(void) 9238c8a9a5SSteve French { 9338c8a9a5SSteve French return SMB21_PROT; 9438c8a9a5SSteve French } 9538c8a9a5SSteve French 9638c8a9a5SSteve French inline int ksmbd_max_protocol(void) 9738c8a9a5SSteve French { 9838c8a9a5SSteve French return SMB311_PROT; 9938c8a9a5SSteve French } 10038c8a9a5SSteve French 10138c8a9a5SSteve French int ksmbd_lookup_protocol_idx(char *str) 10238c8a9a5SSteve French { 10338c8a9a5SSteve French int offt = ARRAY_SIZE(smb1_protos) - 1; 10438c8a9a5SSteve French int len = strlen(str); 10538c8a9a5SSteve French 10638c8a9a5SSteve French while (offt >= 0) { 10738c8a9a5SSteve French if (!strncmp(str, smb1_protos[offt].prot, len)) { 10838c8a9a5SSteve French ksmbd_debug(SMB, "selected %s dialect idx = %d\n", 10938c8a9a5SSteve French smb1_protos[offt].prot, offt); 11038c8a9a5SSteve French return smb1_protos[offt].index; 11138c8a9a5SSteve French } 11238c8a9a5SSteve French offt--; 11338c8a9a5SSteve French } 11438c8a9a5SSteve French 11538c8a9a5SSteve French offt = ARRAY_SIZE(smb2_protos) - 1; 11638c8a9a5SSteve French while (offt >= 0) { 11738c8a9a5SSteve French if (!strncmp(str, smb2_protos[offt].prot, len)) { 11838c8a9a5SSteve French ksmbd_debug(SMB, "selected %s dialect idx = %d\n", 11938c8a9a5SSteve French smb2_protos[offt].prot, offt); 12038c8a9a5SSteve French return smb2_protos[offt].index; 12138c8a9a5SSteve French } 12238c8a9a5SSteve French offt--; 12338c8a9a5SSteve French } 12438c8a9a5SSteve French return -1; 12538c8a9a5SSteve French } 12638c8a9a5SSteve French 12738c8a9a5SSteve French /** 12838c8a9a5SSteve French * ksmbd_verify_smb_message() - check for valid smb2 request header 12938c8a9a5SSteve French * @work: smb work 13038c8a9a5SSteve French * 13138c8a9a5SSteve French * check for valid smb signature and packet direction(request/response) 13238c8a9a5SSteve French * 13338c8a9a5SSteve French * Return: 0 on success, otherwise -EINVAL 13438c8a9a5SSteve French */ 13538c8a9a5SSteve French int ksmbd_verify_smb_message(struct ksmbd_work *work) 13638c8a9a5SSteve French { 13738c8a9a5SSteve French struct smb2_hdr *smb2_hdr = ksmbd_req_buf_next(work); 13838c8a9a5SSteve French struct smb_hdr *hdr; 13938c8a9a5SSteve French 14038c8a9a5SSteve French if (smb2_hdr->ProtocolId == SMB2_PROTO_NUMBER) 14138c8a9a5SSteve French return ksmbd_smb2_check_message(work); 14238c8a9a5SSteve French 14338c8a9a5SSteve French hdr = work->request_buf; 14438c8a9a5SSteve French if (*(__le32 *)hdr->Protocol == SMB1_PROTO_NUMBER && 14538c8a9a5SSteve French hdr->Command == SMB_COM_NEGOTIATE) { 14638c8a9a5SSteve French work->conn->outstanding_credits++; 14738c8a9a5SSteve French return 0; 14838c8a9a5SSteve French } 14938c8a9a5SSteve French 15038c8a9a5SSteve French return -EINVAL; 15138c8a9a5SSteve French } 15238c8a9a5SSteve French 15338c8a9a5SSteve French /** 15438c8a9a5SSteve French * ksmbd_smb_request() - check for valid smb request type 15538c8a9a5SSteve French * @conn: connection instance 15638c8a9a5SSteve French * 15738c8a9a5SSteve French * Return: true on success, otherwise false 15838c8a9a5SSteve French */ 15938c8a9a5SSteve French bool ksmbd_smb_request(struct ksmbd_conn *conn) 16038c8a9a5SSteve French { 161acf50ff9SLi Nan __le32 *proto; 1621c1bcf2dSNamjae Jeon 163acf50ff9SLi Nan if (conn->request_buf[0] != 0) 164acf50ff9SLi Nan return false; 165acf50ff9SLi Nan 166acf50ff9SLi Nan proto = (__le32 *)smb2_get_msg(conn->request_buf); 1671c1bcf2dSNamjae Jeon if (*proto == SMB2_COMPRESSION_TRANSFORM_ID) { 1681c1bcf2dSNamjae Jeon pr_err_ratelimited("smb2 compression not support yet"); 1691c1bcf2dSNamjae Jeon return false; 1701c1bcf2dSNamjae Jeon } 1711c1bcf2dSNamjae Jeon 1721c1bcf2dSNamjae Jeon if (*proto != SMB1_PROTO_NUMBER && 1731c1bcf2dSNamjae Jeon *proto != SMB2_PROTO_NUMBER && 1741c1bcf2dSNamjae Jeon *proto != SMB2_TRANSFORM_PROTO_NUM) 1751c1bcf2dSNamjae Jeon return false; 1761c1bcf2dSNamjae Jeon 1771c1bcf2dSNamjae Jeon return true; 17838c8a9a5SSteve French } 17938c8a9a5SSteve French 18038c8a9a5SSteve French static bool supported_protocol(int idx) 18138c8a9a5SSteve French { 18238c8a9a5SSteve French if (idx == SMB2X_PROT && 18338c8a9a5SSteve French (server_conf.min_protocol >= SMB21_PROT || 18438c8a9a5SSteve French server_conf.max_protocol <= SMB311_PROT)) 18538c8a9a5SSteve French return true; 18638c8a9a5SSteve French 18738c8a9a5SSteve French return (server_conf.min_protocol <= idx && 18838c8a9a5SSteve French idx <= server_conf.max_protocol); 18938c8a9a5SSteve French } 19038c8a9a5SSteve French 19138c8a9a5SSteve French static char *next_dialect(char *dialect, int *next_off, int bcount) 19238c8a9a5SSteve French { 19338c8a9a5SSteve French dialect = dialect + *next_off; 19438c8a9a5SSteve French *next_off = strnlen(dialect, bcount); 19538c8a9a5SSteve French if (dialect[*next_off] != '\0') 19638c8a9a5SSteve French return NULL; 19738c8a9a5SSteve French return dialect; 19838c8a9a5SSteve French } 19938c8a9a5SSteve French 20038c8a9a5SSteve French static int ksmbd_lookup_dialect_by_name(char *cli_dialects, __le16 byte_count) 20138c8a9a5SSteve French { 20238c8a9a5SSteve French int i, seq_num, bcount, next; 20338c8a9a5SSteve French char *dialect; 20438c8a9a5SSteve French 20538c8a9a5SSteve French for (i = ARRAY_SIZE(smb1_protos) - 1; i >= 0; i--) { 20638c8a9a5SSteve French seq_num = 0; 20738c8a9a5SSteve French next = 0; 20838c8a9a5SSteve French dialect = cli_dialects; 20938c8a9a5SSteve French bcount = le16_to_cpu(byte_count); 21038c8a9a5SSteve French do { 21138c8a9a5SSteve French dialect = next_dialect(dialect, &next, bcount); 21238c8a9a5SSteve French if (!dialect) 21338c8a9a5SSteve French break; 21438c8a9a5SSteve French ksmbd_debug(SMB, "client requested dialect %s\n", 21538c8a9a5SSteve French dialect); 21638c8a9a5SSteve French if (!strcmp(dialect, smb1_protos[i].name)) { 21738c8a9a5SSteve French if (supported_protocol(smb1_protos[i].index)) { 21838c8a9a5SSteve French ksmbd_debug(SMB, 21938c8a9a5SSteve French "selected %s dialect\n", 22038c8a9a5SSteve French smb1_protos[i].name); 22138c8a9a5SSteve French if (smb1_protos[i].index == SMB1_PROT) 22238c8a9a5SSteve French return seq_num; 22338c8a9a5SSteve French return smb1_protos[i].prot_id; 22438c8a9a5SSteve French } 22538c8a9a5SSteve French } 22638c8a9a5SSteve French seq_num++; 22738c8a9a5SSteve French bcount -= (++next); 22838c8a9a5SSteve French } while (bcount > 0); 22938c8a9a5SSteve French } 23038c8a9a5SSteve French 23138c8a9a5SSteve French return BAD_PROT_ID; 23238c8a9a5SSteve French } 23338c8a9a5SSteve French 23438c8a9a5SSteve French int ksmbd_lookup_dialect_by_id(__le16 *cli_dialects, __le16 dialects_count) 23538c8a9a5SSteve French { 23638c8a9a5SSteve French int i; 23738c8a9a5SSteve French int count; 23838c8a9a5SSteve French 23938c8a9a5SSteve French for (i = ARRAY_SIZE(smb2_protos) - 1; i >= 0; i--) { 24038c8a9a5SSteve French count = le16_to_cpu(dialects_count); 24138c8a9a5SSteve French while (--count >= 0) { 24238c8a9a5SSteve French ksmbd_debug(SMB, "client requested dialect 0x%x\n", 24338c8a9a5SSteve French le16_to_cpu(cli_dialects[count])); 24438c8a9a5SSteve French if (le16_to_cpu(cli_dialects[count]) != 24538c8a9a5SSteve French smb2_protos[i].prot_id) 24638c8a9a5SSteve French continue; 24738c8a9a5SSteve French 24838c8a9a5SSteve French if (supported_protocol(smb2_protos[i].index)) { 24938c8a9a5SSteve French ksmbd_debug(SMB, "selected %s dialect\n", 25038c8a9a5SSteve French smb2_protos[i].name); 25138c8a9a5SSteve French return smb2_protos[i].prot_id; 25238c8a9a5SSteve French } 25338c8a9a5SSteve French } 25438c8a9a5SSteve French } 25538c8a9a5SSteve French 25638c8a9a5SSteve French return BAD_PROT_ID; 25738c8a9a5SSteve French } 25838c8a9a5SSteve French 25938c8a9a5SSteve French static int ksmbd_negotiate_smb_dialect(void *buf) 26038c8a9a5SSteve French { 26138c8a9a5SSteve French int smb_buf_length = get_rfc1002_len(buf); 26238c8a9a5SSteve French __le32 proto = ((struct smb2_hdr *)smb2_get_msg(buf))->ProtocolId; 26338c8a9a5SSteve French 26438c8a9a5SSteve French if (proto == SMB2_PROTO_NUMBER) { 26538c8a9a5SSteve French struct smb2_negotiate_req *req; 26638c8a9a5SSteve French int smb2_neg_size = 26738c8a9a5SSteve French offsetof(struct smb2_negotiate_req, Dialects); 26838c8a9a5SSteve French 26938c8a9a5SSteve French req = (struct smb2_negotiate_req *)smb2_get_msg(buf); 27038c8a9a5SSteve French if (smb2_neg_size > smb_buf_length) 27138c8a9a5SSteve French goto err_out; 27238c8a9a5SSteve French 2735211cc87SGustavo A. R. Silva if (struct_size(req, Dialects, le16_to_cpu(req->DialectCount)) > 27438c8a9a5SSteve French smb_buf_length) 27538c8a9a5SSteve French goto err_out; 27638c8a9a5SSteve French 27738c8a9a5SSteve French return ksmbd_lookup_dialect_by_id(req->Dialects, 27838c8a9a5SSteve French req->DialectCount); 27938c8a9a5SSteve French } 28038c8a9a5SSteve French 28138c8a9a5SSteve French proto = *(__le32 *)((struct smb_hdr *)buf)->Protocol; 28238c8a9a5SSteve French if (proto == SMB1_PROTO_NUMBER) { 28338c8a9a5SSteve French struct smb_negotiate_req *req; 28438c8a9a5SSteve French 28538c8a9a5SSteve French req = (struct smb_negotiate_req *)buf; 28638c8a9a5SSteve French if (le16_to_cpu(req->ByteCount) < 2) 28738c8a9a5SSteve French goto err_out; 28838c8a9a5SSteve French 28938c8a9a5SSteve French if (offsetof(struct smb_negotiate_req, DialectsArray) - 4 + 29038c8a9a5SSteve French le16_to_cpu(req->ByteCount) > smb_buf_length) { 29138c8a9a5SSteve French goto err_out; 29238c8a9a5SSteve French } 29338c8a9a5SSteve French 29438c8a9a5SSteve French return ksmbd_lookup_dialect_by_name(req->DialectsArray, 29538c8a9a5SSteve French req->ByteCount); 29638c8a9a5SSteve French } 29738c8a9a5SSteve French 29838c8a9a5SSteve French err_out: 29938c8a9a5SSteve French return BAD_PROT_ID; 30038c8a9a5SSteve French } 30138c8a9a5SSteve French 30238c8a9a5SSteve French #define SMB_COM_NEGOTIATE_EX 0x0 30338c8a9a5SSteve French 30438c8a9a5SSteve French /** 30538c8a9a5SSteve French * get_smb1_cmd_val() - get smb command value from smb header 30638c8a9a5SSteve French * @work: smb work containing smb header 30738c8a9a5SSteve French * 30838c8a9a5SSteve French * Return: smb command value 30938c8a9a5SSteve French */ 31038c8a9a5SSteve French static u16 get_smb1_cmd_val(struct ksmbd_work *work) 31138c8a9a5SSteve French { 31238c8a9a5SSteve French return SMB_COM_NEGOTIATE_EX; 31338c8a9a5SSteve French } 31438c8a9a5SSteve French 31538c8a9a5SSteve French /** 31638c8a9a5SSteve French * init_smb1_rsp_hdr() - initialize smb negotiate response header 31738c8a9a5SSteve French * @work: smb work containing smb request 31838c8a9a5SSteve French * 31938c8a9a5SSteve French * Return: 0 on success, otherwise -EINVAL 32038c8a9a5SSteve French */ 32138c8a9a5SSteve French static int init_smb1_rsp_hdr(struct ksmbd_work *work) 32238c8a9a5SSteve French { 32338c8a9a5SSteve French struct smb_hdr *rsp_hdr = (struct smb_hdr *)work->response_buf; 32438c8a9a5SSteve French struct smb_hdr *rcv_hdr = (struct smb_hdr *)work->request_buf; 32538c8a9a5SSteve French 32638c8a9a5SSteve French rsp_hdr->Command = SMB_COM_NEGOTIATE; 32738c8a9a5SSteve French *(__le32 *)rsp_hdr->Protocol = SMB1_PROTO_NUMBER; 32838c8a9a5SSteve French rsp_hdr->Flags = SMBFLG_RESPONSE; 32938c8a9a5SSteve French rsp_hdr->Flags2 = SMBFLG2_UNICODE | SMBFLG2_ERR_STATUS | 33038c8a9a5SSteve French SMBFLG2_EXT_SEC | SMBFLG2_IS_LONG_NAME; 33138c8a9a5SSteve French rsp_hdr->Pid = rcv_hdr->Pid; 33238c8a9a5SSteve French rsp_hdr->Mid = rcv_hdr->Mid; 33338c8a9a5SSteve French return 0; 33438c8a9a5SSteve French } 33538c8a9a5SSteve French 33638c8a9a5SSteve French /** 33738c8a9a5SSteve French * smb1_check_user_session() - check for valid session for a user 33838c8a9a5SSteve French * @work: smb work containing smb request buffer 33938c8a9a5SSteve French * 34038c8a9a5SSteve French * Return: 0 on success, otherwise error 34138c8a9a5SSteve French */ 34238c8a9a5SSteve French static int smb1_check_user_session(struct ksmbd_work *work) 34338c8a9a5SSteve French { 34438c8a9a5SSteve French unsigned int cmd = work->conn->ops->get_cmd_val(work); 34538c8a9a5SSteve French 34638c8a9a5SSteve French if (cmd == SMB_COM_NEGOTIATE_EX) 34738c8a9a5SSteve French return 0; 34838c8a9a5SSteve French 34938c8a9a5SSteve French return -EINVAL; 35038c8a9a5SSteve French } 35138c8a9a5SSteve French 35238c8a9a5SSteve French /** 35338c8a9a5SSteve French * smb1_allocate_rsp_buf() - allocate response buffer for a command 35438c8a9a5SSteve French * @work: smb work containing smb request 35538c8a9a5SSteve French * 35638c8a9a5SSteve French * Return: 0 on success, otherwise -ENOMEM 35738c8a9a5SSteve French */ 35838c8a9a5SSteve French static int smb1_allocate_rsp_buf(struct ksmbd_work *work) 35938c8a9a5SSteve French { 360f87d4f85SNamjae Jeon work->response_buf = kzalloc(MAX_CIFS_SMALL_BUFFER_SIZE, 361f87d4f85SNamjae Jeon GFP_KERNEL); 36238c8a9a5SSteve French work->response_sz = MAX_CIFS_SMALL_BUFFER_SIZE; 36338c8a9a5SSteve French 36438c8a9a5SSteve French if (!work->response_buf) { 36538c8a9a5SSteve French pr_err("Failed to allocate %u bytes buffer\n", 36638c8a9a5SSteve French MAX_CIFS_SMALL_BUFFER_SIZE); 36738c8a9a5SSteve French return -ENOMEM; 36838c8a9a5SSteve French } 36938c8a9a5SSteve French 37038c8a9a5SSteve French return 0; 37138c8a9a5SSteve French } 37238c8a9a5SSteve French 373f4f863a0SNamjae Jeon /** 374f4f863a0SNamjae Jeon * set_smb1_rsp_status() - set error type in smb response header 375f4f863a0SNamjae Jeon * @work: smb work containing smb response header 376f4f863a0SNamjae Jeon * @err: error code to set in response 377f4f863a0SNamjae Jeon */ 378f4f863a0SNamjae Jeon static void set_smb1_rsp_status(struct ksmbd_work *work, __le32 err) 379f4f863a0SNamjae Jeon { 380f4f863a0SNamjae Jeon work->send_no_response = 1; 381f4f863a0SNamjae Jeon } 382f4f863a0SNamjae Jeon 38338c8a9a5SSteve French static struct smb_version_ops smb1_server_ops = { 38438c8a9a5SSteve French .get_cmd_val = get_smb1_cmd_val, 38538c8a9a5SSteve French .init_rsp_hdr = init_smb1_rsp_hdr, 38638c8a9a5SSteve French .allocate_rsp_buf = smb1_allocate_rsp_buf, 38738c8a9a5SSteve French .check_user_session = smb1_check_user_session, 388f4f863a0SNamjae Jeon .set_rsp_status = set_smb1_rsp_status, 38938c8a9a5SSteve French }; 39038c8a9a5SSteve French 39138c8a9a5SSteve French static int smb1_negotiate(struct ksmbd_work *work) 39238c8a9a5SSteve French { 39338c8a9a5SSteve French return ksmbd_smb_negotiate_common(work, SMB_COM_NEGOTIATE); 39438c8a9a5SSteve French } 39538c8a9a5SSteve French 39638c8a9a5SSteve French static struct smb_version_cmds smb1_server_cmds[1] = { 39738c8a9a5SSteve French [SMB_COM_NEGOTIATE_EX] = { .proc = smb1_negotiate, }, 39838c8a9a5SSteve French }; 39938c8a9a5SSteve French 400536bb492SNamjae Jeon static int init_smb1_server(struct ksmbd_conn *conn) 40138c8a9a5SSteve French { 40238c8a9a5SSteve French conn->ops = &smb1_server_ops; 40338c8a9a5SSteve French conn->cmds = smb1_server_cmds; 40438c8a9a5SSteve French conn->max_cmds = ARRAY_SIZE(smb1_server_cmds); 405536bb492SNamjae Jeon return 0; 40638c8a9a5SSteve French } 40738c8a9a5SSteve French 408536bb492SNamjae Jeon int ksmbd_init_smb_server(struct ksmbd_work *work) 40938c8a9a5SSteve French { 41038c8a9a5SSteve French struct ksmbd_conn *conn = work->conn; 41138c8a9a5SSteve French __le32 proto; 41238c8a9a5SSteve French 41338c8a9a5SSteve French proto = *(__le32 *)((struct smb_hdr *)work->request_buf)->Protocol; 414536bb492SNamjae Jeon if (conn->need_neg == false) { 41538c8a9a5SSteve French if (proto == SMB1_PROTO_NUMBER) 416536bb492SNamjae Jeon return -EINVAL; 417536bb492SNamjae Jeon return 0; 418536bb492SNamjae Jeon } 419536bb492SNamjae Jeon 420536bb492SNamjae Jeon if (proto == SMB1_PROTO_NUMBER) 421536bb492SNamjae Jeon return init_smb1_server(conn); 422536bb492SNamjae Jeon return init_smb3_11_server(conn); 42338c8a9a5SSteve French } 42438c8a9a5SSteve French 42538c8a9a5SSteve French int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level, 42638c8a9a5SSteve French struct ksmbd_file *dir, 42738c8a9a5SSteve French struct ksmbd_dir_info *d_info, 42838c8a9a5SSteve French char *search_pattern, 42938c8a9a5SSteve French int (*fn)(struct ksmbd_conn *, int, 43038c8a9a5SSteve French struct ksmbd_dir_info *, 43138c8a9a5SSteve French struct ksmbd_kstat *)) 43238c8a9a5SSteve French { 43338c8a9a5SSteve French int i, rc = 0; 43438c8a9a5SSteve French struct ksmbd_conn *conn = work->conn; 43538c8a9a5SSteve French struct mnt_idmap *idmap = file_mnt_idmap(dir->filp); 43638c8a9a5SSteve French 43738c8a9a5SSteve French for (i = 0; i < 2; i++) { 43838c8a9a5SSteve French struct kstat kstat; 43938c8a9a5SSteve French struct ksmbd_kstat ksmbd_kstat; 44038c8a9a5SSteve French struct dentry *dentry; 44138c8a9a5SSteve French 44238c8a9a5SSteve French if (!dir->dot_dotdot[i]) { /* fill dot entry info */ 44338c8a9a5SSteve French if (i == 0) { 44438c8a9a5SSteve French d_info->name = "."; 44538c8a9a5SSteve French d_info->name_len = 1; 44638c8a9a5SSteve French dentry = dir->filp->f_path.dentry; 44738c8a9a5SSteve French } else { 44838c8a9a5SSteve French d_info->name = ".."; 44938c8a9a5SSteve French d_info->name_len = 2; 45038c8a9a5SSteve French dentry = dir->filp->f_path.dentry->d_parent; 45138c8a9a5SSteve French } 45238c8a9a5SSteve French 45338c8a9a5SSteve French if (!match_pattern(d_info->name, d_info->name_len, 45438c8a9a5SSteve French search_pattern)) { 45538c8a9a5SSteve French dir->dot_dotdot[i] = 1; 45638c8a9a5SSteve French continue; 45738c8a9a5SSteve French } 45838c8a9a5SSteve French 45938c8a9a5SSteve French ksmbd_kstat.kstat = &kstat; 460*c8f7ad2dSMarios Makassikis rc = ksmbd_vfs_fill_dentry_attrs(work, 46138c8a9a5SSteve French idmap, 46238c8a9a5SSteve French dentry, 46338c8a9a5SSteve French &ksmbd_kstat); 464*c8f7ad2dSMarios Makassikis if (rc) 465*c8f7ad2dSMarios Makassikis break; 466*c8f7ad2dSMarios Makassikis 46738c8a9a5SSteve French rc = fn(conn, info_level, d_info, &ksmbd_kstat); 46838c8a9a5SSteve French if (rc) 46938c8a9a5SSteve French break; 47038c8a9a5SSteve French if (d_info->out_buf_len <= 0) 47138c8a9a5SSteve French break; 47238c8a9a5SSteve French 47338c8a9a5SSteve French dir->dot_dotdot[i] = 1; 47438c8a9a5SSteve French if (d_info->flags & SMB2_RETURN_SINGLE_ENTRY) { 47538c8a9a5SSteve French d_info->out_buf_len = 0; 47638c8a9a5SSteve French break; 47738c8a9a5SSteve French } 47838c8a9a5SSteve French } 47938c8a9a5SSteve French } 48038c8a9a5SSteve French 48138c8a9a5SSteve French return rc; 48238c8a9a5SSteve French } 48338c8a9a5SSteve French 48438c8a9a5SSteve French /** 48538c8a9a5SSteve French * ksmbd_extract_shortname() - get shortname from long filename 48638c8a9a5SSteve French * @conn: connection instance 48738c8a9a5SSteve French * @longname: source long filename 48838c8a9a5SSteve French * @shortname: destination short filename 48938c8a9a5SSteve French * 49038c8a9a5SSteve French * Return: shortname length or 0 when source long name is '.' or '..' 49138c8a9a5SSteve French * TODO: Though this function comforms the restriction of 8.3 Filename spec, 49238c8a9a5SSteve French * but the result is different with Windows 7's one. need to check. 49338c8a9a5SSteve French */ 49438c8a9a5SSteve French int ksmbd_extract_shortname(struct ksmbd_conn *conn, const char *longname, 49538c8a9a5SSteve French char *shortname) 49638c8a9a5SSteve French { 49738c8a9a5SSteve French const char *p; 49838c8a9a5SSteve French char base[9], extension[4]; 49938c8a9a5SSteve French char out[13] = {0}; 50038c8a9a5SSteve French int baselen = 0; 50138c8a9a5SSteve French int extlen = 0, len = 0; 50238c8a9a5SSteve French unsigned int csum = 0; 50338c8a9a5SSteve French const unsigned char *ptr; 50438c8a9a5SSteve French bool dot_present = true; 50538c8a9a5SSteve French 50638c8a9a5SSteve French p = longname; 50738c8a9a5SSteve French if ((*p == '.') || (!(strcmp(p, "..")))) { 50838c8a9a5SSteve French /*no mangling required */ 50938c8a9a5SSteve French return 0; 51038c8a9a5SSteve French } 51138c8a9a5SSteve French 51238c8a9a5SSteve French p = strrchr(longname, '.'); 51338c8a9a5SSteve French if (p == longname) { /*name starts with a dot*/ 51438c8a9a5SSteve French strscpy(extension, "___", strlen("___")); 51538c8a9a5SSteve French } else { 51638c8a9a5SSteve French if (p) { 51738c8a9a5SSteve French p++; 51838c8a9a5SSteve French while (*p && extlen < 3) { 51938c8a9a5SSteve French if (*p != '.') 52038c8a9a5SSteve French extension[extlen++] = toupper(*p); 52138c8a9a5SSteve French p++; 52238c8a9a5SSteve French } 52338c8a9a5SSteve French extension[extlen] = '\0'; 52438c8a9a5SSteve French } else { 52538c8a9a5SSteve French dot_present = false; 52638c8a9a5SSteve French } 52738c8a9a5SSteve French } 52838c8a9a5SSteve French 52938c8a9a5SSteve French p = longname; 53038c8a9a5SSteve French if (*p == '.') { 53138c8a9a5SSteve French p++; 53238c8a9a5SSteve French longname++; 53338c8a9a5SSteve French } 53438c8a9a5SSteve French while (*p && (baselen < 5)) { 53538c8a9a5SSteve French if (*p != '.') 53638c8a9a5SSteve French base[baselen++] = toupper(*p); 53738c8a9a5SSteve French p++; 53838c8a9a5SSteve French } 53938c8a9a5SSteve French 54038c8a9a5SSteve French base[baselen] = MAGIC_CHAR; 54138c8a9a5SSteve French memcpy(out, base, baselen + 1); 54238c8a9a5SSteve French 54338c8a9a5SSteve French ptr = longname; 54438c8a9a5SSteve French len = strlen(longname); 54538c8a9a5SSteve French for (; len > 0; len--, ptr++) 54638c8a9a5SSteve French csum += *ptr; 54738c8a9a5SSteve French 54838c8a9a5SSteve French csum = csum % (MANGLE_BASE * MANGLE_BASE); 54938c8a9a5SSteve French out[baselen + 1] = mangle(csum / MANGLE_BASE); 55038c8a9a5SSteve French out[baselen + 2] = mangle(csum); 55138c8a9a5SSteve French out[baselen + 3] = PERIOD; 55238c8a9a5SSteve French 55338c8a9a5SSteve French if (dot_present) 5549cedc58bSArnd Bergmann memcpy(out + baselen + 4, extension, 4); 55538c8a9a5SSteve French else 55638c8a9a5SSteve French out[baselen + 4] = '\0'; 55738c8a9a5SSteve French smbConvertToUTF16((__le16 *)shortname, out, PATH_MAX, 55838c8a9a5SSteve French conn->local_nls, 0); 55938c8a9a5SSteve French len = strlen(out) * 2; 56038c8a9a5SSteve French return len; 56138c8a9a5SSteve French } 56238c8a9a5SSteve French 56338c8a9a5SSteve French static int __smb2_negotiate(struct ksmbd_conn *conn) 56438c8a9a5SSteve French { 56538c8a9a5SSteve French return (conn->dialect >= SMB20_PROT_ID && 56638c8a9a5SSteve French conn->dialect <= SMB311_PROT_ID); 56738c8a9a5SSteve French } 56838c8a9a5SSteve French 56938c8a9a5SSteve French static int smb_handle_negotiate(struct ksmbd_work *work) 57038c8a9a5SSteve French { 57138c8a9a5SSteve French struct smb_negotiate_rsp *neg_rsp = work->response_buf; 57238c8a9a5SSteve French 57338c8a9a5SSteve French ksmbd_debug(SMB, "Unsupported SMB1 protocol\n"); 57438c8a9a5SSteve French 575e2b76ab8SNamjae Jeon if (ksmbd_iov_pin_rsp(work, (void *)neg_rsp, 576e2b76ab8SNamjae Jeon sizeof(struct smb_negotiate_rsp) - 4)) 577e2b76ab8SNamjae Jeon return -ENOMEM; 57838c8a9a5SSteve French 579e2b76ab8SNamjae Jeon neg_rsp->hdr.Status.CifsError = STATUS_SUCCESS; 58038c8a9a5SSteve French neg_rsp->hdr.WordCount = 1; 58138c8a9a5SSteve French neg_rsp->DialectIndex = cpu_to_le16(work->conn->dialect); 58238c8a9a5SSteve French neg_rsp->ByteCount = 0; 58338c8a9a5SSteve French return 0; 58438c8a9a5SSteve French } 58538c8a9a5SSteve French 58638c8a9a5SSteve French int ksmbd_smb_negotiate_common(struct ksmbd_work *work, unsigned int command) 58738c8a9a5SSteve French { 58838c8a9a5SSteve French struct ksmbd_conn *conn = work->conn; 58938c8a9a5SSteve French int ret; 59038c8a9a5SSteve French 59138c8a9a5SSteve French conn->dialect = 59238c8a9a5SSteve French ksmbd_negotiate_smb_dialect(work->request_buf); 59338c8a9a5SSteve French ksmbd_debug(SMB, "conn->dialect 0x%x\n", conn->dialect); 59438c8a9a5SSteve French 59538c8a9a5SSteve French if (command == SMB2_NEGOTIATE_HE) { 59638c8a9a5SSteve French ret = smb2_handle_negotiate(work); 59738c8a9a5SSteve French return ret; 59838c8a9a5SSteve French } 59938c8a9a5SSteve French 60038c8a9a5SSteve French if (command == SMB_COM_NEGOTIATE) { 60138c8a9a5SSteve French if (__smb2_negotiate(conn)) { 60238c8a9a5SSteve French init_smb3_11_server(conn); 60338c8a9a5SSteve French init_smb2_neg_rsp(work); 60438c8a9a5SSteve French ksmbd_debug(SMB, "Upgrade to SMB2 negotiation\n"); 60538c8a9a5SSteve French return 0; 60638c8a9a5SSteve French } 60738c8a9a5SSteve French return smb_handle_negotiate(work); 60838c8a9a5SSteve French } 60938c8a9a5SSteve French 61038c8a9a5SSteve French pr_err("Unknown SMB negotiation command: %u\n", command); 61138c8a9a5SSteve French return -EINVAL; 61238c8a9a5SSteve French } 61338c8a9a5SSteve French 61438c8a9a5SSteve French enum SHARED_MODE_ERRORS { 61538c8a9a5SSteve French SHARE_DELETE_ERROR, 61638c8a9a5SSteve French SHARE_READ_ERROR, 61738c8a9a5SSteve French SHARE_WRITE_ERROR, 61838c8a9a5SSteve French FILE_READ_ERROR, 61938c8a9a5SSteve French FILE_WRITE_ERROR, 62038c8a9a5SSteve French FILE_DELETE_ERROR, 62138c8a9a5SSteve French }; 62238c8a9a5SSteve French 62338c8a9a5SSteve French static const char * const shared_mode_errors[] = { 62438c8a9a5SSteve French "Current access mode does not permit SHARE_DELETE", 62538c8a9a5SSteve French "Current access mode does not permit SHARE_READ", 62638c8a9a5SSteve French "Current access mode does not permit SHARE_WRITE", 62738c8a9a5SSteve French "Desired access mode does not permit FILE_READ", 62838c8a9a5SSteve French "Desired access mode does not permit FILE_WRITE", 62938c8a9a5SSteve French "Desired access mode does not permit FILE_DELETE", 63038c8a9a5SSteve French }; 63138c8a9a5SSteve French 63238c8a9a5SSteve French static void smb_shared_mode_error(int error, struct ksmbd_file *prev_fp, 63338c8a9a5SSteve French struct ksmbd_file *curr_fp) 63438c8a9a5SSteve French { 63538c8a9a5SSteve French ksmbd_debug(SMB, "%s\n", shared_mode_errors[error]); 63638c8a9a5SSteve French ksmbd_debug(SMB, "Current mode: 0x%x Desired mode: 0x%x\n", 63738c8a9a5SSteve French prev_fp->saccess, curr_fp->daccess); 63838c8a9a5SSteve French } 63938c8a9a5SSteve French 64038c8a9a5SSteve French int ksmbd_smb_check_shared_mode(struct file *filp, struct ksmbd_file *curr_fp) 64138c8a9a5SSteve French { 64238c8a9a5SSteve French int rc = 0; 64338c8a9a5SSteve French struct ksmbd_file *prev_fp; 64438c8a9a5SSteve French 64538c8a9a5SSteve French /* 64638c8a9a5SSteve French * Lookup fp in master fp list, and check desired access and 64738c8a9a5SSteve French * shared mode between previous open and current open. 64838c8a9a5SSteve French */ 64938c8a9a5SSteve French read_lock(&curr_fp->f_ci->m_lock); 65038c8a9a5SSteve French list_for_each_entry(prev_fp, &curr_fp->f_ci->m_fp_list, node) { 65138c8a9a5SSteve French if (file_inode(filp) != file_inode(prev_fp->filp)) 65238c8a9a5SSteve French continue; 65338c8a9a5SSteve French 65438c8a9a5SSteve French if (filp == prev_fp->filp) 65538c8a9a5SSteve French continue; 65638c8a9a5SSteve French 65738c8a9a5SSteve French if (ksmbd_stream_fd(prev_fp) && ksmbd_stream_fd(curr_fp)) 65838c8a9a5SSteve French if (strcmp(prev_fp->stream.name, curr_fp->stream.name)) 65938c8a9a5SSteve French continue; 66038c8a9a5SSteve French 66138c8a9a5SSteve French if (prev_fp->attrib_only != curr_fp->attrib_only) 66238c8a9a5SSteve French continue; 66338c8a9a5SSteve French 66438c8a9a5SSteve French if (!(prev_fp->saccess & FILE_SHARE_DELETE_LE) && 66538c8a9a5SSteve French curr_fp->daccess & FILE_DELETE_LE) { 66638c8a9a5SSteve French smb_shared_mode_error(SHARE_DELETE_ERROR, 66738c8a9a5SSteve French prev_fp, 66838c8a9a5SSteve French curr_fp); 66938c8a9a5SSteve French rc = -EPERM; 67038c8a9a5SSteve French break; 67138c8a9a5SSteve French } 67238c8a9a5SSteve French 67338c8a9a5SSteve French /* 67438c8a9a5SSteve French * Only check FILE_SHARE_DELETE if stream opened and 67538c8a9a5SSteve French * normal file opened. 67638c8a9a5SSteve French */ 67738c8a9a5SSteve French if (ksmbd_stream_fd(prev_fp) && !ksmbd_stream_fd(curr_fp)) 67838c8a9a5SSteve French continue; 67938c8a9a5SSteve French 68038c8a9a5SSteve French if (!(prev_fp->saccess & FILE_SHARE_READ_LE) && 68138c8a9a5SSteve French curr_fp->daccess & (FILE_EXECUTE_LE | FILE_READ_DATA_LE)) { 68238c8a9a5SSteve French smb_shared_mode_error(SHARE_READ_ERROR, 68338c8a9a5SSteve French prev_fp, 68438c8a9a5SSteve French curr_fp); 68538c8a9a5SSteve French rc = -EPERM; 68638c8a9a5SSteve French break; 68738c8a9a5SSteve French } 68838c8a9a5SSteve French 68938c8a9a5SSteve French if (!(prev_fp->saccess & FILE_SHARE_WRITE_LE) && 69038c8a9a5SSteve French curr_fp->daccess & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE)) { 69138c8a9a5SSteve French smb_shared_mode_error(SHARE_WRITE_ERROR, 69238c8a9a5SSteve French prev_fp, 69338c8a9a5SSteve French curr_fp); 69438c8a9a5SSteve French rc = -EPERM; 69538c8a9a5SSteve French break; 69638c8a9a5SSteve French } 69738c8a9a5SSteve French 69838c8a9a5SSteve French if (prev_fp->daccess & (FILE_EXECUTE_LE | FILE_READ_DATA_LE) && 69938c8a9a5SSteve French !(curr_fp->saccess & FILE_SHARE_READ_LE)) { 70038c8a9a5SSteve French smb_shared_mode_error(FILE_READ_ERROR, 70138c8a9a5SSteve French prev_fp, 70238c8a9a5SSteve French curr_fp); 70338c8a9a5SSteve French rc = -EPERM; 70438c8a9a5SSteve French break; 70538c8a9a5SSteve French } 70638c8a9a5SSteve French 70738c8a9a5SSteve French if (prev_fp->daccess & (FILE_WRITE_DATA_LE | FILE_APPEND_DATA_LE) && 70838c8a9a5SSteve French !(curr_fp->saccess & FILE_SHARE_WRITE_LE)) { 70938c8a9a5SSteve French smb_shared_mode_error(FILE_WRITE_ERROR, 71038c8a9a5SSteve French prev_fp, 71138c8a9a5SSteve French curr_fp); 71238c8a9a5SSteve French rc = -EPERM; 71338c8a9a5SSteve French break; 71438c8a9a5SSteve French } 71538c8a9a5SSteve French 71638c8a9a5SSteve French if (prev_fp->daccess & FILE_DELETE_LE && 71738c8a9a5SSteve French !(curr_fp->saccess & FILE_SHARE_DELETE_LE)) { 71838c8a9a5SSteve French smb_shared_mode_error(FILE_DELETE_ERROR, 71938c8a9a5SSteve French prev_fp, 72038c8a9a5SSteve French curr_fp); 72138c8a9a5SSteve French rc = -EPERM; 72238c8a9a5SSteve French break; 72338c8a9a5SSteve French } 72438c8a9a5SSteve French } 72538c8a9a5SSteve French read_unlock(&curr_fp->f_ci->m_lock); 72638c8a9a5SSteve French 72738c8a9a5SSteve French return rc; 72838c8a9a5SSteve French } 72938c8a9a5SSteve French 73038c8a9a5SSteve French bool is_asterisk(char *p) 73138c8a9a5SSteve French { 73238c8a9a5SSteve French return p && p[0] == '*'; 73338c8a9a5SSteve French } 73438c8a9a5SSteve French 73538c8a9a5SSteve French int ksmbd_override_fsids(struct ksmbd_work *work) 73638c8a9a5SSteve French { 73738c8a9a5SSteve French struct ksmbd_session *sess = work->sess; 73838c8a9a5SSteve French struct ksmbd_share_config *share = work->tcon->share_conf; 73938c8a9a5SSteve French struct cred *cred; 74038c8a9a5SSteve French struct group_info *gi; 74138c8a9a5SSteve French unsigned int uid; 74238c8a9a5SSteve French unsigned int gid; 74338c8a9a5SSteve French 74438c8a9a5SSteve French uid = user_uid(sess->user); 74538c8a9a5SSteve French gid = user_gid(sess->user); 74638c8a9a5SSteve French if (share->force_uid != KSMBD_SHARE_INVALID_UID) 74738c8a9a5SSteve French uid = share->force_uid; 74838c8a9a5SSteve French if (share->force_gid != KSMBD_SHARE_INVALID_GID) 74938c8a9a5SSteve French gid = share->force_gid; 75038c8a9a5SSteve French 75138c8a9a5SSteve French cred = prepare_kernel_cred(&init_task); 75238c8a9a5SSteve French if (!cred) 75338c8a9a5SSteve French return -ENOMEM; 75438c8a9a5SSteve French 75538c8a9a5SSteve French cred->fsuid = make_kuid(&init_user_ns, uid); 75638c8a9a5SSteve French cred->fsgid = make_kgid(&init_user_ns, gid); 75738c8a9a5SSteve French 75838c8a9a5SSteve French gi = groups_alloc(0); 75938c8a9a5SSteve French if (!gi) { 76038c8a9a5SSteve French abort_creds(cred); 76138c8a9a5SSteve French return -ENOMEM; 76238c8a9a5SSteve French } 76338c8a9a5SSteve French set_groups(cred, gi); 76438c8a9a5SSteve French put_group_info(gi); 76538c8a9a5SSteve French 76638c8a9a5SSteve French if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID)) 76738c8a9a5SSteve French cred->cap_effective = cap_drop_fs_set(cred->cap_effective); 76838c8a9a5SSteve French 76938c8a9a5SSteve French WARN_ON(work->saved_cred); 77038c8a9a5SSteve French work->saved_cred = override_creds(cred); 77138c8a9a5SSteve French if (!work->saved_cred) { 77238c8a9a5SSteve French abort_creds(cred); 77338c8a9a5SSteve French return -EINVAL; 77438c8a9a5SSteve French } 77538c8a9a5SSteve French return 0; 77638c8a9a5SSteve French } 77738c8a9a5SSteve French 77838c8a9a5SSteve French void ksmbd_revert_fsids(struct ksmbd_work *work) 77938c8a9a5SSteve French { 78038c8a9a5SSteve French const struct cred *cred; 78138c8a9a5SSteve French 78238c8a9a5SSteve French WARN_ON(!work->saved_cred); 78338c8a9a5SSteve French 78438c8a9a5SSteve French cred = current_cred(); 78538c8a9a5SSteve French revert_creds(work->saved_cred); 78638c8a9a5SSteve French put_cred(cred); 78738c8a9a5SSteve French work->saved_cred = NULL; 78838c8a9a5SSteve French } 78938c8a9a5SSteve French 79038c8a9a5SSteve French __le32 smb_map_generic_desired_access(__le32 daccess) 79138c8a9a5SSteve French { 79238c8a9a5SSteve French if (daccess & FILE_GENERIC_READ_LE) { 79338c8a9a5SSteve French daccess |= cpu_to_le32(GENERIC_READ_FLAGS); 79438c8a9a5SSteve French daccess &= ~FILE_GENERIC_READ_LE; 79538c8a9a5SSteve French } 79638c8a9a5SSteve French 79738c8a9a5SSteve French if (daccess & FILE_GENERIC_WRITE_LE) { 79838c8a9a5SSteve French daccess |= cpu_to_le32(GENERIC_WRITE_FLAGS); 79938c8a9a5SSteve French daccess &= ~FILE_GENERIC_WRITE_LE; 80038c8a9a5SSteve French } 80138c8a9a5SSteve French 80238c8a9a5SSteve French if (daccess & FILE_GENERIC_EXECUTE_LE) { 80338c8a9a5SSteve French daccess |= cpu_to_le32(GENERIC_EXECUTE_FLAGS); 80438c8a9a5SSteve French daccess &= ~FILE_GENERIC_EXECUTE_LE; 80538c8a9a5SSteve French } 80638c8a9a5SSteve French 80738c8a9a5SSteve French if (daccess & FILE_GENERIC_ALL_LE) { 80838c8a9a5SSteve French daccess |= cpu_to_le32(GENERIC_ALL_FLAGS); 80938c8a9a5SSteve French daccess &= ~FILE_GENERIC_ALL_LE; 81038c8a9a5SSteve French } 81138c8a9a5SSteve French 81238c8a9a5SSteve French return daccess; 81338c8a9a5SSteve French } 814