mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:44:45 +01:00
74 client changesets
-----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEE6fsu8pdIjtWE/DpLiiy9cAdyT1EFAmmKKuoACgkQiiy9cAdy T1HIhgv/V9CALNuGPS397O2Ys5R1ozYEkdPn47ZsgsLhr7YXdILWzeyDLxUvJp0R 7DWzOTnFPTTBitG89KPH9r/Vlotx8cFipPq4jo6jjtpt9pCThBkAiPLaA4GYkf6Q E07CPhOBsjSSrVdhuKmZwQAQub7/a4WQvgoGF0W1tsDWjZPN0/edyi/1AA1eMkXO qq9xMJ+9qGl+6o+ohQjG0Xi8gq9Ui0Hj9nS2/JTiPbY6QuUQjU55nPlNOMD10e3N WdY8PjD/q6MlZIlJ2SZ9Zq/f/Oni3YtvbbHact2qh8Jd5KgLXesf4LDBMvmM1AVb TSdqzuGzuOpDpnNXwNj47Rdru0jd6Y2Vz7mxLMg7eK3W4Ehxo2AF9DcCmPBhx36z u3T3TM5ZWClpjCR4FcPDY9frnvS+qwoLMj3wtJyKw72u9mGejfR+N/2OWzljBs2e QFv8N+vMUlzOB7Egp/9CG73vI9egw/ag2PA91l2u/YGafZQrqSso5zptKozNbmLL OStEEnn9 =tdRC -----END PGP SIGNATURE----- Merge tag 'v7.0-rc-part1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6 Pull smb client updates from Steve French: - multichannel improvements, including making add channel async at mount time - fix potential double free in open path - retry fixes - locking improvements - fix potential directory lease races - cleanup patches for client headers - patches to better split out SMB1 code - minor cleanup of structs for gcc 14 warnings - error handling improvements * tag 'v7.0-rc-part1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6: (74 commits) cifs: Fix the copyright banner on smb1maperror.c smb: common: add header guards to fs/smb/common/smb2status.h smb: client: Avoid a dozen -Wflex-array-member-not-at-end warnings smb/client: remove useless comment in mapping_table_ERRSRV smb/client: remove some literal NT error codes from ntstatus_to_dos_map smb/client: add NT_STATUS_VOLUME_NOT_UPGRADED smb/client: add NT_STATUS_NO_USER_KEYS smb/client: add NT_STATUS_WRONG_EFS smb/client: add NT_STATUS_NO_EFS smb/client: add NT_STATUS_NO_RECOVERY_POLICY smb/client: add NT_STATUS_RANGE_NOT_FOUND smb/client: add NT_STATUS_DECRYPTION_FAILED smb/client: add NT_STATUS_ENCRYPTION_FAILED smb/client: add NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT smb/client: add NT_STATUS_VOLUME_DISMOUNTED smb/client: add NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT smb/client: add NT_STATUS_VARIABLE_NOT_FOUND smb/client: rename ERRinvlevel to ERRunknownlevel smb/client: add NT_STATUS_OS2_INVALID_LEVEL smb/client: map NT_STATUS_INVALID_INFO_CLASS to ERRbadpipe ...
This commit is contained in:
commit
8a5203c630
71 changed files with 8643 additions and 10499 deletions
|
|
@ -546,6 +546,15 @@ void netfs_read_subreq_terminated(struct netfs_io_subrequest *subreq)
|
|||
}
|
||||
}
|
||||
|
||||
/* If need retry is set, error should not matter unless we hit too many
|
||||
* retries. Pause the generation of new subreqs
|
||||
*/
|
||||
if (test_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags)) {
|
||||
trace_netfs_rreq(rreq, netfs_rreq_trace_set_pause);
|
||||
set_bit(NETFS_RREQ_PAUSE, &rreq->flags);
|
||||
goto skip_error_checks;
|
||||
}
|
||||
|
||||
if (unlikely(subreq->error < 0)) {
|
||||
trace_netfs_failure(rreq, subreq, subreq->error, netfs_fail_read);
|
||||
if (subreq->source == NETFS_READ_FROM_CACHE) {
|
||||
|
|
@ -559,6 +568,7 @@ void netfs_read_subreq_terminated(struct netfs_io_subrequest *subreq)
|
|||
set_bit(NETFS_RREQ_PAUSE, &rreq->flags);
|
||||
}
|
||||
|
||||
skip_error_checks:
|
||||
trace_netfs_sreq(subreq, netfs_sreq_trace_terminated);
|
||||
netfs_subreq_clear_in_progress(subreq);
|
||||
netfs_put_subrequest(subreq, netfs_sreq_trace_put_terminated);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
static void netfs_reissue_read(struct netfs_io_request *rreq,
|
||||
struct netfs_io_subrequest *subreq)
|
||||
{
|
||||
subreq->error = 0;
|
||||
__clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags);
|
||||
__set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags);
|
||||
netfs_stat(&netfs_n_rh_retry_read_subreq);
|
||||
|
|
@ -242,8 +243,7 @@ abandon_after:
|
|||
subreq = list_next_entry(subreq, rreq_link);
|
||||
abandon:
|
||||
list_for_each_entry_from(subreq, &stream->subrequests, rreq_link) {
|
||||
if (!subreq->error &&
|
||||
!test_bit(NETFS_SREQ_FAILED, &subreq->flags) &&
|
||||
if (!test_bit(NETFS_SREQ_FAILED, &subreq->flags) &&
|
||||
!test_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags))
|
||||
continue;
|
||||
subreq->error = -ENOMEM;
|
||||
|
|
|
|||
|
|
@ -492,11 +492,11 @@ void netfs_write_subrequest_terminated(void *_op, ssize_t transferred_or_error)
|
|||
|
||||
if (IS_ERR_VALUE(transferred_or_error)) {
|
||||
subreq->error = transferred_or_error;
|
||||
if (subreq->error == -EAGAIN)
|
||||
set_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags);
|
||||
else
|
||||
/* if need retry is set, error should not matter */
|
||||
if (!test_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags)) {
|
||||
set_bit(NETFS_SREQ_FAILED, &subreq->flags);
|
||||
trace_netfs_failure(wreq, subreq, transferred_or_error, netfs_fail_write);
|
||||
trace_netfs_failure(wreq, subreq, transferred_or_error, netfs_fail_write);
|
||||
}
|
||||
|
||||
switch (subreq->source) {
|
||||
case NETFS_WRITE_TO_CACHE:
|
||||
|
|
|
|||
|
|
@ -250,6 +250,7 @@ void netfs_reissue_write(struct netfs_io_stream *stream,
|
|||
iov_iter_truncate(&subreq->io_iter, size);
|
||||
|
||||
subreq->retry_count++;
|
||||
subreq->error = 0;
|
||||
__clear_bit(NETFS_SREQ_MADE_PROGRESS, &subreq->flags);
|
||||
__set_bit(NETFS_SREQ_IN_PROGRESS, &subreq->flags);
|
||||
netfs_stat(&netfs_n_wh_retry_write_subreq);
|
||||
|
|
|
|||
|
|
@ -98,7 +98,6 @@ static void netfs_retry_write_stream(struct netfs_io_request *wreq,
|
|||
subreq->start = start;
|
||||
subreq->len = len;
|
||||
__clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags);
|
||||
subreq->retry_count++;
|
||||
trace_netfs_sreq(subreq, netfs_sreq_trace_retry);
|
||||
|
||||
/* Renegotiate max_len (wsize) */
|
||||
|
|
|
|||
|
|
@ -9,3 +9,20 @@ config SMBFS
|
|||
tristate
|
||||
default y if CIFS=y || SMB_SERVER=y
|
||||
default m if CIFS=m || SMB_SERVER=m
|
||||
|
||||
config SMB_KUNIT_TESTS
|
||||
tristate "KUnit tests for SMB" if !KUNIT_ALL_TESTS
|
||||
depends on SMBFS && KUNIT
|
||||
default KUNIT_ALL_TESTS
|
||||
help
|
||||
This builds the SMB KUnit tests.
|
||||
|
||||
KUnit tests run during boot and output the results to the debug log
|
||||
in TAP format (https://testanything.org/). Only useful for kernel devs
|
||||
running KUnit test harness and are not for inclusion into a production
|
||||
build.
|
||||
|
||||
For more information on KUnit and unit tests in general please refer
|
||||
to the KUnit documentation in Documentation/dev-tools/kunit/.
|
||||
|
||||
If unsure, say N.
|
||||
|
|
|
|||
|
|
@ -32,6 +32,28 @@ cifs-$(CONFIG_CIFS_SMB_DIRECT) += smbdirect.o
|
|||
|
||||
cifs-$(CONFIG_CIFS_ROOT) += cifsroot.o
|
||||
|
||||
cifs-$(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) += smb1ops.o cifssmb.o cifstransport.o
|
||||
cifs-$(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) += \
|
||||
cifssmb.o \
|
||||
smb1debug.o \
|
||||
smb1encrypt.o \
|
||||
smb1maperror.o \
|
||||
smb1misc.o \
|
||||
smb1ops.o \
|
||||
smb1session.o \
|
||||
smb1transport.o
|
||||
|
||||
cifs-$(CONFIG_CIFS_COMPRESSION) += compress.o compress/lz77.o
|
||||
|
||||
#
|
||||
# Build the SMB2 error mapping table from smb2status.h
|
||||
#
|
||||
$(obj)/smb2_mapping_table.c: $(src)/../common/smb2status.h \
|
||||
$(src)/gen_smb2_mapping
|
||||
$(call cmd,gen_smb2_mapping)
|
||||
|
||||
$(obj)/smb2maperror.o: $(obj)/smb2_mapping_table.c
|
||||
|
||||
quiet_cmd_gen_smb2_mapping = GEN $@
|
||||
cmd_gen_smb2_mapping = perl $(src)/gen_smb2_mapping $< $@
|
||||
|
||||
clean-files += smb2_mapping_table.c
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
|
|||
struct cached_fid *cfid;
|
||||
struct cached_fids *cfids;
|
||||
const char *npath;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
__le32 lease_flags = 0;
|
||||
|
||||
if (cifs_sb->root == NULL)
|
||||
|
|
@ -304,6 +304,10 @@ replay_again:
|
|||
smb2_set_related(&rqst[1]);
|
||||
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
|
||||
smb2_set_replay(server, &rqst[0]);
|
||||
smb2_set_replay(server, &rqst[1]);
|
||||
}
|
||||
|
|
@ -788,11 +792,11 @@ static void cfids_laundromat_worker(struct work_struct *work)
|
|||
cfid->dentry = NULL;
|
||||
|
||||
if (cfid->is_open) {
|
||||
spin_lock(&cifs_tcp_ses_lock);
|
||||
spin_lock(&cfid->tcon->tc_lock);
|
||||
++cfid->tcon->tc_count;
|
||||
trace_smb3_tcon_ref(cfid->tcon->debug_id, cfid->tcon->tc_count,
|
||||
netfs_trace_tcon_ref_get_cached_laundromat);
|
||||
spin_unlock(&cifs_tcp_ses_lock);
|
||||
spin_unlock(&cfid->tcon->tc_lock);
|
||||
queue_work(serverclose_wq, &cfid->close_work);
|
||||
} else
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ struct cached_fid {
|
|||
struct list_head entry;
|
||||
struct cached_fids *cfids;
|
||||
const char *path;
|
||||
bool has_lease:1;
|
||||
bool is_open:1;
|
||||
bool on_list:1;
|
||||
bool file_all_info_is_valid:1;
|
||||
bool has_lease;
|
||||
bool is_open;
|
||||
bool on_list;
|
||||
bool file_all_info_is_valid;
|
||||
unsigned long time; /* jiffies of when lease was taken */
|
||||
unsigned long last_access_time; /* jiffies of when last accessed */
|
||||
struct kref refcount;
|
||||
|
|
@ -48,8 +48,10 @@ struct cached_fid {
|
|||
struct dentry *dentry;
|
||||
struct work_struct put_work;
|
||||
struct work_struct close_work;
|
||||
struct smb2_file_all_info file_all_info;
|
||||
struct cached_dirents dirents;
|
||||
|
||||
/* Must be last as it ends in a flexible-array member. */
|
||||
struct smb2_file_all_info file_all_info;
|
||||
};
|
||||
|
||||
/* default MAX_CACHED_FIDS is 16 */
|
||||
|
|
@ -77,22 +79,18 @@ is_valid_cached_dir(struct cached_fid *cfid)
|
|||
return cfid->time && cfid->has_lease;
|
||||
}
|
||||
|
||||
extern struct cached_fids *init_cached_dirs(void);
|
||||
extern void free_cached_dirs(struct cached_fids *cfids);
|
||||
extern int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *path,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
bool lookup_only, struct cached_fid **cfid);
|
||||
extern int open_cached_dir_by_dentry(struct cifs_tcon *tcon,
|
||||
struct dentry *dentry,
|
||||
struct cached_fid **cfid);
|
||||
extern void close_cached_dir(struct cached_fid *cfid);
|
||||
extern void drop_cached_dir_by_name(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
const char *name,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
extern void close_all_cached_dirs(struct cifs_sb_info *cifs_sb);
|
||||
extern void invalidate_all_cached_dirs(struct cifs_tcon *tcon);
|
||||
extern bool cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16]);
|
||||
struct cached_fids *init_cached_dirs(void);
|
||||
void free_cached_dirs(struct cached_fids *cfids);
|
||||
int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, const char *path,
|
||||
struct cifs_sb_info *cifs_sb, bool lookup_only,
|
||||
struct cached_fid **ret_cfid);
|
||||
int open_cached_dir_by_dentry(struct cifs_tcon *tcon, struct dentry *dentry,
|
||||
struct cached_fid **ret_cfid);
|
||||
void close_cached_dir(struct cached_fid *cfid);
|
||||
void drop_cached_dir_by_name(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *name, struct cifs_sb_info *cifs_sb);
|
||||
void close_all_cached_dirs(struct cifs_sb_info *cifs_sb);
|
||||
void invalidate_all_cached_dirs(struct cifs_tcon *tcon);
|
||||
bool cached_dir_lease_break(struct cifs_tcon *tcon, __u8 lease_key[16]);
|
||||
|
||||
#endif /* _CACHED_DIR_H */
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
#include <linux/proc_fs.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <uapi/linux/ethtool.h>
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_debug.h"
|
||||
|
|
@ -37,21 +36,6 @@ cifs_dump_mem(char *label, void *data, int length)
|
|||
data, length, true);
|
||||
}
|
||||
|
||||
void cifs_dump_detail(void *buf, size_t buf_len, struct TCP_Server_Info *server)
|
||||
{
|
||||
#ifdef CONFIG_CIFS_DEBUG2
|
||||
struct smb_hdr *smb = buf;
|
||||
|
||||
cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d Wct: %d\n",
|
||||
smb->Command, smb->Status.CifsError, smb->Flags,
|
||||
smb->Flags2, smb->Mid, smb->Pid, smb->WordCount);
|
||||
if (!server->ops->check_message(buf, buf_len, server->total_read, server)) {
|
||||
cifs_dbg(VFS, "smb buf %p len %u\n", smb,
|
||||
server->ops->calc_smb_size(smb));
|
||||
}
|
||||
#endif /* CONFIG_CIFS_DEBUG2 */
|
||||
}
|
||||
|
||||
void cifs_dump_mids(struct TCP_Server_Info *server)
|
||||
{
|
||||
#ifdef CONFIG_CIFS_DEBUG2
|
||||
|
|
@ -79,7 +63,7 @@ void cifs_dump_mids(struct TCP_Server_Info *server)
|
|||
cifs_dbg(VFS, "IsMult: %d IsEnd: %d\n",
|
||||
mid_entry->multiRsp, mid_entry->multiEnd);
|
||||
if (mid_entry->resp_buf) {
|
||||
cifs_dump_detail(mid_entry->resp_buf,
|
||||
server->ops->dump_detail(mid_entry->resp_buf,
|
||||
mid_entry->response_pdu_len, server);
|
||||
cifs_dump_mem("existing buf: ", mid_entry->resp_buf, 62);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
#define pr_fmt(fmt) "CIFS: " fmt
|
||||
|
||||
void cifs_dump_mem(char *label, void *data, int length);
|
||||
void cifs_dump_detail(void *buf, size_t buf_len, struct TCP_Server_Info *server);
|
||||
void cifs_dump_mids(struct TCP_Server_Info *server);
|
||||
extern bool traceSMB; /* flag which enables the function below */
|
||||
void dump_smb(void *buf, int smb_buf_length);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ struct cifs_spnego_msg {
|
|||
};
|
||||
|
||||
extern struct key_type cifs_spnego_key_type;
|
||||
extern struct key *cifs_get_spnego_key(struct cifs_ses *sesInfo,
|
||||
struct TCP_Server_Info *server);
|
||||
struct key *cifs_get_spnego_key(struct cifs_ses *sesInfo,
|
||||
struct TCP_Server_Info *server);
|
||||
|
||||
#endif /* _CIFS_SPNEGO_H */
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ struct sk_buff;
|
|||
struct genl_info;
|
||||
|
||||
#ifdef CONFIG_CIFS_SWN_UPCALL
|
||||
extern int cifs_swn_register(struct cifs_tcon *tcon);
|
||||
int cifs_swn_register(struct cifs_tcon *tcon);
|
||||
|
||||
extern int cifs_swn_unregister(struct cifs_tcon *tcon);
|
||||
int cifs_swn_unregister(struct cifs_tcon *tcon);
|
||||
|
||||
extern int cifs_swn_notify(struct sk_buff *skb, struct genl_info *info);
|
||||
int cifs_swn_notify(struct sk_buff *skb, struct genl_info *info);
|
||||
|
||||
extern void cifs_swn_dump(struct seq_file *m);
|
||||
void cifs_swn_dump(struct seq_file *m);
|
||||
|
||||
extern void cifs_swn_check(void);
|
||||
void cifs_swn_check(void);
|
||||
|
||||
static inline bool cifs_swn_set_server_dstaddr(struct TCP_Server_Info *server)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
#include <linux/slab.h>
|
||||
#include "cifs_fs_sb.h"
|
||||
#include "cifs_unicode.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifs_debug.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -55,19 +55,20 @@
|
|||
#define SFU_MAP_UNI_RSVD 2
|
||||
|
||||
int cifs_from_utf16(char *to, const __le16 *from, int tolen, int fromlen,
|
||||
const struct nls_table *cp, int map_type);
|
||||
const struct nls_table *codepage, int map_type);
|
||||
int cifs_utf16_bytes(const __le16 *from, int maxbytes,
|
||||
const struct nls_table *codepage);
|
||||
int cifs_strtoUTF16(__le16 *, const char *, int, const struct nls_table *);
|
||||
int cifs_strtoUTF16(__le16 *to, const char *from, int len,
|
||||
const struct nls_table *codepage);
|
||||
char *cifs_strndup_from_utf16(const char *src, const int maxlen,
|
||||
const bool is_unicode,
|
||||
const struct nls_table *codepage);
|
||||
extern int cifsConvertToUTF16(__le16 *target, const char *source, int maxlen,
|
||||
const struct nls_table *cp, int mapChars);
|
||||
extern int cifs_remap(struct cifs_sb_info *cifs_sb);
|
||||
extern __le16 *cifs_strndup_to_utf16(const char *src, const int maxlen,
|
||||
int *utf16_len, const struct nls_table *cp,
|
||||
int remap);
|
||||
int cifsConvertToUTF16(__le16 *target, const char *source, int srclen,
|
||||
const struct nls_table *cp, int map_chars);
|
||||
int cifs_remap(struct cifs_sb_info *cifs_sb);
|
||||
__le16 *cifs_strndup_to_utf16(const char *src, const int maxlen,
|
||||
int *utf16_len, const struct nls_table *cp,
|
||||
int remap);
|
||||
wchar_t cifs_toupper(wchar_t in);
|
||||
|
||||
#endif /* _CIFS_UNICODE_H */
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
#include <linux/posix_acl.h>
|
||||
#include <linux/posix_acl_xattr.h>
|
||||
#include <keys/user-type.h>
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsacl.h"
|
||||
#include "cifsproto.h"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/slab.h>
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifs_debug.h"
|
||||
#include "cifs_unicode.h"
|
||||
|
|
@ -116,129 +115,6 @@ int __cifs_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
|
|||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate and return the CIFS signature based on the mac key and SMB PDU.
|
||||
* The 16 byte signature must be allocated by the caller. Note we only use the
|
||||
* 1st eight bytes and that the smb header signature field on input contains
|
||||
* the sequence number before this function is called. Also, this function
|
||||
* should be called with the server->srv_mutex held.
|
||||
*/
|
||||
static int cifs_calc_signature(struct smb_rqst *rqst,
|
||||
struct TCP_Server_Info *server, char *signature)
|
||||
{
|
||||
struct md5_ctx ctx;
|
||||
|
||||
if (!rqst->rq_iov || !signature || !server)
|
||||
return -EINVAL;
|
||||
if (fips_enabled) {
|
||||
cifs_dbg(VFS,
|
||||
"MD5 signature support is disabled due to FIPS\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
md5_init(&ctx);
|
||||
md5_update(&ctx, server->session_key.response, server->session_key.len);
|
||||
|
||||
return __cifs_calc_signature(
|
||||
rqst, server, signature,
|
||||
&(struct cifs_calc_sig_ctx){ .md5 = &ctx });
|
||||
}
|
||||
|
||||
/* must be called with server->srv_mutex held */
|
||||
int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
|
||||
__u32 *pexpected_response_sequence_number)
|
||||
{
|
||||
int rc = 0;
|
||||
char smb_signature[20];
|
||||
struct smb_hdr *cifs_pdu = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
|
||||
|
||||
if ((cifs_pdu == NULL) || (server == NULL))
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock(&server->srv_lock);
|
||||
if (!(cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) ||
|
||||
server->tcpStatus == CifsNeedNegotiate) {
|
||||
spin_unlock(&server->srv_lock);
|
||||
return rc;
|
||||
}
|
||||
spin_unlock(&server->srv_lock);
|
||||
|
||||
if (!server->session_estab) {
|
||||
memcpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
|
||||
return rc;
|
||||
}
|
||||
|
||||
cifs_pdu->Signature.Sequence.SequenceNumber =
|
||||
cpu_to_le32(server->sequence_number);
|
||||
cifs_pdu->Signature.Sequence.Reserved = 0;
|
||||
|
||||
*pexpected_response_sequence_number = ++server->sequence_number;
|
||||
++server->sequence_number;
|
||||
|
||||
rc = cifs_calc_signature(rqst, server, smb_signature);
|
||||
if (rc)
|
||||
memset(cifs_pdu->Signature.SecuritySignature, 0, 8);
|
||||
else
|
||||
memcpy(cifs_pdu->Signature.SecuritySignature, smb_signature, 8);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int cifs_verify_signature(struct smb_rqst *rqst,
|
||||
struct TCP_Server_Info *server,
|
||||
__u32 expected_sequence_number)
|
||||
{
|
||||
unsigned int rc;
|
||||
char server_response_sig[8];
|
||||
char what_we_think_sig_should_be[20];
|
||||
struct smb_hdr *cifs_pdu = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
|
||||
|
||||
if (cifs_pdu == NULL || server == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
if (!server->session_estab)
|
||||
return 0;
|
||||
|
||||
if (cifs_pdu->Command == SMB_COM_LOCKING_ANDX) {
|
||||
struct smb_com_lock_req *pSMB =
|
||||
(struct smb_com_lock_req *)cifs_pdu;
|
||||
if (pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* BB what if signatures are supposed to be on for session but
|
||||
server does not send one? BB */
|
||||
|
||||
/* Do not need to verify session setups with signature "BSRSPYL " */
|
||||
if (memcmp(cifs_pdu->Signature.SecuritySignature, "BSRSPYL ", 8) == 0)
|
||||
cifs_dbg(FYI, "dummy signature received for smb command 0x%x\n",
|
||||
cifs_pdu->Command);
|
||||
|
||||
/* save off the original signature so we can modify the smb and check
|
||||
its signature against what the server sent */
|
||||
memcpy(server_response_sig, cifs_pdu->Signature.SecuritySignature, 8);
|
||||
|
||||
cifs_pdu->Signature.Sequence.SequenceNumber =
|
||||
cpu_to_le32(expected_sequence_number);
|
||||
cifs_pdu->Signature.Sequence.Reserved = 0;
|
||||
|
||||
cifs_server_lock(server);
|
||||
rc = cifs_calc_signature(rqst, server, what_we_think_sig_should_be);
|
||||
cifs_server_unlock(server);
|
||||
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
/* cifs_dump_mem("what we think it should be: ",
|
||||
what_we_think_sig_should_be, 16); */
|
||||
|
||||
if (memcmp(server_response_sig, what_we_think_sig_should_be, 8))
|
||||
return -EACCES;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/* Build a proper attribute value/target info pairs blob.
|
||||
* Fill in netbios and dns domain name and workstation name
|
||||
* and client time (total five av pairs and + one end of fields indicator.
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
#include <uapi/linux/magic.h>
|
||||
#include <net/ipv6.h>
|
||||
#include "cifsfs.h"
|
||||
#include "cifspdu.h"
|
||||
#define DECLARE_GLOBALS_HERE
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
|
|
@ -1904,6 +1903,11 @@ static int __init
|
|||
init_cifs(void)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
rc = smb2_init_maperror();
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
cifs_proc_init();
|
||||
INIT_LIST_HEAD(&cifs_tcp_ses_list);
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -43,40 +43,41 @@ extern const struct address_space_operations cifs_addr_ops;
|
|||
extern const struct address_space_operations cifs_addr_ops_smallbuf;
|
||||
|
||||
/* Functions related to super block operations */
|
||||
extern void cifs_sb_active(struct super_block *sb);
|
||||
extern void cifs_sb_deactive(struct super_block *sb);
|
||||
void cifs_sb_active(struct super_block *sb);
|
||||
void cifs_sb_deactive(struct super_block *sb);
|
||||
|
||||
/* Functions related to inodes */
|
||||
extern const struct inode_operations cifs_dir_inode_ops;
|
||||
extern struct inode *cifs_root_iget(struct super_block *);
|
||||
extern int cifs_create(struct mnt_idmap *, struct inode *,
|
||||
struct dentry *, umode_t, bool excl);
|
||||
extern int cifs_atomic_open(struct inode *, struct dentry *,
|
||||
struct file *, unsigned, umode_t);
|
||||
extern struct dentry *cifs_lookup(struct inode *, struct dentry *,
|
||||
unsigned int);
|
||||
extern int cifs_unlink(struct inode *dir, struct dentry *dentry);
|
||||
extern int cifs_hardlink(struct dentry *, struct inode *, struct dentry *);
|
||||
extern int cifs_mknod(struct mnt_idmap *, struct inode *, struct dentry *,
|
||||
umode_t, dev_t);
|
||||
extern struct dentry *cifs_mkdir(struct mnt_idmap *, struct inode *, struct dentry *,
|
||||
umode_t);
|
||||
extern int cifs_rmdir(struct inode *, struct dentry *);
|
||||
extern int cifs_rename2(struct mnt_idmap *, struct inode *,
|
||||
struct dentry *, struct inode *, struct dentry *,
|
||||
unsigned int);
|
||||
extern int cifs_revalidate_file_attr(struct file *filp);
|
||||
extern int cifs_revalidate_dentry_attr(struct dentry *);
|
||||
extern int cifs_revalidate_file(struct file *filp);
|
||||
extern int cifs_revalidate_dentry(struct dentry *);
|
||||
extern int cifs_revalidate_mapping(struct inode *inode);
|
||||
extern int cifs_zap_mapping(struct inode *inode);
|
||||
extern int cifs_getattr(struct mnt_idmap *, const struct path *,
|
||||
struct kstat *, u32, unsigned int);
|
||||
extern int cifs_setattr(struct mnt_idmap *, struct dentry *,
|
||||
struct iattr *);
|
||||
extern int cifs_fiemap(struct inode *, struct fiemap_extent_info *, u64 start,
|
||||
u64 len);
|
||||
struct inode *cifs_root_iget(struct super_block *sb);
|
||||
int cifs_create(struct mnt_idmap *idmap, struct inode *inode,
|
||||
struct dentry *direntry, umode_t mode, bool excl);
|
||||
int cifs_atomic_open(struct inode *inode, struct dentry *direntry,
|
||||
struct file *file, unsigned int oflags, umode_t mode);
|
||||
struct dentry *cifs_lookup(struct inode *parent_dir_inode,
|
||||
struct dentry *direntry, unsigned int flags);
|
||||
int cifs_unlink(struct inode *dir, struct dentry *dentry);
|
||||
int cifs_hardlink(struct dentry *old_file, struct inode *inode,
|
||||
struct dentry *direntry);
|
||||
int cifs_mknod(struct mnt_idmap *idmap, struct inode *inode,
|
||||
struct dentry *direntry, umode_t mode, dev_t device_number);
|
||||
struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
|
||||
struct dentry *direntry, umode_t mode);
|
||||
int cifs_rmdir(struct inode *inode, struct dentry *direntry);
|
||||
int cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
|
||||
struct dentry *source_dentry, struct inode *target_dir,
|
||||
struct dentry *target_dentry, unsigned int flags);
|
||||
int cifs_revalidate_file_attr(struct file *filp);
|
||||
int cifs_revalidate_dentry_attr(struct dentry *dentry);
|
||||
int cifs_revalidate_file(struct file *filp);
|
||||
int cifs_revalidate_dentry(struct dentry *dentry);
|
||||
int cifs_revalidate_mapping(struct inode *inode);
|
||||
int cifs_zap_mapping(struct inode *inode);
|
||||
int cifs_getattr(struct mnt_idmap *idmap, const struct path *path,
|
||||
struct kstat *stat, u32 request_mask, unsigned int flags);
|
||||
int cifs_setattr(struct mnt_idmap *idmap, struct dentry *direntry,
|
||||
struct iattr *attrs);
|
||||
int cifs_fiemap(struct inode *inode, struct fiemap_extent_info *fei, u64 start,
|
||||
u64 len);
|
||||
|
||||
extern const struct inode_operations cifs_file_inode_ops;
|
||||
extern const struct inode_operations cifs_symlink_inode_ops;
|
||||
|
|
@ -91,54 +92,55 @@ extern const struct file_operations cifs_file_strict_ops; /* if strictio mnt */
|
|||
extern const struct file_operations cifs_file_nobrl_ops; /* no brlocks */
|
||||
extern const struct file_operations cifs_file_direct_nobrl_ops;
|
||||
extern const struct file_operations cifs_file_strict_nobrl_ops;
|
||||
extern int cifs_open(struct inode *inode, struct file *file);
|
||||
extern int cifs_close(struct inode *inode, struct file *file);
|
||||
extern int cifs_closedir(struct inode *inode, struct file *file);
|
||||
extern ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to);
|
||||
extern ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from);
|
||||
int cifs_open(struct inode *inode, struct file *file);
|
||||
int cifs_close(struct inode *inode, struct file *file);
|
||||
int cifs_closedir(struct inode *inode, struct file *file);
|
||||
ssize_t cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to);
|
||||
ssize_t cifs_strict_writev(struct kiocb *iocb, struct iov_iter *from);
|
||||
ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from);
|
||||
ssize_t cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter);
|
||||
extern int cifs_flock(struct file *pfile, int cmd, struct file_lock *plock);
|
||||
extern int cifs_lock(struct file *, int, struct file_lock *);
|
||||
extern int cifs_fsync(struct file *, loff_t, loff_t, int);
|
||||
extern int cifs_strict_fsync(struct file *, loff_t, loff_t, int);
|
||||
extern int cifs_flush(struct file *, fl_owner_t id);
|
||||
int cifs_flock(struct file *file, int cmd, struct file_lock *fl);
|
||||
int cifs_lock(struct file *file, int cmd, struct file_lock *flock);
|
||||
int cifs_fsync(struct file *file, loff_t start, loff_t end, int datasync);
|
||||
int cifs_strict_fsync(struct file *file, loff_t start, loff_t end,
|
||||
int datasync);
|
||||
int cifs_flush(struct file *file, fl_owner_t id);
|
||||
int cifs_file_mmap_prepare(struct vm_area_desc *desc);
|
||||
int cifs_file_strict_mmap_prepare(struct vm_area_desc *desc);
|
||||
extern const struct file_operations cifs_dir_ops;
|
||||
extern int cifs_readdir(struct file *file, struct dir_context *ctx);
|
||||
int cifs_readdir(struct file *file, struct dir_context *ctx);
|
||||
|
||||
/* Functions related to dir entries */
|
||||
extern const struct dentry_operations cifs_dentry_ops;
|
||||
extern const struct dentry_operations cifs_ci_dentry_ops;
|
||||
|
||||
extern struct vfsmount *cifs_d_automount(struct path *path);
|
||||
struct vfsmount *cifs_d_automount(struct path *path);
|
||||
|
||||
/* Functions related to symlinks */
|
||||
extern const char *cifs_get_link(struct dentry *, struct inode *,
|
||||
struct delayed_call *);
|
||||
extern int cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
|
||||
struct dentry *direntry, const char *symname);
|
||||
const char *cifs_get_link(struct dentry *dentry, struct inode *inode,
|
||||
struct delayed_call *done);
|
||||
int cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
|
||||
struct dentry *direntry, const char *symname);
|
||||
|
||||
#ifdef CONFIG_CIFS_XATTR
|
||||
extern const struct xattr_handler * const cifs_xattr_handlers[];
|
||||
extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
|
||||
ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size);
|
||||
#else
|
||||
# define cifs_xattr_handlers NULL
|
||||
# define cifs_listxattr NULL
|
||||
#endif
|
||||
|
||||
extern ssize_t cifs_file_copychunk_range(unsigned int xid,
|
||||
struct file *src_file, loff_t off,
|
||||
struct file *dst_file, loff_t destoff,
|
||||
size_t len, unsigned int flags);
|
||||
ssize_t cifs_file_copychunk_range(unsigned int xid, struct file *src_file,
|
||||
loff_t off, struct file *dst_file,
|
||||
loff_t destoff, size_t len,
|
||||
unsigned int flags);
|
||||
|
||||
extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg);
|
||||
extern void cifs_setsize(struct inode *inode, loff_t offset);
|
||||
long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg);
|
||||
void cifs_setsize(struct inode *inode, loff_t offset);
|
||||
|
||||
struct smb3_fs_context;
|
||||
extern struct dentry *cifs_smb3_do_mount(struct file_system_type *fs_type,
|
||||
int flags, struct smb3_fs_context *ctx);
|
||||
struct dentry *cifs_smb3_do_mount(struct file_system_type *fs_type, int flags,
|
||||
struct smb3_fs_context *old_ctx);
|
||||
|
||||
#ifdef CONFIG_CIFS_NFSD_EXPORT
|
||||
extern const struct export_operations cifs_export_ops;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "../common/smb2pdu.h"
|
||||
#include "../common/fscc.h"
|
||||
#include "smb2pdu.h"
|
||||
#include "smb1pdu.h"
|
||||
#include <linux/filelock.h>
|
||||
|
||||
#define SMB_PATH_MAX 260
|
||||
|
|
@ -103,8 +104,6 @@
|
|||
*/
|
||||
#define SMB2_MAX_CREDITS_AVAILABLE 32000
|
||||
|
||||
#include "cifspdu.h"
|
||||
|
||||
#ifndef XATTR_DOS_ATTRIB
|
||||
#define XATTR_DOS_ATTRIB "user.DOSATTRIB"
|
||||
#endif
|
||||
|
|
@ -950,18 +949,6 @@ revert_current_mid_from_hdr(struct TCP_Server_Info *server,
|
|||
return revert_current_mid(server, num > 0 ? num : 1);
|
||||
}
|
||||
|
||||
static inline __u16
|
||||
get_mid(const struct smb_hdr *smb)
|
||||
{
|
||||
return le16_to_cpu(smb->Mid);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
compare_mid(__u16 mid, const struct smb_hdr *smb)
|
||||
{
|
||||
return mid == le16_to_cpu(smb->Mid);
|
||||
}
|
||||
|
||||
/*
|
||||
* When the server supports very large reads and writes via POSIX extensions,
|
||||
* we can allow up to 2^24-1, minus the size of a READ/WRITE_AND_X header, not
|
||||
|
|
@ -1327,8 +1314,8 @@ struct tcon_link {
|
|||
struct cifs_tcon *tl_tcon;
|
||||
};
|
||||
|
||||
extern struct tcon_link *cifs_sb_tlink(struct cifs_sb_info *cifs_sb);
|
||||
extern void smb3_free_compound_rqst(int num_rqst, struct smb_rqst *rqst);
|
||||
struct tcon_link *cifs_sb_tlink(struct cifs_sb_info *cifs_sb);
|
||||
void smb3_free_compound_rqst(int num_rqst, struct smb_rqst *rqst);
|
||||
|
||||
static inline struct cifs_tcon *
|
||||
tlink_tcon(struct tcon_link *tlink)
|
||||
|
|
@ -1342,7 +1329,7 @@ cifs_sb_master_tlink(struct cifs_sb_info *cifs_sb)
|
|||
return cifs_sb->master_tlink;
|
||||
}
|
||||
|
||||
extern void cifs_put_tlink(struct tcon_link *tlink);
|
||||
void cifs_put_tlink(struct tcon_link *tlink);
|
||||
|
||||
static inline struct tcon_link *
|
||||
cifs_get_tlink(struct tcon_link *tlink)
|
||||
|
|
@ -1353,7 +1340,7 @@ cifs_get_tlink(struct tcon_link *tlink)
|
|||
}
|
||||
|
||||
/* This function is always expected to succeed */
|
||||
extern struct cifs_tcon *cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb);
|
||||
struct cifs_tcon *cifs_sb_master_tcon(struct cifs_sb_info *cifs_sb);
|
||||
|
||||
#define CIFS_OPLOCK_NO_CHANGE 0xfe
|
||||
|
||||
|
|
@ -1507,6 +1494,8 @@ struct cifs_io_subrequest {
|
|||
int result;
|
||||
bool have_xid;
|
||||
bool replay;
|
||||
unsigned int retries; /* number of retries so far */
|
||||
unsigned int cur_sleep; /* time to sleep before replay */
|
||||
struct kvec iov[2];
|
||||
struct TCP_Server_Info *server;
|
||||
#ifdef CONFIG_CIFS_SMB_DIRECT
|
||||
|
|
@ -1526,8 +1515,8 @@ cifsFileInfo_get_locked(struct cifsFileInfo *cifs_file)
|
|||
}
|
||||
|
||||
struct cifsFileInfo *cifsFileInfo_get(struct cifsFileInfo *cifs_file);
|
||||
void _cifsFileInfo_put(struct cifsFileInfo *cifs_file, bool wait_oplock_hdlr,
|
||||
bool offload);
|
||||
void _cifsFileInfo_put(struct cifsFileInfo *cifs_file,
|
||||
bool wait_oplock_handler, bool offload);
|
||||
void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
|
||||
int cifs_file_flush(const unsigned int xid, struct inode *inode,
|
||||
struct cifsFileInfo *cfile);
|
||||
|
|
@ -1796,6 +1785,11 @@ struct cifs_mount_ctx {
|
|||
struct cifs_tcon *tcon;
|
||||
};
|
||||
|
||||
struct mchan_mount {
|
||||
struct work_struct work;
|
||||
struct cifs_ses *ses;
|
||||
};
|
||||
|
||||
static inline void __free_dfs_info_param(struct dfs_info3_param *param)
|
||||
{
|
||||
kfree(param->path_name);
|
||||
|
|
@ -1943,6 +1937,8 @@ require use of the stronger protocol */
|
|||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* LOCK ORDERING NOTES:
|
||||
****************************************************************************
|
||||
* Here are all the locks (spinlock, mutex, semaphore) in cifs.ko, arranged according
|
||||
* to the locking order. i.e. if two locks are to be held together, the lock that
|
||||
* appears higher in this list needs to be taken before the other.
|
||||
|
|
@ -1971,18 +1967,21 @@ require use of the stronger protocol */
|
|||
* =====================================================================================
|
||||
* Lock Protects Initialization fn
|
||||
* =====================================================================================
|
||||
* cifs_mount_mutex mount/unmount operations
|
||||
* vol_list_lock
|
||||
* vol_info->ctx_lock vol_info->ctx
|
||||
* cifs_sb_info->tlink_tree_lock cifs_sb_info->tlink_tree cifs_setup_cifs_sb
|
||||
* TCP_Server_Info-> TCP_Server_Info cifs_get_tcp_session
|
||||
* reconnect_mutex
|
||||
* TCP_Server_Info->srv_mutex TCP_Server_Info cifs_get_tcp_session
|
||||
* cifs_ses->session_mutex cifs_ses sesInfoAlloc
|
||||
* TCP_Server_Info->srv_mutex TCP_Server_Info cifs_get_tcp_session
|
||||
* cifs_tcp_ses_lock cifs_tcp_ses_list sesInfoAlloc
|
||||
* cifs_tcon->open_file_lock cifs_tcon->openFileList tconInfoAlloc
|
||||
* cifs_tcon->pending_opens
|
||||
* cifs_tcon->stat_lock cifs_tcon->bytes_read tconInfoAlloc
|
||||
* cifs_tcon->bytes_written
|
||||
* cifs_tcp_ses_lock cifs_tcp_ses_list sesInfoAlloc
|
||||
* cifs_tcon->fscache_lock cifs_tcon->fscache tconInfoAlloc
|
||||
* cifs_tcon->sb_list_lock cifs_tcon->cifs_sb_list tconInfoAlloc
|
||||
* GlobalMid_Lock GlobalMaxActiveXid init_cifs
|
||||
* GlobalCurrentXid
|
||||
* GlobalTotalActiveXid
|
||||
|
|
@ -2005,6 +2004,8 @@ require use of the stronger protocol */
|
|||
* ->chans_in_reconnect
|
||||
* cifs_tcon->tc_lock (anything that is not protected by another lock and can change)
|
||||
* tcon_info_alloc
|
||||
* cifs_swnreg_idr_mutex cifs_swnreg_idr cifs_swn.c
|
||||
* (witness service registration, accesses tcon fields under tc_lock)
|
||||
* inode->i_rwsem, taken by fs/netfs/locking.c e.g. should be taken before cifsInodeInfo locks
|
||||
* cifsInodeInfo->open_file_lock cifsInodeInfo->openFileList cifs_alloc_inode
|
||||
* cifsInodeInfo->writers_lock cifsInodeInfo->writers cifsInodeInfo_alloc
|
||||
|
|
@ -2012,12 +2013,12 @@ require use of the stronger protocol */
|
|||
* ->can_cache_brlcks
|
||||
* cifsInodeInfo->deferred_lock cifsInodeInfo->deferred_closes cifsInodeInfo_alloc
|
||||
* cached_fids->cfid_list_lock cifs_tcon->cfids->entries init_cached_dirs
|
||||
* cached_fid->fid_lock (anything that is not protected by another lock and can change)
|
||||
* init_cached_dir
|
||||
* cached_fid->dirents.de_mutex cached_fid->dirents alloc_cached_dir
|
||||
* cifsFileInfo->fh_mutex cifsFileInfo cifs_new_fileinfo
|
||||
* cifsFileInfo->file_info_lock cifsFileInfo->count cifs_new_fileinfo
|
||||
* ->invalidHandle initiate_cifs_search
|
||||
* ->oplock_break_cancelled
|
||||
* smbdirect_mr->mutex RDMA memory region management (SMBDirect only)
|
||||
* mid_q_entry->mid_lock mid_q_entry->callback alloc_mid
|
||||
* smb2_mid_entry_alloc
|
||||
* (Any fields of mid_q_entry that will need protection)
|
||||
|
|
@ -2115,8 +2116,6 @@ extern mempool_t cifs_io_subrequest_pool;
|
|||
|
||||
/* Operations for different SMB versions */
|
||||
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
|
||||
extern struct smb_version_operations smb1_operations;
|
||||
extern struct smb_version_values smb1_values;
|
||||
extern struct smb_version_operations smb20_operations;
|
||||
extern struct smb_version_values smb20_values;
|
||||
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -14,6 +14,7 @@
|
|||
#ifdef CONFIG_CIFS_DFS_UPCALL
|
||||
#include "dfs_cache.h"
|
||||
#endif
|
||||
#include "smb1proto.h"
|
||||
|
||||
struct statfs;
|
||||
struct smb_rqst;
|
||||
|
|
@ -25,16 +26,15 @@ struct smb3_fs_context;
|
|||
*****************************************************************
|
||||
*/
|
||||
|
||||
extern struct smb_hdr *cifs_buf_get(void);
|
||||
extern void cifs_buf_release(void *);
|
||||
extern struct smb_hdr *cifs_small_buf_get(void);
|
||||
extern void cifs_small_buf_release(void *);
|
||||
extern void free_rsp_buf(int, void *);
|
||||
extern int smb_send_kvec(struct TCP_Server_Info *server,
|
||||
struct msghdr *msg,
|
||||
size_t *sent);
|
||||
extern unsigned int _get_xid(void);
|
||||
extern void _free_xid(unsigned int);
|
||||
void *cifs_buf_get(void);
|
||||
void cifs_buf_release(void *buf_to_free);
|
||||
void *cifs_small_buf_get(void);
|
||||
void cifs_small_buf_release(void *buf_to_free);
|
||||
void free_rsp_buf(int resp_buftype, void *rsp);
|
||||
int smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg,
|
||||
size_t *sent);
|
||||
unsigned int _get_xid(void);
|
||||
void _free_xid(unsigned int xid);
|
||||
#define get_xid() \
|
||||
({ \
|
||||
unsigned int __xid = _get_xid(); \
|
||||
|
|
@ -55,16 +55,16 @@ do { \
|
|||
else \
|
||||
trace_smb3_exit_done(curr_xid, __func__); \
|
||||
} while (0)
|
||||
extern int init_cifs_idmap(void);
|
||||
extern void exit_cifs_idmap(void);
|
||||
extern int init_cifs_spnego(void);
|
||||
extern void exit_cifs_spnego(void);
|
||||
extern const char *build_path_from_dentry(struct dentry *, void *);
|
||||
char *__build_path_from_dentry_optional_prefix(struct dentry *direntry, void *page,
|
||||
const char *tree, int tree_len,
|
||||
bool prefix);
|
||||
extern char *build_path_from_dentry_optional_prefix(struct dentry *direntry,
|
||||
void *page, bool prefix);
|
||||
int init_cifs_idmap(void);
|
||||
void exit_cifs_idmap(void);
|
||||
int init_cifs_spnego(void);
|
||||
void exit_cifs_spnego(void);
|
||||
const char *build_path_from_dentry(struct dentry *direntry, void *page);
|
||||
char *__build_path_from_dentry_optional_prefix(struct dentry *direntry,
|
||||
void *page, const char *tree,
|
||||
int tree_len, bool prefix);
|
||||
char *build_path_from_dentry_optional_prefix(struct dentry *direntry,
|
||||
void *page, bool prefix);
|
||||
static inline void *alloc_dentry_path(void)
|
||||
{
|
||||
return __getname();
|
||||
|
|
@ -76,57 +76,43 @@ static inline void free_dentry_path(void *page)
|
|||
__putname(page);
|
||||
}
|
||||
|
||||
extern char *cifs_build_path_to_root(struct smb3_fs_context *ctx,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
struct cifs_tcon *tcon,
|
||||
int add_treename);
|
||||
char *cifs_build_path_to_root(struct smb3_fs_context *ctx,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
struct cifs_tcon *tcon, int add_treename);
|
||||
char *cifs_build_devname(char *nodename, const char *prepath);
|
||||
void delete_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid);
|
||||
void __release_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid);
|
||||
void cifs_wake_up_task(struct TCP_Server_Info *server, struct mid_q_entry *mid);
|
||||
extern int cifs_handle_standard(struct TCP_Server_Info *server,
|
||||
struct mid_q_entry *mid);
|
||||
extern char *smb3_fs_context_fullpath(const struct smb3_fs_context *ctx,
|
||||
char dirsep);
|
||||
extern int smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx);
|
||||
extern int smb3_parse_opt(const char *options, const char *key, char **val);
|
||||
extern int cifs_ipaddr_cmp(struct sockaddr *srcaddr, struct sockaddr *rhs);
|
||||
extern bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs);
|
||||
extern int cifs_discard_remaining_data(struct TCP_Server_Info *server);
|
||||
extern int cifs_call_async(struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst,
|
||||
mid_receive_t receive, mid_callback_t callback,
|
||||
mid_handle_t handle, void *cbdata, const int flags,
|
||||
const struct cifs_credits *exist_credits);
|
||||
extern struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses);
|
||||
extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst, int *resp_buf_type,
|
||||
const int flags, struct kvec *resp_iov);
|
||||
extern int compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const int flags, const int num_rqst,
|
||||
struct smb_rqst *rqst, int *resp_buf_type,
|
||||
struct kvec *resp_iov);
|
||||
int SendReceive(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct smb_hdr *in_buf, unsigned int in_len,
|
||||
struct smb_hdr *out_buf, int *pbytes_returned, const int flags);
|
||||
int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
|
||||
char *in_buf, unsigned int in_len, int flags);
|
||||
int cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server);
|
||||
struct mid_q_entry *cifs_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *ignored,
|
||||
struct smb_rqst *rqst);
|
||||
struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst);
|
||||
void __release_mid(struct TCP_Server_Info *server,
|
||||
struct mid_q_entry *midEntry);
|
||||
void cifs_wake_up_task(struct TCP_Server_Info *server,
|
||||
struct mid_q_entry *mid);
|
||||
int cifs_handle_standard(struct TCP_Server_Info *server,
|
||||
struct mid_q_entry *mid);
|
||||
char *smb3_fs_context_fullpath(const struct smb3_fs_context *ctx, char dirsep);
|
||||
int smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx);
|
||||
int smb3_parse_opt(const char *options, const char *key, char **val);
|
||||
int cifs_ipaddr_cmp(struct sockaddr *srcaddr, struct sockaddr *rhs);
|
||||
bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs);
|
||||
int cifs_discard_remaining_data(struct TCP_Server_Info *server);
|
||||
int cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
|
||||
mid_receive_t receive, mid_callback_t callback,
|
||||
mid_handle_t handle, void *cbdata, const int flags,
|
||||
const struct cifs_credits *exist_credits);
|
||||
struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses);
|
||||
int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server, struct smb_rqst *rqst,
|
||||
int *resp_buf_type, const int flags, struct kvec *resp_iov);
|
||||
int compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server, const int flags,
|
||||
const int num_rqst, struct smb_rqst *rqst,
|
||||
int *resp_buf_type, struct kvec *resp_iov);
|
||||
int cifs_sync_mid_result(struct mid_q_entry *mid,
|
||||
struct TCP_Server_Info *server);
|
||||
int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
|
||||
struct smb_rqst *rqst);
|
||||
extern int cifs_check_receive(struct mid_q_entry *mid,
|
||||
struct TCP_Server_Info *server, bool log_error);
|
||||
int wait_for_free_request(struct TCP_Server_Info *server, const int flags,
|
||||
unsigned int *instance);
|
||||
extern int cifs_wait_mtu_credits(struct TCP_Server_Info *server,
|
||||
size_t size, size_t *num,
|
||||
struct cifs_credits *credits);
|
||||
int cifs_wait_mtu_credits(struct TCP_Server_Info *server, size_t size,
|
||||
size_t *num, struct cifs_credits *credits);
|
||||
|
||||
static inline int
|
||||
send_cancel(struct cifs_ses *ses, struct TCP_Server_Info *server,
|
||||
|
|
@ -137,482 +123,216 @@ send_cancel(struct cifs_ses *ses, struct TCP_Server_Info *server,
|
|||
server->ops->send_cancel(ses, server, rqst, mid, xid) : 0;
|
||||
}
|
||||
|
||||
int wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ);
|
||||
extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *,
|
||||
struct kvec *, int /* nvec to send */,
|
||||
int * /* type of buf returned */, const int flags,
|
||||
struct kvec * /* resp vec */);
|
||||
int wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *mid);
|
||||
|
||||
void smb2_query_server_interfaces(struct work_struct *work);
|
||||
void
|
||||
cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server,
|
||||
bool all_channels);
|
||||
void
|
||||
cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
|
||||
bool mark_smb_session);
|
||||
extern int cifs_reconnect(struct TCP_Server_Info *server,
|
||||
bool mark_smb_session);
|
||||
int checkSMB(char *buf, unsigned int pdu_len, unsigned int len,
|
||||
struct TCP_Server_Info *srvr);
|
||||
extern bool is_valid_oplock_break(char *, struct TCP_Server_Info *);
|
||||
extern bool backup_cred(struct cifs_sb_info *);
|
||||
extern bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 eof,
|
||||
bool from_readdir);
|
||||
void cifs_write_subrequest_terminated(struct cifs_io_subrequest *wdata, ssize_t result);
|
||||
extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *, int);
|
||||
extern int cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
|
||||
int flags,
|
||||
struct cifsFileInfo **ret_file);
|
||||
extern int cifs_get_writable_path(struct cifs_tcon *tcon, const char *name,
|
||||
int flags,
|
||||
struct cifsFileInfo **ret_file);
|
||||
extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *, bool);
|
||||
extern int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name,
|
||||
struct cifsFileInfo **ret_file);
|
||||
extern int cifs_get_hardlink_path(struct cifs_tcon *tcon, struct inode *inode,
|
||||
struct file *file);
|
||||
extern unsigned int smbCalcSize(void *buf);
|
||||
extern int decode_negTokenInit(unsigned char *security_blob, int length,
|
||||
void cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server,
|
||||
bool all_channels);
|
||||
void cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
|
||||
bool mark_smb_session);
|
||||
int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session);
|
||||
bool backup_cred(struct cifs_sb_info *cifs_sb);
|
||||
bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file,
|
||||
bool from_readdir);
|
||||
void cifs_write_subrequest_terminated(struct cifs_io_subrequest *wdata,
|
||||
ssize_t result);
|
||||
struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *cifs_inode,
|
||||
int flags);
|
||||
int cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, int flags,
|
||||
struct cifsFileInfo **ret_file);
|
||||
int cifs_get_writable_path(struct cifs_tcon *tcon, const char *name, int flags,
|
||||
struct cifsFileInfo **ret_file);
|
||||
struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode,
|
||||
bool fsuid_only);
|
||||
int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name,
|
||||
struct cifsFileInfo **ret_file);
|
||||
int cifs_get_hardlink_path(struct cifs_tcon *tcon, struct inode *inode,
|
||||
struct file *file);
|
||||
int decode_negTokenInit(unsigned char *security_blob, int length,
|
||||
struct TCP_Server_Info *server);
|
||||
extern int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
|
||||
extern void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
|
||||
extern int map_smb_to_linux_error(char *buf, bool logErr);
|
||||
extern int map_and_check_smb_error(struct TCP_Server_Info *server,
|
||||
struct mid_q_entry *mid, bool logErr);
|
||||
unsigned int header_assemble(struct smb_hdr *buffer, char smb_command,
|
||||
const struct cifs_tcon *treeCon, int word_count
|
||||
/* length of fixed section word count in two byte units */);
|
||||
extern int small_smb_init_no_tc(const int smb_cmd, const int wct,
|
||||
struct cifs_ses *ses,
|
||||
void **request_buf);
|
||||
extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const struct nls_table *nls_cp);
|
||||
extern struct timespec64 cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
|
||||
extern u64 cifs_UnixTimeToNT(struct timespec64);
|
||||
extern struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
|
||||
int offset);
|
||||
extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
|
||||
extern int cifs_get_writer(struct cifsInodeInfo *cinode);
|
||||
extern void cifs_put_writer(struct cifsInodeInfo *cinode);
|
||||
extern void cifs_done_oplock_break(struct cifsInodeInfo *cinode);
|
||||
extern int cifs_unlock_range(struct cifsFileInfo *cfile,
|
||||
struct file_lock *flock, const unsigned int xid);
|
||||
extern int cifs_push_mandatory_locks(struct cifsFileInfo *cfile);
|
||||
int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
|
||||
void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
|
||||
struct timespec64 cifs_NTtimeToUnix(__le64 ntutc);
|
||||
u64 cifs_UnixTimeToNT(struct timespec64 t);
|
||||
struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset);
|
||||
void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
|
||||
int cifs_get_writer(struct cifsInodeInfo *cinode);
|
||||
void cifs_put_writer(struct cifsInodeInfo *cinode);
|
||||
void cifs_done_oplock_break(struct cifsInodeInfo *cinode);
|
||||
int cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
|
||||
unsigned int xid);
|
||||
int cifs_push_mandatory_locks(struct cifsFileInfo *cfile);
|
||||
|
||||
extern void cifs_down_write(struct rw_semaphore *sem);
|
||||
void cifs_down_write(struct rw_semaphore *sem);
|
||||
struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
|
||||
struct tcon_link *tlink, __u32 oplock,
|
||||
const char *symlink_target);
|
||||
extern int cifs_posix_open(const char *full_path, struct inode **inode,
|
||||
struct super_block *sb, int mode,
|
||||
unsigned int f_flags, __u32 *oplock, __u16 *netfid,
|
||||
unsigned int xid);
|
||||
int cifs_posix_open(const char *full_path, struct inode **pinode,
|
||||
struct super_block *sb, int mode, unsigned int f_flags,
|
||||
__u32 *poplock, __u16 *pnetfid, unsigned int xid);
|
||||
void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr);
|
||||
extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr,
|
||||
FILE_UNIX_BASIC_INFO *info,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
extern void cifs_dir_info_to_fattr(struct cifs_fattr *, FILE_DIRECTORY_INFO *,
|
||||
struct cifs_sb_info *);
|
||||
extern int cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr,
|
||||
bool from_readdir);
|
||||
extern struct inode *cifs_iget(struct super_block *sb,
|
||||
struct cifs_fattr *fattr);
|
||||
void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr,
|
||||
FILE_UNIX_BASIC_INFO *info,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
void cifs_dir_info_to_fattr(struct cifs_fattr *fattr,
|
||||
FILE_DIRECTORY_INFO *info,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
int cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr,
|
||||
bool from_readdir);
|
||||
struct inode *cifs_iget(struct super_block *sb, struct cifs_fattr *fattr);
|
||||
|
||||
int cifs_get_inode_info(struct inode **inode, const char *full_path,
|
||||
struct cifs_open_info_data *data, struct super_block *sb, int xid,
|
||||
struct cifs_open_info_data *data,
|
||||
struct super_block *sb, int xid,
|
||||
const struct cifs_fid *fid);
|
||||
extern int smb311_posix_get_inode_info(struct inode **inode,
|
||||
const char *full_path,
|
||||
struct cifs_open_info_data *data,
|
||||
struct super_block *sb,
|
||||
const unsigned int xid);
|
||||
extern int cifs_get_inode_info_unix(struct inode **pinode,
|
||||
const unsigned char *search_path,
|
||||
struct super_block *sb, unsigned int xid);
|
||||
extern int cifs_set_file_info(struct inode *inode, struct iattr *attrs,
|
||||
unsigned int xid, const char *full_path, __u32 dosattr);
|
||||
extern int cifs_rename_pending_delete(const char *full_path,
|
||||
struct dentry *dentry,
|
||||
const unsigned int xid);
|
||||
extern int sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid,
|
||||
struct cifs_fattr *fattr, uint sidtype);
|
||||
extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
|
||||
struct cifs_fattr *fattr, struct inode *inode,
|
||||
bool get_mode_from_special_sid,
|
||||
const char *path, const struct cifs_fid *pfid);
|
||||
extern int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
|
||||
kuid_t uid, kgid_t gid);
|
||||
extern struct smb_ntsd *get_cifs_acl(struct cifs_sb_info *cifssmb, struct inode *ino,
|
||||
const char *path, u32 *plen, u32 info);
|
||||
extern struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifssb,
|
||||
const struct cifs_fid *pfid, u32 *plen, u32 info);
|
||||
extern struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap,
|
||||
struct dentry *dentry, int type);
|
||||
extern int cifs_set_acl(struct mnt_idmap *idmap,
|
||||
struct dentry *dentry, struct posix_acl *acl, int type);
|
||||
extern int set_cifs_acl(struct smb_ntsd *pntsd, __u32 len, struct inode *ino,
|
||||
const char *path, int flag);
|
||||
extern unsigned int setup_authusers_ACE(struct smb_ace *pace);
|
||||
extern unsigned int setup_special_mode_ACE(struct smb_ace *pace,
|
||||
bool posix,
|
||||
__u64 nmode);
|
||||
extern unsigned int setup_special_user_owner_ACE(struct smb_ace *pace);
|
||||
int smb311_posix_get_inode_info(struct inode **inode, const char *full_path,
|
||||
struct cifs_open_info_data *data,
|
||||
struct super_block *sb,
|
||||
const unsigned int xid);
|
||||
int cifs_get_inode_info_unix(struct inode **pinode,
|
||||
const unsigned char *full_path,
|
||||
struct super_block *sb, unsigned int xid);
|
||||
int cifs_set_file_info(struct inode *inode, struct iattr *attrs,
|
||||
unsigned int xid, const char *full_path, __u32 dosattr);
|
||||
int cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
|
||||
const unsigned int xid);
|
||||
int sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid,
|
||||
struct cifs_fattr *fattr, uint sidtype);
|
||||
int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
|
||||
struct inode *inode, bool mode_from_special_sid,
|
||||
const char *path, const struct cifs_fid *pfid);
|
||||
int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
|
||||
kuid_t uid, kgid_t gid);
|
||||
struct smb_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
|
||||
struct inode *inode, const char *path,
|
||||
u32 *pacllen, u32 info);
|
||||
struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
|
||||
const struct cifs_fid *cifsfid,
|
||||
u32 *pacllen, u32 info);
|
||||
struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
|
||||
int type);
|
||||
int cifs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
|
||||
struct posix_acl *acl, int type);
|
||||
int set_cifs_acl(struct smb_ntsd *pnntsd, __u32 acllen, struct inode *inode,
|
||||
const char *path, int aclflag);
|
||||
unsigned int setup_authusers_ACE(struct smb_ace *pntace);
|
||||
unsigned int setup_special_mode_ACE(struct smb_ace *pntace, bool posix,
|
||||
__u64 nmode);
|
||||
unsigned int setup_special_user_owner_ACE(struct smb_ace *pntace);
|
||||
|
||||
void dequeue_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid, bool malformed);
|
||||
extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf,
|
||||
unsigned int to_read);
|
||||
extern ssize_t cifs_discard_from_socket(struct TCP_Server_Info *server,
|
||||
size_t to_read);
|
||||
void dequeue_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid,
|
||||
bool malformed);
|
||||
int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf,
|
||||
unsigned int to_read);
|
||||
ssize_t cifs_discard_from_socket(struct TCP_Server_Info *server,
|
||||
size_t to_read);
|
||||
int cifs_read_iter_from_socket(struct TCP_Server_Info *server,
|
||||
struct iov_iter *iter,
|
||||
unsigned int to_read);
|
||||
extern int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb);
|
||||
struct iov_iter *iter, unsigned int to_read);
|
||||
int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb);
|
||||
void cifs_mount_put_conns(struct cifs_mount_ctx *mnt_ctx);
|
||||
int cifs_mount_get_session(struct cifs_mount_ctx *mnt_ctx);
|
||||
int cifs_is_path_remote(struct cifs_mount_ctx *mnt_ctx);
|
||||
int cifs_mount_get_tcon(struct cifs_mount_ctx *mnt_ctx);
|
||||
extern int cifs_match_super(struct super_block *, void *);
|
||||
extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
|
||||
extern void cifs_umount(struct cifs_sb_info *);
|
||||
extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
|
||||
extern void cifs_reopen_persistent_handles(struct cifs_tcon *tcon);
|
||||
int cifs_match_super(struct super_block *sb, void *data);
|
||||
int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
|
||||
void cifs_umount(struct cifs_sb_info *cifs_sb);
|
||||
void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
|
||||
void cifs_reopen_persistent_handles(struct cifs_tcon *tcon);
|
||||
|
||||
extern bool cifs_find_lock_conflict(struct cifsFileInfo *cfile, __u64 offset,
|
||||
__u64 length, __u8 type, __u16 flags,
|
||||
struct cifsLockInfo **conf_lock,
|
||||
int rw_check);
|
||||
extern void cifs_add_pending_open(struct cifs_fid *fid,
|
||||
bool cifs_find_lock_conflict(struct cifsFileInfo *cfile, __u64 offset,
|
||||
__u64 length, __u8 type, __u16 flags,
|
||||
struct cifsLockInfo **conf_lock, int rw_check);
|
||||
void cifs_add_pending_open(struct cifs_fid *fid, struct tcon_link *tlink,
|
||||
struct cifs_pending_open *open);
|
||||
void cifs_add_pending_open_locked(struct cifs_fid *fid,
|
||||
struct tcon_link *tlink,
|
||||
struct cifs_pending_open *open);
|
||||
extern void cifs_add_pending_open_locked(struct cifs_fid *fid,
|
||||
struct tcon_link *tlink,
|
||||
struct cifs_pending_open *open);
|
||||
extern void cifs_del_pending_open(struct cifs_pending_open *open);
|
||||
void cifs_del_pending_open(struct cifs_pending_open *open);
|
||||
|
||||
extern bool cifs_is_deferred_close(struct cifsFileInfo *cfile,
|
||||
struct cifs_deferred_close **dclose);
|
||||
bool cifs_is_deferred_close(struct cifsFileInfo *cfile,
|
||||
struct cifs_deferred_close **pdclose);
|
||||
|
||||
extern void cifs_add_deferred_close(struct cifsFileInfo *cfile,
|
||||
struct cifs_deferred_close *dclose);
|
||||
void cifs_add_deferred_close(struct cifsFileInfo *cfile,
|
||||
struct cifs_deferred_close *dclose);
|
||||
|
||||
extern void cifs_del_deferred_close(struct cifsFileInfo *cfile);
|
||||
void cifs_del_deferred_close(struct cifsFileInfo *cfile);
|
||||
|
||||
extern void cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode);
|
||||
void cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode);
|
||||
|
||||
extern void cifs_close_all_deferred_files(struct cifs_tcon *cifs_tcon);
|
||||
void cifs_close_all_deferred_files(struct cifs_tcon *tcon);
|
||||
|
||||
void cifs_close_deferred_file_under_dentry(struct cifs_tcon *cifs_tcon,
|
||||
void cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon,
|
||||
struct dentry *dentry);
|
||||
|
||||
extern void cifs_mark_open_handles_for_deleted_file(struct inode *inode,
|
||||
const char *path);
|
||||
void cifs_mark_open_handles_for_deleted_file(struct inode *inode,
|
||||
const char *path);
|
||||
|
||||
extern struct TCP_Server_Info *
|
||||
cifs_get_tcp_session(struct smb3_fs_context *ctx,
|
||||
struct TCP_Server_Info *primary_server);
|
||||
extern void cifs_put_tcp_session(struct TCP_Server_Info *server,
|
||||
int from_reconnect);
|
||||
extern void cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
|
||||
struct TCP_Server_Info *cifs_get_tcp_session(struct smb3_fs_context *ctx,
|
||||
struct TCP_Server_Info *primary_server);
|
||||
void cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect);
|
||||
void cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
|
||||
|
||||
extern void cifs_release_automount_timer(void);
|
||||
void cifs_release_automount_timer(void);
|
||||
|
||||
void cifs_proc_init(void);
|
||||
void cifs_proc_clean(void);
|
||||
|
||||
extern void cifs_move_llist(struct list_head *source, struct list_head *dest);
|
||||
extern void cifs_free_llist(struct list_head *llist);
|
||||
extern void cifs_del_lock_waiters(struct cifsLockInfo *lock);
|
||||
void cifs_move_llist(struct list_head *source, struct list_head *dest);
|
||||
void cifs_free_llist(struct list_head *llist);
|
||||
void cifs_del_lock_waiters(struct cifsLockInfo *lock);
|
||||
|
||||
int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon);
|
||||
|
||||
extern int cifs_negotiate_protocol(const unsigned int xid,
|
||||
struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
extern int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
struct nls_table *nls_info);
|
||||
extern int cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required);
|
||||
extern int CIFSSMBNegotiate(const unsigned int xid,
|
||||
struct cifs_ses *ses,
|
||||
int cifs_negotiate_protocol(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
struct nls_table *nls_info);
|
||||
int cifs_enable_signing(struct TCP_Server_Info *server,
|
||||
bool mnt_sign_required);
|
||||
|
||||
extern int CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
|
||||
const char *tree, struct cifs_tcon *tcon,
|
||||
const struct nls_table *);
|
||||
int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
|
||||
unsigned int *num_of_nodes,
|
||||
struct dfs_info3_param **target_nodes,
|
||||
const struct nls_table *nls_codepage, int remap,
|
||||
const char *searchName, bool is_unicode);
|
||||
|
||||
extern int CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *searchName, struct cifs_sb_info *cifs_sb,
|
||||
__u16 *searchHandle, __u16 search_flags,
|
||||
struct cifs_search_info *psrch_inf,
|
||||
bool msearch);
|
||||
struct cifs_ses *sesInfoAlloc(void);
|
||||
void sesInfoFree(struct cifs_ses *buf_to_free);
|
||||
struct cifs_tcon *tcon_info_alloc(bool dir_leases_enabled,
|
||||
enum smb3_tcon_ref_trace trace);
|
||||
void tconInfoFree(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
|
||||
|
||||
extern int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
__u16 searchHandle, __u16 search_flags,
|
||||
struct cifs_search_info *psrch_inf);
|
||||
|
||||
extern int CIFSFindClose(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u16 search_handle);
|
||||
|
||||
extern int CIFSSMBQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u16 netfid, FILE_ALL_INFO *pFindData);
|
||||
extern int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *search_Name, FILE_ALL_INFO *data,
|
||||
int legacy /* whether to use old info level */,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
extern int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *search_name, FILE_ALL_INFO *data,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
|
||||
extern int CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u16 netfid, FILE_UNIX_BASIC_INFO *pFindData);
|
||||
extern int CIFSSMBUnixQPathInfo(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
const unsigned char *searchName,
|
||||
FILE_UNIX_BASIC_INFO *pFindData,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
|
||||
extern int CIFSGetDFSRefer(const unsigned int xid, struct cifs_ses *ses,
|
||||
const char *search_name,
|
||||
struct dfs_info3_param **target_nodes,
|
||||
unsigned int *num_of_nodes,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
|
||||
extern int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
|
||||
unsigned int *num_of_nodes,
|
||||
struct dfs_info3_param **target_nodes,
|
||||
const struct nls_table *nls_codepage, int remap,
|
||||
const char *searchName, bool is_unicode);
|
||||
extern void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
struct smb3_fs_context *ctx);
|
||||
extern int CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct kstatfs *FSData);
|
||||
extern int SMBOldQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct kstatfs *FSData);
|
||||
extern int CIFSSMBSetFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
__u64 cap);
|
||||
|
||||
extern int CIFSSMBQFSAttributeInfo(const unsigned int xid,
|
||||
struct cifs_tcon *tcon);
|
||||
extern int CIFSSMBQFSDeviceInfo(const unsigned int xid, struct cifs_tcon *tcon);
|
||||
extern int CIFSSMBQFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon);
|
||||
extern int CIFSSMBQFSPosixInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct kstatfs *FSData);
|
||||
|
||||
extern int SMBSetInformation(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *fileName, __le32 attributes, __le64 write_time,
|
||||
const struct nls_table *nls_codepage,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
extern int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *fileName, const FILE_BASIC_INFO *data,
|
||||
const struct nls_table *nls_codepage,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
extern int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const FILE_BASIC_INFO *data, __u16 fid,
|
||||
__u32 pid_of_opener);
|
||||
extern int CIFSSMBSetFileDisposition(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
bool delete_file, __u16 fid,
|
||||
__u32 pid_of_opener);
|
||||
extern int CIFSSMBSetEOF(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *file_name, __u64 size,
|
||||
struct cifs_sb_info *cifs_sb, bool set_allocation,
|
||||
struct dentry *dentry);
|
||||
extern int CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifsFileInfo *cfile, __u64 size,
|
||||
bool set_allocation);
|
||||
|
||||
struct cifs_unix_set_info_args {
|
||||
__u64 ctime;
|
||||
__u64 atime;
|
||||
__u64 mtime;
|
||||
__u64 mode;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
dev_t device;
|
||||
};
|
||||
|
||||
extern int CIFSSMBUnixSetFileInfo(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
const struct cifs_unix_set_info_args *args,
|
||||
u16 fid, u32 pid_of_opener);
|
||||
|
||||
extern int CIFSSMBUnixSetPathInfo(const unsigned int xid,
|
||||
struct cifs_tcon *tcon, const char *file_name,
|
||||
const struct cifs_unix_set_info_args *args,
|
||||
const struct nls_table *nls_codepage,
|
||||
int remap);
|
||||
|
||||
extern int CIFSSMBMkDir(const unsigned int xid, struct inode *inode,
|
||||
umode_t mode, struct cifs_tcon *tcon,
|
||||
const char *name, struct cifs_sb_info *cifs_sb);
|
||||
extern int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *name, struct cifs_sb_info *cifs_sb);
|
||||
extern int CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *name, __u16 type,
|
||||
const struct nls_table *nls_codepage,
|
||||
int remap_special_chars);
|
||||
extern int CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *name, struct cifs_sb_info *cifs_sb,
|
||||
struct dentry *dentry);
|
||||
int CIFSSMBRename(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct dentry *source_dentry,
|
||||
const char *from_name, const char *to_name,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
extern int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
int netfid, const char *target_name,
|
||||
const struct nls_table *nls_codepage,
|
||||
int remap_special_chars);
|
||||
int CIFSCreateHardLink(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
struct dentry *source_dentry,
|
||||
const char *from_name, const char *to_name,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
extern int CIFSUnixCreateHardLink(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
const char *fromName, const char *toName,
|
||||
const struct nls_table *nls_codepage,
|
||||
int remap_special_chars);
|
||||
extern int CIFSUnixCreateSymLink(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
const char *fromName, const char *toName,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
extern int CIFSSMBUnixQuerySymLink(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
const unsigned char *searchName, char **syminfo,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
extern int cifs_query_reparse_point(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
const char *full_path,
|
||||
u32 *tag, struct kvec *rsp,
|
||||
int *rsp_buftype);
|
||||
extern struct inode *cifs_create_reparse_inode(struct cifs_open_info_data *data,
|
||||
struct super_block *sb,
|
||||
const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
const char *full_path,
|
||||
bool directory,
|
||||
struct kvec *reparse_iov,
|
||||
struct kvec *xattr_iov);
|
||||
extern int CIFSSMB_set_compression(const unsigned int xid,
|
||||
struct cifs_tcon *tcon, __u16 fid);
|
||||
extern int CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms,
|
||||
int *oplock, FILE_ALL_INFO *buf);
|
||||
extern int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *fileName, const int disposition,
|
||||
const int access_flags, const int omode,
|
||||
__u16 *netfid, int *pOplock, FILE_ALL_INFO *,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
extern int CIFSPOSIXCreate(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u32 posix_flags, __u64 mode, __u16 *netfid,
|
||||
FILE_UNIX_BASIC_INFO *pRetData,
|
||||
__u32 *pOplock, const char *name,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
extern int CIFSSMBClose(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const int smb_file_id);
|
||||
|
||||
extern int CIFSSMBFlush(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const int smb_file_id);
|
||||
|
||||
extern int CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms,
|
||||
unsigned int *nbytes, char **buf,
|
||||
int *return_buf_type);
|
||||
extern int CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
|
||||
unsigned int *nbytes, const char *buf);
|
||||
extern int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
|
||||
unsigned int *nbytes, struct kvec *iov, const int nvec);
|
||||
extern int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *search_name, __u64 *inode_number,
|
||||
const struct nls_table *nls_codepage,
|
||||
int remap);
|
||||
|
||||
extern int cifs_lockv(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u16 netfid, const __u8 lock_type,
|
||||
const __u32 num_unlock, const __u32 num_lock,
|
||||
LOCKING_ANDX_RANGE *buf);
|
||||
extern int CIFSSMBLock(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u16 netfid, const __u32 netpid, const __u64 len,
|
||||
const __u64 offset, const __u32 numUnlock,
|
||||
const __u32 numLock, const __u8 lockType,
|
||||
const bool waitFlag, const __u8 oplock_level);
|
||||
extern int CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u16 smb_file_id, const __u32 netpid,
|
||||
const loff_t start_offset, const __u64 len,
|
||||
struct file_lock *, const __u16 lock_type,
|
||||
const bool waitFlag);
|
||||
extern int CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon);
|
||||
extern int CIFSSMBEcho(struct TCP_Server_Info *server);
|
||||
extern int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses);
|
||||
|
||||
extern struct cifs_ses *sesInfoAlloc(void);
|
||||
extern void sesInfoFree(struct cifs_ses *);
|
||||
extern struct cifs_tcon *tcon_info_alloc(bool dir_leases_enabled,
|
||||
enum smb3_tcon_ref_trace trace);
|
||||
extern void tconInfoFree(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace);
|
||||
|
||||
extern int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
|
||||
__u32 *pexpected_response_sequence_number);
|
||||
int cifs_verify_signature(struct smb_rqst *rqst,
|
||||
struct TCP_Server_Info *server,
|
||||
__u32 expected_sequence_number);
|
||||
extern int setup_ntlmv2_rsp(struct cifs_ses *, const struct nls_table *);
|
||||
extern void cifs_crypto_secmech_release(struct TCP_Server_Info *server);
|
||||
extern int calc_seckey(struct cifs_ses *);
|
||||
extern int generate_smb30signingkey(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
extern int generate_smb311signingkey(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
int setup_ntlmv2_rsp(struct cifs_ses *ses, const struct nls_table *nls_cp);
|
||||
void cifs_crypto_secmech_release(struct TCP_Server_Info *server);
|
||||
int calc_seckey(struct cifs_ses *ses);
|
||||
int generate_smb30signingkey(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
int generate_smb311signingkey(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
|
||||
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
|
||||
extern ssize_t CIFSSMBQAllEAs(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const unsigned char *searchName,
|
||||
const unsigned char *ea_name, char *EAData,
|
||||
size_t bufsize, struct cifs_sb_info *cifs_sb);
|
||||
extern int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *fileName, const char *ea_name,
|
||||
const void *ea_value, const __u16 ea_value_len,
|
||||
const struct nls_table *nls_codepage,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
extern int CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
__u16 fid, struct smb_ntsd **acl_inf, __u32 *buflen, __u32 info);
|
||||
extern int CIFSSMBSetCIFSACL(const unsigned int, struct cifs_tcon *, __u16,
|
||||
struct smb_ntsd *pntsd, __u32 len, int aclflag);
|
||||
extern int cifs_do_get_acl(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const unsigned char *searchName,
|
||||
struct posix_acl **acl, const int acl_type,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
extern int cifs_do_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const unsigned char *fileName,
|
||||
const struct posix_acl *acl, const int acl_type,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
extern int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
|
||||
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
|
||||
extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb);
|
||||
extern bool couldbe_mf_symlink(const struct cifs_fattr *fattr);
|
||||
extern int check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
struct cifs_fattr *fattr,
|
||||
const unsigned char *path);
|
||||
extern int E_md4hash(const unsigned char *passwd, unsigned char *p16,
|
||||
const struct nls_table *codepage);
|
||||
void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb);
|
||||
bool couldbe_mf_symlink(const struct cifs_fattr *fattr);
|
||||
int check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
|
||||
const unsigned char *path);
|
||||
int E_md4hash(const unsigned char *passwd, unsigned char *p16,
|
||||
const struct nls_table *codepage);
|
||||
|
||||
extern struct TCP_Server_Info *
|
||||
cifs_find_tcp_session(struct smb3_fs_context *ctx);
|
||||
struct TCP_Server_Info *cifs_find_tcp_session(struct smb3_fs_context *ctx);
|
||||
|
||||
struct cifs_tcon *cifs_setup_ipc(struct cifs_ses *ses, bool seal);
|
||||
|
||||
void __cifs_put_smb_ses(struct cifs_ses *ses);
|
||||
|
||||
extern struct cifs_ses *
|
||||
cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx);
|
||||
struct cifs_ses *cifs_get_smb_ses(struct TCP_Server_Info *server,
|
||||
struct smb3_fs_context *ctx);
|
||||
|
||||
int cifs_async_readv(struct cifs_io_subrequest *rdata);
|
||||
int cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid);
|
||||
int cifs_readv_receive(struct TCP_Server_Info *server,
|
||||
struct mid_q_entry *mid);
|
||||
|
||||
void cifs_async_writev(struct cifs_io_subrequest *wdata);
|
||||
int cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
const unsigned char *path, char *pbuf,
|
||||
|
|
@ -621,46 +341,41 @@ int cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
|
|||
struct cifs_sb_info *cifs_sb,
|
||||
const unsigned char *path, char *pbuf,
|
||||
unsigned int *pbytes_written);
|
||||
int __cifs_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server,
|
||||
char *signature, struct cifs_calc_sig_ctx *ctx);
|
||||
enum securityEnum cifs_select_sectype(struct TCP_Server_Info *,
|
||||
enum securityEnum);
|
||||
int __cifs_calc_signature(struct smb_rqst *rqst,
|
||||
struct TCP_Server_Info *server, char *signature,
|
||||
struct cifs_calc_sig_ctx *ctx);
|
||||
enum securityEnum cifs_select_sectype(struct TCP_Server_Info *server,
|
||||
enum securityEnum requested);
|
||||
|
||||
int cifs_alloc_hash(const char *name, struct shash_desc **sdesc);
|
||||
void cifs_free_hash(struct shash_desc **sdesc);
|
||||
|
||||
int cifs_try_adding_channels(struct cifs_ses *ses);
|
||||
int smb3_update_ses_channels(struct cifs_ses *ses, struct TCP_Server_Info *server,
|
||||
bool from_reconnect, bool disable_mchan);
|
||||
int smb3_update_ses_channels(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
bool from_reconnect, bool disable_mchan);
|
||||
bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface);
|
||||
|
||||
int
|
||||
cifs_ses_get_chan_index(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
void
|
||||
cifs_chan_set_in_reconnect(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
void
|
||||
cifs_chan_clear_in_reconnect(struct cifs_ses *ses,
|
||||
int cifs_ses_get_chan_index(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
void cifs_chan_set_in_reconnect(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
void cifs_chan_clear_in_reconnect(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
void cifs_chan_set_need_reconnect(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
void cifs_chan_clear_need_reconnect(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
bool cifs_chan_needs_reconnect(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
void
|
||||
cifs_chan_set_need_reconnect(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
void
|
||||
cifs_chan_clear_need_reconnect(struct cifs_ses *ses,
|
||||
bool cifs_chan_is_iface_active(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
bool
|
||||
cifs_chan_needs_reconnect(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
bool
|
||||
cifs_chan_is_iface_active(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
void
|
||||
cifs_decrease_secondary_channels(struct cifs_ses *ses, bool disable_mchan);
|
||||
void
|
||||
cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server);
|
||||
int
|
||||
SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount);
|
||||
void cifs_decrease_secondary_channels(struct cifs_ses *ses,
|
||||
bool disable_mchan);
|
||||
void cifs_chan_update_iface(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
int SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
bool in_mount);
|
||||
|
||||
void extract_unc_hostname(const char *unc, const char **h, size_t *len);
|
||||
int copy_path_name(char *dst, const char *src);
|
||||
|
|
@ -673,9 +388,8 @@ void cifs_put_tcp_super(struct super_block *sb);
|
|||
int cifs_update_super_prepath(struct cifs_sb_info *cifs_sb, char *prefix);
|
||||
char *extract_hostname(const char *unc);
|
||||
char *extract_sharename(const char *unc);
|
||||
int parse_reparse_point(struct reparse_data_buffer *buf,
|
||||
u32 plen, struct cifs_sb_info *cifs_sb,
|
||||
const char *full_path,
|
||||
int parse_reparse_point(struct reparse_data_buffer *buf, u32 plen,
|
||||
struct cifs_sb_info *cifs_sb, const char *full_path,
|
||||
struct cifs_open_info_data *data);
|
||||
int __cifs_sfu_make_node(unsigned int xid, struct inode *inode,
|
||||
struct dentry *dentry, struct cifs_tcon *tcon,
|
||||
|
|
@ -696,14 +410,12 @@ static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,
|
|||
referral, NULL);
|
||||
}
|
||||
|
||||
int match_target_ip(struct TCP_Server_Info *server,
|
||||
const char *host, size_t hostlen,
|
||||
bool *result);
|
||||
int match_target_ip(struct TCP_Server_Info *server, const char *host,
|
||||
size_t hostlen, bool *result);
|
||||
int cifs_inval_name_dfs_link_error(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
const char *full_path,
|
||||
bool *islink);
|
||||
const char *full_path, bool *islink);
|
||||
#else
|
||||
static inline int cifs_inval_name_dfs_link_error(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
|
|
|
|||
|
|
@ -26,11 +26,12 @@
|
|||
#include <linux/uaccess.h>
|
||||
#include <linux/netfs.h>
|
||||
#include <trace/events/netfs.h>
|
||||
#include "cifspdu.h"
|
||||
#include "cifsfs.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsacl.h"
|
||||
#include "cifsproto.h"
|
||||
#include "smb1proto.h"
|
||||
#include "../common/smbfsctl.h"
|
||||
#include "cifsfs.h"
|
||||
#include "cifsacl.h"
|
||||
#include "cifs_unicode.h"
|
||||
#include "cifs_debug.h"
|
||||
#include "fscache.h"
|
||||
|
|
@ -533,6 +534,146 @@ neg_err_exit:
|
|||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Issue a TREE_CONNECT request.
|
||||
*/
|
||||
int
|
||||
CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
|
||||
const char *tree, struct cifs_tcon *tcon,
|
||||
const struct nls_table *nls_codepage)
|
||||
{
|
||||
struct smb_hdr *smb_buffer;
|
||||
struct smb_hdr *smb_buffer_response;
|
||||
TCONX_REQ *pSMB;
|
||||
TCONX_RSP *pSMBr;
|
||||
unsigned char *bcc_ptr;
|
||||
int rc = 0;
|
||||
int length, in_len;
|
||||
__u16 bytes_left, count;
|
||||
|
||||
if (ses == NULL)
|
||||
return smb_EIO(smb_eio_trace_null_pointers);
|
||||
|
||||
smb_buffer = cifs_buf_get();
|
||||
if (smb_buffer == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
smb_buffer_response = smb_buffer;
|
||||
|
||||
in_len = header_assemble(smb_buffer, SMB_COM_TREE_CONNECT_ANDX,
|
||||
NULL /*no tid */, 4 /*wct */);
|
||||
|
||||
smb_buffer->Mid = get_next_mid(ses->server);
|
||||
smb_buffer->Uid = ses->Suid;
|
||||
pSMB = (TCONX_REQ *) smb_buffer;
|
||||
pSMBr = (TCONX_RSP *) smb_buffer_response;
|
||||
|
||||
pSMB->AndXCommand = 0xFF;
|
||||
pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO);
|
||||
bcc_ptr = &pSMB->Password[0];
|
||||
|
||||
pSMB->PasswordLength = cpu_to_le16(1); /* minimum */
|
||||
*bcc_ptr = 0; /* password is null byte */
|
||||
bcc_ptr++; /* skip password */
|
||||
/* already aligned so no need to do it below */
|
||||
|
||||
if (ses->server->sign)
|
||||
smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
|
||||
|
||||
if (ses->capabilities & CAP_STATUS32)
|
||||
smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS;
|
||||
|
||||
if (ses->capabilities & CAP_DFS)
|
||||
smb_buffer->Flags2 |= SMBFLG2_DFS;
|
||||
|
||||
if (ses->capabilities & CAP_UNICODE) {
|
||||
smb_buffer->Flags2 |= SMBFLG2_UNICODE;
|
||||
length =
|
||||
cifs_strtoUTF16((__le16 *) bcc_ptr, tree,
|
||||
6 /* max utf8 char length in bytes */ *
|
||||
(/* server len*/ + 256 /* share len */), nls_codepage);
|
||||
bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */
|
||||
bcc_ptr += 2; /* skip trailing null */
|
||||
} else { /* ASCII */
|
||||
strcpy(bcc_ptr, tree);
|
||||
bcc_ptr += strlen(tree) + 1;
|
||||
}
|
||||
strcpy(bcc_ptr, "?????");
|
||||
bcc_ptr += strlen("?????");
|
||||
bcc_ptr += 1;
|
||||
count = bcc_ptr - &pSMB->Password[0];
|
||||
in_len += count;
|
||||
pSMB->ByteCount = cpu_to_le16(count);
|
||||
|
||||
rc = SendReceive(xid, ses, smb_buffer, in_len, smb_buffer_response,
|
||||
&length, 0);
|
||||
|
||||
/* above now done in SendReceive */
|
||||
if (rc == 0) {
|
||||
bool is_unicode;
|
||||
|
||||
tcon->tid = smb_buffer_response->Tid;
|
||||
bcc_ptr = pByteArea(smb_buffer_response);
|
||||
bytes_left = get_bcc(smb_buffer_response);
|
||||
length = strnlen(bcc_ptr, bytes_left - 2);
|
||||
if (smb_buffer->Flags2 & SMBFLG2_UNICODE)
|
||||
is_unicode = true;
|
||||
else
|
||||
is_unicode = false;
|
||||
|
||||
|
||||
/* skip service field (NB: this field is always ASCII) */
|
||||
if (length == 3) {
|
||||
if ((bcc_ptr[0] == 'I') && (bcc_ptr[1] == 'P') &&
|
||||
(bcc_ptr[2] == 'C')) {
|
||||
cifs_dbg(FYI, "IPC connection\n");
|
||||
tcon->ipc = true;
|
||||
tcon->pipe = true;
|
||||
}
|
||||
} else if (length == 2) {
|
||||
if ((bcc_ptr[0] == 'A') && (bcc_ptr[1] == ':')) {
|
||||
/* the most common case */
|
||||
cifs_dbg(FYI, "disk share connection\n");
|
||||
}
|
||||
}
|
||||
bcc_ptr += length + 1;
|
||||
bytes_left -= (length + 1);
|
||||
strscpy(tcon->tree_name, tree, sizeof(tcon->tree_name));
|
||||
|
||||
/* mostly informational -- no need to fail on error here */
|
||||
kfree(tcon->nativeFileSystem);
|
||||
tcon->nativeFileSystem = cifs_strndup_from_utf16(bcc_ptr,
|
||||
bytes_left, is_unicode,
|
||||
nls_codepage);
|
||||
|
||||
cifs_dbg(FYI, "nativeFileSystem=%s\n", tcon->nativeFileSystem);
|
||||
|
||||
if ((smb_buffer_response->WordCount == 3) ||
|
||||
(smb_buffer_response->WordCount == 7))
|
||||
/* field is in same location */
|
||||
tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport);
|
||||
else
|
||||
tcon->Flags = 0;
|
||||
cifs_dbg(FYI, "Tcon flags: 0x%x\n", tcon->Flags);
|
||||
|
||||
/*
|
||||
* reset_cifs_unix_caps calls QFSInfo which requires
|
||||
* need_reconnect to be false, but we would not need to call
|
||||
* reset_caps if this were not a reconnect case so must check
|
||||
* need_reconnect flag here. The caller will also clear
|
||||
* need_reconnect when tcon was successful but needed to be
|
||||
* cleared earlier in the case of unix extensions reconnect
|
||||
*/
|
||||
if (tcon->need_reconnect && tcon->unix_ext) {
|
||||
cifs_dbg(FYI, "resetting caps for %s\n", tcon->tree_name);
|
||||
tcon->need_reconnect = false;
|
||||
reset_cifs_unix_caps(xid, tcon, NULL, NULL);
|
||||
}
|
||||
}
|
||||
cifs_buf_release(smb_buffer);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,265 +0,0 @@
|
|||
// SPDX-License-Identifier: LGPL-2.1
|
||||
/*
|
||||
*
|
||||
* Copyright (C) International Business Machines Corp., 2002,2008
|
||||
* Author(s): Steve French (sfrench@us.ibm.com)
|
||||
* Jeremy Allison (jra@samba.org) 2006.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/gfp.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/net.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/freezer.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/bvec.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/processor.h>
|
||||
#include <linux/mempool.h>
|
||||
#include <linux/sched/signal.h>
|
||||
#include <linux/task_io_accounting_ops.h>
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_debug.h"
|
||||
#include "smb2proto.h"
|
||||
#include "smbdirect.h"
|
||||
#include "compress.h"
|
||||
|
||||
/* Max number of iovectors we can use off the stack when sending requests. */
|
||||
#define CIFS_MAX_IOV_SIZE 8
|
||||
|
||||
static struct mid_q_entry *
|
||||
alloc_mid(const struct smb_hdr *smb_buffer, struct TCP_Server_Info *server)
|
||||
{
|
||||
struct mid_q_entry *temp;
|
||||
|
||||
if (server == NULL) {
|
||||
cifs_dbg(VFS, "%s: null TCP session\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
temp = mempool_alloc(&cifs_mid_pool, GFP_NOFS);
|
||||
memset(temp, 0, sizeof(struct mid_q_entry));
|
||||
refcount_set(&temp->refcount, 1);
|
||||
spin_lock_init(&temp->mid_lock);
|
||||
temp->mid = get_mid(smb_buffer);
|
||||
temp->pid = current->pid;
|
||||
temp->command = cpu_to_le16(smb_buffer->Command);
|
||||
cifs_dbg(FYI, "For smb_command %d\n", smb_buffer->Command);
|
||||
/* easier to use jiffies */
|
||||
/* when mid allocated can be before when sent */
|
||||
temp->when_alloc = jiffies;
|
||||
|
||||
/*
|
||||
* The default is for the mid to be synchronous, so the
|
||||
* default callback just wakes up the current task.
|
||||
*/
|
||||
get_task_struct(current);
|
||||
temp->creator = current;
|
||||
temp->callback = cifs_wake_up_task;
|
||||
temp->callback_data = current;
|
||||
|
||||
atomic_inc(&mid_count);
|
||||
temp->mid_state = MID_REQUEST_ALLOCATED;
|
||||
return temp;
|
||||
}
|
||||
|
||||
static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
|
||||
struct mid_q_entry **ppmidQ)
|
||||
{
|
||||
spin_lock(&ses->ses_lock);
|
||||
if (ses->ses_status == SES_NEW) {
|
||||
if ((in_buf->Command != SMB_COM_SESSION_SETUP_ANDX) &&
|
||||
(in_buf->Command != SMB_COM_NEGOTIATE)) {
|
||||
spin_unlock(&ses->ses_lock);
|
||||
return -EAGAIN;
|
||||
}
|
||||
/* else ok - we are setting up session */
|
||||
}
|
||||
|
||||
if (ses->ses_status == SES_EXITING) {
|
||||
/* check if SMB session is bad because we are setting it up */
|
||||
if (in_buf->Command != SMB_COM_LOGOFF_ANDX) {
|
||||
spin_unlock(&ses->ses_lock);
|
||||
return -EAGAIN;
|
||||
}
|
||||
/* else ok - we are shutting down session */
|
||||
}
|
||||
spin_unlock(&ses->ses_lock);
|
||||
|
||||
*ppmidQ = alloc_mid(in_buf, ses->server);
|
||||
if (*ppmidQ == NULL)
|
||||
return -ENOMEM;
|
||||
spin_lock(&ses->server->mid_queue_lock);
|
||||
list_add_tail(&(*ppmidQ)->qhead, &ses->server->pending_mid_q);
|
||||
spin_unlock(&ses->server->mid_queue_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct mid_q_entry *
|
||||
cifs_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *hdr = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
|
||||
struct mid_q_entry *mid;
|
||||
|
||||
/* enable signing if server requires it */
|
||||
if (server->sign)
|
||||
hdr->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
|
||||
|
||||
mid = alloc_mid(hdr, server);
|
||||
if (mid == NULL)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
rc = cifs_sign_rqst(rqst, server, &mid->sequence_number);
|
||||
if (rc) {
|
||||
release_mid(server, mid);
|
||||
return ERR_PTR(rc);
|
||||
}
|
||||
|
||||
return mid;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Send an SMB Request. No response info (other than return code)
|
||||
* needs to be parsed.
|
||||
*
|
||||
* flags indicate the type of request buffer and how long to wait
|
||||
* and whether to log NT STATUS code (error) before mapping it to POSIX error
|
||||
*
|
||||
*/
|
||||
int
|
||||
SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
|
||||
char *in_buf, unsigned int in_len, int flags)
|
||||
{
|
||||
int rc;
|
||||
struct kvec iov[1];
|
||||
struct kvec rsp_iov;
|
||||
int resp_buf_type;
|
||||
|
||||
iov[0].iov_base = in_buf;
|
||||
iov[0].iov_len = in_len;
|
||||
flags |= CIFS_NO_RSP_BUF;
|
||||
rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov);
|
||||
cifs_dbg(NOISY, "SendRcvNoRsp flags %d rc %d\n", flags, rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
|
||||
bool log_error)
|
||||
{
|
||||
unsigned int len = mid->response_pdu_len;
|
||||
|
||||
dump_smb(mid->resp_buf, min_t(u32, 92, len));
|
||||
|
||||
/* convert the length into a more usable form */
|
||||
if (server->sign) {
|
||||
struct kvec iov[1];
|
||||
int rc = 0;
|
||||
struct smb_rqst rqst = { .rq_iov = iov,
|
||||
.rq_nvec = ARRAY_SIZE(iov) };
|
||||
|
||||
iov[0].iov_base = mid->resp_buf;
|
||||
iov[0].iov_len = len;
|
||||
/* FIXME: add code to kill session */
|
||||
rc = cifs_verify_signature(&rqst, server,
|
||||
mid->sequence_number);
|
||||
if (rc)
|
||||
cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
|
||||
rc);
|
||||
}
|
||||
|
||||
/* BB special case reconnect tid and uid here? */
|
||||
return map_and_check_smb_error(server, mid, log_error);
|
||||
}
|
||||
|
||||
struct mid_q_entry *
|
||||
cifs_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *hdr = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
|
||||
struct mid_q_entry *mid;
|
||||
|
||||
rc = allocate_mid(ses, hdr, &mid);
|
||||
if (rc)
|
||||
return ERR_PTR(rc);
|
||||
rc = cifs_sign_rqst(rqst, server, &mid->sequence_number);
|
||||
if (rc) {
|
||||
delete_mid(server, mid);
|
||||
return ERR_PTR(rc);
|
||||
}
|
||||
return mid;
|
||||
}
|
||||
|
||||
int
|
||||
SendReceive2(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct kvec *iov, int n_vec, int *resp_buf_type /* ret */,
|
||||
const int flags, struct kvec *resp_iov)
|
||||
{
|
||||
struct smb_rqst rqst = {
|
||||
.rq_iov = iov,
|
||||
.rq_nvec = n_vec,
|
||||
};
|
||||
|
||||
return cifs_send_recv(xid, ses, ses->server,
|
||||
&rqst, resp_buf_type, flags, resp_iov);
|
||||
}
|
||||
|
||||
int
|
||||
SendReceive(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct smb_hdr *in_buf, unsigned int in_len,
|
||||
struct smb_hdr *out_buf, int *pbytes_returned, const int flags)
|
||||
{
|
||||
struct TCP_Server_Info *server;
|
||||
struct kvec resp_iov = {};
|
||||
struct kvec iov = { .iov_base = in_buf, .iov_len = in_len };
|
||||
struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
|
||||
int resp_buf_type;
|
||||
int rc = 0;
|
||||
|
||||
if (WARN_ON_ONCE(in_len > 0xffffff))
|
||||
return smb_EIO1(smb_eio_trace_tx_too_long, in_len);
|
||||
if (ses == NULL) {
|
||||
cifs_dbg(VFS, "Null smb session\n");
|
||||
return smb_EIO(smb_eio_trace_null_pointers);
|
||||
}
|
||||
server = ses->server;
|
||||
if (server == NULL) {
|
||||
cifs_dbg(VFS, "Null tcp session\n");
|
||||
return smb_EIO(smb_eio_trace_null_pointers);
|
||||
}
|
||||
|
||||
/* Ensure that we do not send more than 50 overlapping requests
|
||||
to the same server. We may make this configurable later or
|
||||
use ses->maxReq */
|
||||
|
||||
if (in_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
|
||||
cifs_server_dbg(VFS, "Invalid length, greater than maximum frame, %d\n",
|
||||
in_len);
|
||||
return smb_EIO1(smb_eio_trace_tx_too_long, in_len);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, ses->server,
|
||||
&rqst, &resp_buf_type, flags, &resp_iov);
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
|
||||
if (out_buf) {
|
||||
*pbytes_returned = resp_iov.iov_len;
|
||||
if (resp_iov.iov_len)
|
||||
memcpy(out_buf, resp_iov.iov_base, resp_iov.iov_len);
|
||||
}
|
||||
|
||||
out:
|
||||
free_rsp_buf(resp_buf_type, resp_iov.iov_base);
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -30,7 +30,8 @@
|
|||
typedef int (*compress_send_fn)(struct TCP_Server_Info *, int, struct smb_rqst *);
|
||||
|
||||
|
||||
int smb_compress(struct TCP_Server_Info *server, struct smb_rqst *rq, compress_send_fn send_fn);
|
||||
int smb_compress(struct TCP_Server_Info *server, struct smb_rqst *rq,
|
||||
compress_send_fn send_fn);
|
||||
bool should_compress(const struct cifs_tcon *tcon, const struct smb_rqst *rq);
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include <net/ipv6.h>
|
||||
#include <linux/parser.h>
|
||||
#include <linux/bvec.h>
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_unicode.h"
|
||||
|
|
@ -64,6 +63,10 @@ static int generic_ip_connect(struct TCP_Server_Info *server);
|
|||
static void tlink_rb_insert(struct rb_root *root, struct tcon_link *new_tlink);
|
||||
static void cifs_prune_tlinks(struct work_struct *work);
|
||||
|
||||
static struct mchan_mount *mchan_mount_alloc(struct cifs_ses *ses);
|
||||
static void mchan_mount_free(struct mchan_mount *mchan_mount);
|
||||
static void mchan_mount_work_fn(struct work_struct *work);
|
||||
|
||||
/*
|
||||
* Resolve hostname and set ip addr in tcp ses. Useful for hostnames that may
|
||||
* get their ip addresses changed at some point.
|
||||
|
|
@ -3463,115 +3466,6 @@ ip_connect(struct TCP_Server_Info *server)
|
|||
return generic_ip_connect(server);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
|
||||
void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
|
||||
{
|
||||
/*
|
||||
* If we are reconnecting then should we check to see if
|
||||
* any requested capabilities changed locally e.g. via
|
||||
* remount but we can not do much about it here
|
||||
* if they have (even if we could detect it by the following)
|
||||
* Perhaps we could add a backpointer to array of sb from tcon
|
||||
* or if we change to make all sb to same share the same
|
||||
* sb as NFS - then we only have one backpointer to sb.
|
||||
* What if we wanted to mount the server share twice once with
|
||||
* and once without posixacls or posix paths?
|
||||
*/
|
||||
__u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
|
||||
|
||||
if (ctx && ctx->no_linux_ext) {
|
||||
tcon->fsUnixInfo.Capability = 0;
|
||||
tcon->unix_ext = 0; /* Unix Extensions disabled */
|
||||
cifs_dbg(FYI, "Linux protocol extensions disabled\n");
|
||||
return;
|
||||
} else if (ctx)
|
||||
tcon->unix_ext = 1; /* Unix Extensions supported */
|
||||
|
||||
if (!tcon->unix_ext) {
|
||||
cifs_dbg(FYI, "Unix extensions disabled so not set on reconnect\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CIFSSMBQFSUnixInfo(xid, tcon)) {
|
||||
__u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
|
||||
|
||||
cifs_dbg(FYI, "unix caps which server supports %lld\n", cap);
|
||||
/*
|
||||
* check for reconnect case in which we do not
|
||||
* want to change the mount behavior if we can avoid it
|
||||
*/
|
||||
if (ctx == NULL) {
|
||||
/*
|
||||
* turn off POSIX ACL and PATHNAMES if not set
|
||||
* originally at mount time
|
||||
*/
|
||||
if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0)
|
||||
cap &= ~CIFS_UNIX_POSIX_ACL_CAP;
|
||||
if ((saved_cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0) {
|
||||
if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP)
|
||||
cifs_dbg(VFS, "POSIXPATH support change\n");
|
||||
cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
|
||||
} else if ((cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0) {
|
||||
cifs_dbg(VFS, "possible reconnect error\n");
|
||||
cifs_dbg(VFS, "server disabled POSIX path support\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (cap & CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP)
|
||||
cifs_dbg(VFS, "per-share encryption not supported yet\n");
|
||||
|
||||
cap &= CIFS_UNIX_CAP_MASK;
|
||||
if (ctx && ctx->no_psx_acl)
|
||||
cap &= ~CIFS_UNIX_POSIX_ACL_CAP;
|
||||
else if (CIFS_UNIX_POSIX_ACL_CAP & cap) {
|
||||
cifs_dbg(FYI, "negotiated posix acl support\n");
|
||||
if (cifs_sb)
|
||||
cifs_sb->mnt_cifs_flags |=
|
||||
CIFS_MOUNT_POSIXACL;
|
||||
}
|
||||
|
||||
if (ctx && ctx->posix_paths == 0)
|
||||
cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
|
||||
else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
|
||||
cifs_dbg(FYI, "negotiate posix pathnames\n");
|
||||
if (cifs_sb)
|
||||
cifs_sb->mnt_cifs_flags |=
|
||||
CIFS_MOUNT_POSIX_PATHS;
|
||||
}
|
||||
|
||||
cifs_dbg(FYI, "Negotiate caps 0x%x\n", (int)cap);
|
||||
#ifdef CONFIG_CIFS_DEBUG2
|
||||
if (cap & CIFS_UNIX_FCNTL_CAP)
|
||||
cifs_dbg(FYI, "FCNTL cap\n");
|
||||
if (cap & CIFS_UNIX_EXTATTR_CAP)
|
||||
cifs_dbg(FYI, "EXTATTR cap\n");
|
||||
if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP)
|
||||
cifs_dbg(FYI, "POSIX path cap\n");
|
||||
if (cap & CIFS_UNIX_XATTR_CAP)
|
||||
cifs_dbg(FYI, "XATTR cap\n");
|
||||
if (cap & CIFS_UNIX_POSIX_ACL_CAP)
|
||||
cifs_dbg(FYI, "POSIX ACL cap\n");
|
||||
if (cap & CIFS_UNIX_LARGE_READ_CAP)
|
||||
cifs_dbg(FYI, "very large read cap\n");
|
||||
if (cap & CIFS_UNIX_LARGE_WRITE_CAP)
|
||||
cifs_dbg(FYI, "very large write cap\n");
|
||||
if (cap & CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP)
|
||||
cifs_dbg(FYI, "transport encryption cap\n");
|
||||
if (cap & CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP)
|
||||
cifs_dbg(FYI, "mandatory transport encryption cap\n");
|
||||
#endif /* CIFS_DEBUG2 */
|
||||
if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) {
|
||||
if (ctx == NULL)
|
||||
cifs_dbg(FYI, "resetting capabilities failed\n");
|
||||
else
|
||||
cifs_dbg(VFS, "Negotiating Unix capabilities with the server failed. Consider mounting with the Unix Extensions disabled if problems are found by specifying the nounix mount option.\n");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
|
||||
|
||||
int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb)
|
||||
{
|
||||
struct smb3_fs_context *ctx = cifs_sb->ctx;
|
||||
|
|
@ -3899,15 +3793,64 @@ out:
|
|||
return rc;
|
||||
}
|
||||
|
||||
static struct mchan_mount *
|
||||
mchan_mount_alloc(struct cifs_ses *ses)
|
||||
{
|
||||
struct mchan_mount *mchan_mount;
|
||||
|
||||
mchan_mount = kzalloc(sizeof(*mchan_mount), GFP_KERNEL);
|
||||
if (!mchan_mount)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
INIT_WORK(&mchan_mount->work, mchan_mount_work_fn);
|
||||
|
||||
spin_lock(&cifs_tcp_ses_lock);
|
||||
cifs_smb_ses_inc_refcount(ses);
|
||||
spin_unlock(&cifs_tcp_ses_lock);
|
||||
mchan_mount->ses = ses;
|
||||
|
||||
return mchan_mount;
|
||||
}
|
||||
|
||||
static void
|
||||
mchan_mount_free(struct mchan_mount *mchan_mount)
|
||||
{
|
||||
cifs_put_smb_ses(mchan_mount->ses);
|
||||
kfree(mchan_mount);
|
||||
}
|
||||
|
||||
static void
|
||||
mchan_mount_work_fn(struct work_struct *work)
|
||||
{
|
||||
struct mchan_mount *mchan_mount = container_of(work, struct mchan_mount, work);
|
||||
|
||||
smb3_update_ses_channels(mchan_mount->ses,
|
||||
mchan_mount->ses->server,
|
||||
false /* from_reconnect */,
|
||||
false /* disable_mchan */);
|
||||
|
||||
mchan_mount_free(mchan_mount);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CIFS_DFS_UPCALL
|
||||
int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
|
||||
{
|
||||
struct cifs_mount_ctx mnt_ctx = { .cifs_sb = cifs_sb, .fs_ctx = ctx, };
|
||||
struct mchan_mount *mchan_mount = NULL;
|
||||
int rc;
|
||||
|
||||
rc = dfs_mount_share(&mnt_ctx);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
if (ctx->multichannel) {
|
||||
mchan_mount = mchan_mount_alloc(mnt_ctx.ses);
|
||||
if (IS_ERR(mchan_mount)) {
|
||||
rc = PTR_ERR(mchan_mount);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ctx->dfs_conn)
|
||||
goto out;
|
||||
|
||||
|
|
@ -3926,17 +3869,19 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
|
|||
ctx->prepath = NULL;
|
||||
|
||||
out:
|
||||
smb3_update_ses_channels(mnt_ctx.ses, mnt_ctx.server,
|
||||
false /* from_reconnect */,
|
||||
false /* disable_mchan */);
|
||||
rc = mount_setup_tlink(cifs_sb, mnt_ctx.ses, mnt_ctx.tcon);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
if (ctx->multichannel)
|
||||
queue_work(cifsiod_wq, &mchan_mount->work);
|
||||
|
||||
free_xid(mnt_ctx.xid);
|
||||
return rc;
|
||||
|
||||
error:
|
||||
if (ctx->multichannel && !IS_ERR_OR_NULL(mchan_mount))
|
||||
mchan_mount_free(mchan_mount);
|
||||
cifs_mount_put_conns(&mnt_ctx);
|
||||
return rc;
|
||||
}
|
||||
|
|
@ -3945,6 +3890,7 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
|
|||
{
|
||||
int rc = 0;
|
||||
struct cifs_mount_ctx mnt_ctx = { .cifs_sb = cifs_sb, .fs_ctx = ctx, };
|
||||
struct mchan_mount *mchan_mount = NULL;
|
||||
|
||||
rc = cifs_mount_get_session(&mnt_ctx);
|
||||
if (rc)
|
||||
|
|
@ -3972,161 +3918,32 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
|
|||
if (rc)
|
||||
goto error;
|
||||
|
||||
if (ctx->multichannel) {
|
||||
mchan_mount = mchan_mount_alloc(mnt_ctx.ses);
|
||||
if (IS_ERR(mchan_mount)) {
|
||||
rc = PTR_ERR(mchan_mount);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
rc = mount_setup_tlink(cifs_sb, mnt_ctx.ses, mnt_ctx.tcon);
|
||||
if (rc)
|
||||
goto error;
|
||||
|
||||
if (ctx->multichannel)
|
||||
queue_work(cifsiod_wq, &mchan_mount->work);
|
||||
|
||||
free_xid(mnt_ctx.xid);
|
||||
return rc;
|
||||
|
||||
error:
|
||||
if (ctx->multichannel && !IS_ERR_OR_NULL(mchan_mount))
|
||||
mchan_mount_free(mchan_mount);
|
||||
cifs_mount_put_conns(&mnt_ctx);
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
|
||||
/*
|
||||
* Issue a TREE_CONNECT request.
|
||||
*/
|
||||
int
|
||||
CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
|
||||
const char *tree, struct cifs_tcon *tcon,
|
||||
const struct nls_table *nls_codepage)
|
||||
{
|
||||
struct smb_hdr *smb_buffer;
|
||||
struct smb_hdr *smb_buffer_response;
|
||||
TCONX_REQ *pSMB;
|
||||
TCONX_RSP *pSMBr;
|
||||
unsigned char *bcc_ptr;
|
||||
int rc = 0;
|
||||
int length, in_len;
|
||||
__u16 bytes_left, count;
|
||||
|
||||
if (ses == NULL)
|
||||
return smb_EIO(smb_eio_trace_null_pointers);
|
||||
|
||||
smb_buffer = cifs_buf_get();
|
||||
if (smb_buffer == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
smb_buffer_response = smb_buffer;
|
||||
|
||||
in_len = header_assemble(smb_buffer, SMB_COM_TREE_CONNECT_ANDX,
|
||||
NULL /*no tid */, 4 /*wct */);
|
||||
|
||||
smb_buffer->Mid = get_next_mid(ses->server);
|
||||
smb_buffer->Uid = ses->Suid;
|
||||
pSMB = (TCONX_REQ *) smb_buffer;
|
||||
pSMBr = (TCONX_RSP *) smb_buffer_response;
|
||||
|
||||
pSMB->AndXCommand = 0xFF;
|
||||
pSMB->Flags = cpu_to_le16(TCON_EXTENDED_SECINFO);
|
||||
bcc_ptr = &pSMB->Password[0];
|
||||
|
||||
pSMB->PasswordLength = cpu_to_le16(1); /* minimum */
|
||||
*bcc_ptr = 0; /* password is null byte */
|
||||
bcc_ptr++; /* skip password */
|
||||
/* already aligned so no need to do it below */
|
||||
|
||||
if (ses->server->sign)
|
||||
smb_buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
|
||||
|
||||
if (ses->capabilities & CAP_STATUS32)
|
||||
smb_buffer->Flags2 |= SMBFLG2_ERR_STATUS;
|
||||
|
||||
if (ses->capabilities & CAP_DFS)
|
||||
smb_buffer->Flags2 |= SMBFLG2_DFS;
|
||||
|
||||
if (ses->capabilities & CAP_UNICODE) {
|
||||
smb_buffer->Flags2 |= SMBFLG2_UNICODE;
|
||||
length =
|
||||
cifs_strtoUTF16((__le16 *) bcc_ptr, tree,
|
||||
6 /* max utf8 char length in bytes */ *
|
||||
(/* server len*/ + 256 /* share len */), nls_codepage);
|
||||
bcc_ptr += 2 * length; /* convert num 16 bit words to bytes */
|
||||
bcc_ptr += 2; /* skip trailing null */
|
||||
} else { /* ASCII */
|
||||
strcpy(bcc_ptr, tree);
|
||||
bcc_ptr += strlen(tree) + 1;
|
||||
}
|
||||
strcpy(bcc_ptr, "?????");
|
||||
bcc_ptr += strlen("?????");
|
||||
bcc_ptr += 1;
|
||||
count = bcc_ptr - &pSMB->Password[0];
|
||||
in_len += count;
|
||||
pSMB->ByteCount = cpu_to_le16(count);
|
||||
|
||||
rc = SendReceive(xid, ses, smb_buffer, in_len, smb_buffer_response,
|
||||
&length, 0);
|
||||
|
||||
/* above now done in SendReceive */
|
||||
if (rc == 0) {
|
||||
bool is_unicode;
|
||||
|
||||
tcon->tid = smb_buffer_response->Tid;
|
||||
bcc_ptr = pByteArea(smb_buffer_response);
|
||||
bytes_left = get_bcc(smb_buffer_response);
|
||||
length = strnlen(bcc_ptr, bytes_left - 2);
|
||||
if (smb_buffer->Flags2 & SMBFLG2_UNICODE)
|
||||
is_unicode = true;
|
||||
else
|
||||
is_unicode = false;
|
||||
|
||||
|
||||
/* skip service field (NB: this field is always ASCII) */
|
||||
if (length == 3) {
|
||||
if ((bcc_ptr[0] == 'I') && (bcc_ptr[1] == 'P') &&
|
||||
(bcc_ptr[2] == 'C')) {
|
||||
cifs_dbg(FYI, "IPC connection\n");
|
||||
tcon->ipc = true;
|
||||
tcon->pipe = true;
|
||||
}
|
||||
} else if (length == 2) {
|
||||
if ((bcc_ptr[0] == 'A') && (bcc_ptr[1] == ':')) {
|
||||
/* the most common case */
|
||||
cifs_dbg(FYI, "disk share connection\n");
|
||||
}
|
||||
}
|
||||
bcc_ptr += length + 1;
|
||||
bytes_left -= (length + 1);
|
||||
strscpy(tcon->tree_name, tree, sizeof(tcon->tree_name));
|
||||
|
||||
/* mostly informational -- no need to fail on error here */
|
||||
kfree(tcon->nativeFileSystem);
|
||||
tcon->nativeFileSystem = cifs_strndup_from_utf16(bcc_ptr,
|
||||
bytes_left, is_unicode,
|
||||
nls_codepage);
|
||||
|
||||
cifs_dbg(FYI, "nativeFileSystem=%s\n", tcon->nativeFileSystem);
|
||||
|
||||
if ((smb_buffer_response->WordCount == 3) ||
|
||||
(smb_buffer_response->WordCount == 7))
|
||||
/* field is in same location */
|
||||
tcon->Flags = le16_to_cpu(pSMBr->OptionalSupport);
|
||||
else
|
||||
tcon->Flags = 0;
|
||||
cifs_dbg(FYI, "Tcon flags: 0x%x\n", tcon->Flags);
|
||||
|
||||
/*
|
||||
* reset_cifs_unix_caps calls QFSInfo which requires
|
||||
* need_reconnect to be false, but we would not need to call
|
||||
* reset_caps if this were not a reconnect case so must check
|
||||
* need_reconnect flag here. The caller will also clear
|
||||
* need_reconnect when tcon was successful but needed to be
|
||||
* cleared earlier in the case of unix extensions reconnect
|
||||
*/
|
||||
if (tcon->need_reconnect && tcon->unix_ext) {
|
||||
cifs_dbg(FYI, "resetting caps for %s\n", tcon->tree_name);
|
||||
tcon->need_reconnect = false;
|
||||
reset_cifs_unix_caps(xid, tcon, NULL, NULL);
|
||||
}
|
||||
}
|
||||
cifs_buf_release(smb_buffer);
|
||||
return rc;
|
||||
}
|
||||
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
|
||||
|
||||
static void delayed_free(struct rcu_head *p)
|
||||
{
|
||||
struct cifs_sb_info *cifs_sb = container_of(p, struct cifs_sb_info, rcu);
|
||||
|
|
@ -4270,7 +4087,9 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
|
|||
ses->ses_status = SES_IN_SETUP;
|
||||
|
||||
/* force iface_list refresh */
|
||||
spin_lock(&ses->iface_lock);
|
||||
ses->iface_last_update = 0;
|
||||
spin_unlock(&ses->iface_lock);
|
||||
}
|
||||
spin_unlock(&ses->ses_lock);
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,8 @@ static inline void ref_walk_mark_end(struct dfs_ref_walk *rw)
|
|||
ref->tit = ERR_PTR(-ENOENT); /* end marker */
|
||||
}
|
||||
|
||||
int dfs_parse_target_referral(const char *full_path, const struct dfs_info3_param *ref,
|
||||
int dfs_parse_target_referral(const char *full_path,
|
||||
const struct dfs_info3_param *ref,
|
||||
struct smb3_fs_context *ctx);
|
||||
int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,17 +37,22 @@ int dfs_cache_init(void);
|
|||
void dfs_cache_destroy(void);
|
||||
extern const struct proc_ops dfscache_proc_ops;
|
||||
|
||||
int dfs_cache_find(const unsigned int xid, struct cifs_ses *ses, const struct nls_table *cp,
|
||||
int remap, const char *path, struct dfs_info3_param *ref,
|
||||
int dfs_cache_find(const unsigned int xid, struct cifs_ses *ses,
|
||||
const struct nls_table *cp, int remap, const char *path,
|
||||
struct dfs_info3_param *ref,
|
||||
struct dfs_cache_tgt_list *tgt_list);
|
||||
int dfs_cache_noreq_find(const char *path, struct dfs_info3_param *ref,
|
||||
struct dfs_cache_tgt_list *tgt_list);
|
||||
void dfs_cache_noreq_update_tgthint(const char *path, const struct dfs_cache_tgt_iterator *it);
|
||||
int dfs_cache_get_tgt_referral(const char *path, const struct dfs_cache_tgt_iterator *it,
|
||||
void dfs_cache_noreq_update_tgthint(const char *path,
|
||||
const struct dfs_cache_tgt_iterator *it);
|
||||
int dfs_cache_get_tgt_referral(const char *path,
|
||||
const struct dfs_cache_tgt_iterator *it,
|
||||
struct dfs_info3_param *ref);
|
||||
int dfs_cache_get_tgt_share(char *path, const struct dfs_cache_tgt_iterator *it, char **share,
|
||||
char **prefix);
|
||||
char *dfs_cache_canonical_path(const char *path, const struct nls_table *cp, int remap);
|
||||
int dfs_cache_get_tgt_share(char *path,
|
||||
const struct dfs_cache_tgt_iterator *it,
|
||||
char **share, char **prefix);
|
||||
char *dfs_cache_canonical_path(const char *path, const struct nls_table *cp,
|
||||
int remap);
|
||||
int dfs_cache_remount_fs(struct cifs_sb_info *cifs_sb);
|
||||
void dfs_cache_refresh(struct work_struct *work);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#include <linux/mount.h>
|
||||
#include <linux/file.h>
|
||||
#include "cifsfs.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_debug.h"
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
|
||||
int dns_resolve_name(const char *dom, const char *name,
|
||||
size_t namelen, struct sockaddr *ip_addr);
|
||||
int dns_resolve_name(const char *dom, const char *name, size_t namelen,
|
||||
struct sockaddr *ip_addr);
|
||||
|
||||
static inline int dns_resolve_unc(const char *dom, const char *unc,
|
||||
struct sockaddr *ip_addr)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
#include <linux/mm.h>
|
||||
#include <asm/div64.h>
|
||||
#include "cifsfs.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "smb2proto.h"
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <linux/parser.h>
|
||||
#include <linux/utsname.h>
|
||||
#include "cifsfs.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_unicode.h"
|
||||
|
|
|
|||
|
|
@ -361,18 +361,20 @@ static inline enum cifs_symlink_type cifs_symlink_type(struct cifs_sb_info *cifs
|
|||
return CIFS_SYMLINK_TYPE_NONE;
|
||||
}
|
||||
|
||||
extern int smb3_init_fs_context(struct fs_context *fc);
|
||||
extern void smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx);
|
||||
extern void smb3_cleanup_fs_context(struct smb3_fs_context *ctx);
|
||||
int smb3_init_fs_context(struct fs_context *fc);
|
||||
void smb3_cleanup_fs_context_contents(struct smb3_fs_context *ctx);
|
||||
void smb3_cleanup_fs_context(struct smb3_fs_context *ctx);
|
||||
|
||||
static inline struct smb3_fs_context *smb3_fc2context(const struct fs_context *fc)
|
||||
{
|
||||
return fc->fs_private;
|
||||
}
|
||||
|
||||
extern int smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx);
|
||||
extern int smb3_sync_session_ctx_passwords(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses);
|
||||
extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
|
||||
int smb3_fs_context_dup(struct smb3_fs_context *new_ctx,
|
||||
struct smb3_fs_context *ctx);
|
||||
int smb3_sync_session_ctx_passwords(struct cifs_sb_info *cifs_sb,
|
||||
struct cifs_ses *ses);
|
||||
void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
|
||||
|
||||
/*
|
||||
* max deferred close timeout (jiffies) - 2^30
|
||||
|
|
@ -380,7 +382,7 @@ extern void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb);
|
|||
#define SMB3_MAX_DCLOSETIMEO (1 << 30)
|
||||
#define SMB3_DEF_DCLOSETIMEO (1 * HZ) /* even 1 sec enough to help eg open/write/close/open/read */
|
||||
#define MAX_CACHED_FIDS 16
|
||||
extern char *cifs_sanitize_prepath(char *prepath, gfp_t gfp);
|
||||
char *cifs_sanitize_prepath(char *prepath, gfp_t gfp);
|
||||
|
||||
extern struct mutex cifs_mount_mutex;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,12 +38,17 @@ struct cifs_fscache_inode_coherency_data {
|
|||
/*
|
||||
* fscache.c
|
||||
*/
|
||||
extern int cifs_fscache_get_super_cookie(struct cifs_tcon *);
|
||||
extern void cifs_fscache_release_super_cookie(struct cifs_tcon *);
|
||||
int cifs_fscache_get_super_cookie(struct cifs_tcon *tcon);
|
||||
void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon);
|
||||
void cifs_fscache_get_inode_cookie(struct inode *inode);
|
||||
void cifs_fscache_unuse_inode_cookie(struct inode *inode, bool update);
|
||||
void cifs_fscache_release_inode_cookie(struct inode *inode);
|
||||
int cifs_fscache_get_super_cookie(struct cifs_tcon *tcon);
|
||||
void cifs_fscache_release_super_cookie(struct cifs_tcon *tcon);
|
||||
|
||||
extern void cifs_fscache_get_inode_cookie(struct inode *inode);
|
||||
extern void cifs_fscache_release_inode_cookie(struct inode *);
|
||||
extern void cifs_fscache_unuse_inode_cookie(struct inode *inode, bool update);
|
||||
void cifs_fscache_get_inode_cookie(struct inode *inode);
|
||||
void cifs_fscache_release_inode_cookie(struct inode *inode);
|
||||
void cifs_fscache_unuse_inode_cookie(struct inode *inode, bool update);
|
||||
|
||||
static inline
|
||||
void cifs_fscache_fill_coherency(struct inode *inode,
|
||||
|
|
|
|||
86
fs/smb/client/gen_smb2_mapping
Normal file
86
fs/smb/client/gen_smb2_mapping
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#!/usr/bin/perl -w
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#
|
||||
# Generate an SMB2 status -> error mapping table,
|
||||
# sorted by NT status code (cpu-endian, ascending).
|
||||
#
|
||||
# Copyright (C) 2025 Red Hat, Inc. All Rights Reserved.
|
||||
# Written by David Howells (dhowells@redhat.com)
|
||||
#
|
||||
use strict;
|
||||
|
||||
if ($#ARGV != 1) {
|
||||
print STDERR "Format: ", $0, " <in-h-file> <out-c-file>\n";
|
||||
exit(2);
|
||||
}
|
||||
|
||||
my %statuses = ();
|
||||
my @list = ();
|
||||
|
||||
#
|
||||
# Read the file
|
||||
#
|
||||
open IN_FILE, "<$ARGV[0]" || die;
|
||||
while (<IN_FILE>) {
|
||||
chomp;
|
||||
|
||||
if (m!^#define\s*([A-Za-z0-9_]+)\s+cpu_to_le32[(]([0-9a-fA-Fx]+)[)]\s+//\s+([-A-Z0-9_]+)!) {
|
||||
my $status = $1;
|
||||
my $code = $2;
|
||||
my $ncode = hex($2);
|
||||
my $error = $3;
|
||||
my $s;
|
||||
|
||||
next if ($status =~ /^STATUS_SEVERITY/);
|
||||
|
||||
die "Duplicate status $status"
|
||||
if exists($statuses{$status});
|
||||
|
||||
my %s = (
|
||||
status => $status,
|
||||
code => $code,
|
||||
ncode => $ncode,
|
||||
error => $error
|
||||
);
|
||||
$statuses{$status} = \%s;
|
||||
push @list, \%s;
|
||||
}
|
||||
}
|
||||
close IN_FILE || die;
|
||||
|
||||
|
||||
@list = sort( { $a->{ncode} <=> $b->{ncode} } @list);
|
||||
|
||||
open OUT_FILE, ">$ARGV[1]" || die;
|
||||
my $list_size = scalar @list;
|
||||
my $full_status = "";
|
||||
for (my $i = 0; $i < $list_size; $i++) {
|
||||
my $entry = $list[$i];
|
||||
my $status = $entry->{status};
|
||||
my $code = $entry->{code};
|
||||
my $ncode = $entry->{ncode};
|
||||
my $error = $entry->{error};
|
||||
|
||||
next if ($ncode == 0);
|
||||
|
||||
$full_status .= $status;
|
||||
# There may be synonyms
|
||||
if ($i < $list_size - 1) {
|
||||
my $next_entry = $list[$i + 1];
|
||||
my $next_ncode = $next_entry->{ncode};
|
||||
if ($next_ncode == $ncode) {
|
||||
$full_status .= " or ";
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
my $pad = " ";
|
||||
if (length($full_status) < 40) {
|
||||
my $n = 40 - length($full_status);
|
||||
$pad = "\t" x ((($n-1) / 8) + 1);
|
||||
}
|
||||
print(OUT_FILE "{ $code, $error, \"$full_status\" },\n");
|
||||
|
||||
$full_status = "";
|
||||
}
|
||||
close OUT_FILE || die;
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
#include <linux/fiemap.h>
|
||||
#include <asm/div64.h>
|
||||
#include "cifsfs.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "smb2proto.h"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
#include <linux/mount.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/pagemap.h>
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_debug.h"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include <linux/slab.h>
|
||||
#include <linux/namei.h>
|
||||
#include "cifsfs.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_debug.h"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include <linux/ctype.h>
|
||||
#include <linux/mempool.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_debug.h"
|
||||
|
|
@ -19,6 +18,7 @@
|
|||
#include "cifs_unicode.h"
|
||||
#include "smb2pdu.h"
|
||||
#include "smb2proto.h"
|
||||
#include "smb1proto.h"
|
||||
#include "cifsfs.h"
|
||||
#ifdef CONFIG_CIFS_DFS_UPCALL
|
||||
#include "dns_resolve.h"
|
||||
|
|
@ -178,10 +178,10 @@ tconInfoFree(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace)
|
|||
kfree(tcon);
|
||||
}
|
||||
|
||||
struct smb_hdr *
|
||||
void *
|
||||
cifs_buf_get(void)
|
||||
{
|
||||
struct smb_hdr *ret_buf = NULL;
|
||||
void *ret_buf = NULL;
|
||||
/*
|
||||
* SMB2 header is bigger than CIFS one - no problems to clean some
|
||||
* more bytes for CIFS.
|
||||
|
|
@ -220,10 +220,10 @@ cifs_buf_release(void *buf_to_free)
|
|||
return;
|
||||
}
|
||||
|
||||
struct smb_hdr *
|
||||
void *
|
||||
cifs_small_buf_get(void)
|
||||
{
|
||||
struct smb_hdr *ret_buf = NULL;
|
||||
void *ret_buf = NULL;
|
||||
|
||||
/* We could use negotiated size instead of max_msgsize -
|
||||
but it may be more efficient to always alloc same size
|
||||
|
|
@ -231,7 +231,6 @@ cifs_small_buf_get(void)
|
|||
defaults to this and can not be bigger */
|
||||
ret_buf = mempool_alloc(cifs_sm_req_poolp, GFP_NOFS);
|
||||
/* No need to clear memory here, cleared in header assemble */
|
||||
/* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
|
||||
atomic_inc(&small_buf_alloc_count);
|
||||
#ifdef CONFIG_CIFS_STATS2
|
||||
atomic_inc(&total_small_buf_alloc_count);
|
||||
|
|
@ -263,297 +262,6 @@ free_rsp_buf(int resp_buftype, void *rsp)
|
|||
cifs_buf_release(rsp);
|
||||
}
|
||||
|
||||
/* NB: MID can not be set if treeCon not passed in, in that
|
||||
case it is responsibility of caller to set the mid */
|
||||
unsigned int
|
||||
header_assemble(struct smb_hdr *buffer, char smb_command,
|
||||
const struct cifs_tcon *treeCon, int word_count
|
||||
/* length of fixed section (word count) in two byte units */)
|
||||
{
|
||||
unsigned int in_len;
|
||||
char *temp = (char *) buffer;
|
||||
|
||||
memset(temp, 0, 256); /* bigger than MAX_CIFS_HDR_SIZE */
|
||||
|
||||
in_len = (2 * word_count) + sizeof(struct smb_hdr) +
|
||||
2 /* for bcc field itself */;
|
||||
|
||||
buffer->Protocol[0] = 0xFF;
|
||||
buffer->Protocol[1] = 'S';
|
||||
buffer->Protocol[2] = 'M';
|
||||
buffer->Protocol[3] = 'B';
|
||||
buffer->Command = smb_command;
|
||||
buffer->Flags = 0x00; /* case sensitive */
|
||||
buffer->Flags2 = SMBFLG2_KNOWS_LONG_NAMES;
|
||||
buffer->Pid = cpu_to_le16((__u16)current->tgid);
|
||||
buffer->PidHigh = cpu_to_le16((__u16)(current->tgid >> 16));
|
||||
if (treeCon) {
|
||||
buffer->Tid = treeCon->tid;
|
||||
if (treeCon->ses) {
|
||||
if (treeCon->ses->capabilities & CAP_UNICODE)
|
||||
buffer->Flags2 |= SMBFLG2_UNICODE;
|
||||
if (treeCon->ses->capabilities & CAP_STATUS32)
|
||||
buffer->Flags2 |= SMBFLG2_ERR_STATUS;
|
||||
|
||||
/* Uid is not converted */
|
||||
buffer->Uid = treeCon->ses->Suid;
|
||||
if (treeCon->ses->server)
|
||||
buffer->Mid = get_next_mid(treeCon->ses->server);
|
||||
}
|
||||
if (treeCon->Flags & SMB_SHARE_IS_IN_DFS)
|
||||
buffer->Flags2 |= SMBFLG2_DFS;
|
||||
if (treeCon->nocase)
|
||||
buffer->Flags |= SMBFLG_CASELESS;
|
||||
if ((treeCon->ses) && (treeCon->ses->server))
|
||||
if (treeCon->ses->server->sign)
|
||||
buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
|
||||
}
|
||||
|
||||
/* endian conversion of flags is now done just before sending */
|
||||
buffer->WordCount = (char) word_count;
|
||||
return in_len;
|
||||
}
|
||||
|
||||
static int
|
||||
check_smb_hdr(struct smb_hdr *smb)
|
||||
{
|
||||
/* does it have the right SMB "signature" ? */
|
||||
if (*(__le32 *) smb->Protocol != SMB1_PROTO_NUMBER) {
|
||||
cifs_dbg(VFS, "Bad protocol string signature header 0x%x\n",
|
||||
*(unsigned int *)smb->Protocol);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* if it's a response then accept */
|
||||
if (smb->Flags & SMBFLG_RESPONSE)
|
||||
return 0;
|
||||
|
||||
/* only one valid case where server sends us request */
|
||||
if (smb->Command == SMB_COM_LOCKING_ANDX)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Windows NT server returns error resposne (e.g. STATUS_DELETE_PENDING
|
||||
* or STATUS_OBJECT_NAME_NOT_FOUND or ERRDOS/ERRbadfile or any other)
|
||||
* for some TRANS2 requests without the RESPONSE flag set in header.
|
||||
*/
|
||||
if (smb->Command == SMB_COM_TRANSACTION2 && smb->Status.CifsError != 0)
|
||||
return 0;
|
||||
|
||||
cifs_dbg(VFS, "Server sent request, not response. mid=%u\n",
|
||||
get_mid(smb));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
checkSMB(char *buf, unsigned int pdu_len, unsigned int total_read,
|
||||
struct TCP_Server_Info *server)
|
||||
{
|
||||
struct smb_hdr *smb = (struct smb_hdr *)buf;
|
||||
__u32 rfclen = pdu_len;
|
||||
__u32 clc_len; /* calculated length */
|
||||
cifs_dbg(FYI, "checkSMB Length: 0x%x, smb_buf_length: 0x%x\n",
|
||||
total_read, rfclen);
|
||||
|
||||
/* is this frame too small to even get to a BCC? */
|
||||
if (total_read < 2 + sizeof(struct smb_hdr)) {
|
||||
if ((total_read >= sizeof(struct smb_hdr) - 1)
|
||||
&& (smb->Status.CifsError != 0)) {
|
||||
/* it's an error return */
|
||||
smb->WordCount = 0;
|
||||
/* some error cases do not return wct and bcc */
|
||||
return 0;
|
||||
} else if ((total_read == sizeof(struct smb_hdr) + 1) &&
|
||||
(smb->WordCount == 0)) {
|
||||
char *tmp = (char *)smb;
|
||||
/* Need to work around a bug in two servers here */
|
||||
/* First, check if the part of bcc they sent was zero */
|
||||
if (tmp[sizeof(struct smb_hdr)] == 0) {
|
||||
/* some servers return only half of bcc
|
||||
* on simple responses (wct, bcc both zero)
|
||||
* in particular have seen this on
|
||||
* ulogoffX and FindClose. This leaves
|
||||
* one byte of bcc potentially uninitialized
|
||||
*/
|
||||
/* zero rest of bcc */
|
||||
tmp[sizeof(struct smb_hdr)+1] = 0;
|
||||
return 0;
|
||||
}
|
||||
cifs_dbg(VFS, "rcvd invalid byte count (bcc)\n");
|
||||
return smb_EIO1(smb_eio_trace_rx_inv_bcc, tmp[sizeof(struct smb_hdr)]);
|
||||
} else {
|
||||
cifs_dbg(VFS, "Length less than smb header size\n");
|
||||
return smb_EIO2(smb_eio_trace_rx_too_short,
|
||||
total_read, smb->WordCount);
|
||||
}
|
||||
} else if (total_read < sizeof(*smb) + 2 * smb->WordCount) {
|
||||
cifs_dbg(VFS, "%s: can't read BCC due to invalid WordCount(%u)\n",
|
||||
__func__, smb->WordCount);
|
||||
return smb_EIO2(smb_eio_trace_rx_check_rsp,
|
||||
total_read, 2 + sizeof(struct smb_hdr));
|
||||
}
|
||||
|
||||
/* otherwise, there is enough to get to the BCC */
|
||||
if (check_smb_hdr(smb))
|
||||
return smb_EIO1(smb_eio_trace_rx_rfc1002_magic, *(u32 *)smb->Protocol);
|
||||
clc_len = smbCalcSize(smb);
|
||||
|
||||
if (rfclen != total_read) {
|
||||
cifs_dbg(VFS, "Length read does not match RFC1001 length %d/%d\n",
|
||||
rfclen, total_read);
|
||||
return smb_EIO2(smb_eio_trace_rx_check_rsp,
|
||||
total_read, rfclen);
|
||||
}
|
||||
|
||||
if (rfclen != clc_len) {
|
||||
__u16 mid = get_mid(smb);
|
||||
/* check if bcc wrapped around for large read responses */
|
||||
if ((rfclen > 64 * 1024) && (rfclen > clc_len)) {
|
||||
/* check if lengths match mod 64K */
|
||||
if (((rfclen) & 0xFFFF) == (clc_len & 0xFFFF))
|
||||
return 0; /* bcc wrapped */
|
||||
}
|
||||
cifs_dbg(FYI, "Calculated size %u vs length %u mismatch for mid=%u\n",
|
||||
clc_len, rfclen, mid);
|
||||
|
||||
if (rfclen < clc_len) {
|
||||
cifs_dbg(VFS, "RFC1001 size %u smaller than SMB for mid=%u\n",
|
||||
rfclen, mid);
|
||||
return smb_EIO2(smb_eio_trace_rx_calc_len_too_big,
|
||||
rfclen, clc_len);
|
||||
} else if (rfclen > clc_len + 512) {
|
||||
/*
|
||||
* Some servers (Windows XP in particular) send more
|
||||
* data than the lengths in the SMB packet would
|
||||
* indicate on certain calls (byte range locks and
|
||||
* trans2 find first calls in particular). While the
|
||||
* client can handle such a frame by ignoring the
|
||||
* trailing data, we choose limit the amount of extra
|
||||
* data to 512 bytes.
|
||||
*/
|
||||
cifs_dbg(VFS, "RFC1001 size %u more than 512 bytes larger than SMB for mid=%u\n",
|
||||
rfclen, mid);
|
||||
return smb_EIO2(smb_eio_trace_rx_overlong,
|
||||
rfclen, clc_len + 512);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv)
|
||||
{
|
||||
struct smb_hdr *buf = (struct smb_hdr *)buffer;
|
||||
struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf;
|
||||
struct TCP_Server_Info *pserver;
|
||||
struct cifs_ses *ses;
|
||||
struct cifs_tcon *tcon;
|
||||
struct cifsInodeInfo *pCifsInode;
|
||||
struct cifsFileInfo *netfile;
|
||||
|
||||
cifs_dbg(FYI, "Checking for oplock break or dnotify response\n");
|
||||
if ((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) &&
|
||||
(pSMB->hdr.Flags & SMBFLG_RESPONSE)) {
|
||||
struct smb_com_transaction_change_notify_rsp *pSMBr =
|
||||
(struct smb_com_transaction_change_notify_rsp *)buf;
|
||||
struct file_notify_information *pnotify;
|
||||
__u32 data_offset = 0;
|
||||
size_t len = srv->total_read - srv->pdu_size;
|
||||
|
||||
if (get_bcc(buf) > sizeof(struct file_notify_information)) {
|
||||
data_offset = le32_to_cpu(pSMBr->DataOffset);
|
||||
|
||||
if (data_offset >
|
||||
len - sizeof(struct file_notify_information)) {
|
||||
cifs_dbg(FYI, "Invalid data_offset %u\n",
|
||||
data_offset);
|
||||
return true;
|
||||
}
|
||||
pnotify = (struct file_notify_information *)
|
||||
((char *)&pSMBr->hdr.Protocol + data_offset);
|
||||
cifs_dbg(FYI, "dnotify on %s Action: 0x%x\n",
|
||||
pnotify->FileName, pnotify->Action);
|
||||
/* cifs_dump_mem("Rcvd notify Data: ",buf,
|
||||
sizeof(struct smb_hdr)+60); */
|
||||
return true;
|
||||
}
|
||||
if (pSMBr->hdr.Status.CifsError) {
|
||||
cifs_dbg(FYI, "notify err 0x%x\n",
|
||||
pSMBr->hdr.Status.CifsError);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX)
|
||||
return false;
|
||||
if (pSMB->hdr.Flags & SMBFLG_RESPONSE) {
|
||||
/* no sense logging error on invalid handle on oplock
|
||||
break - harmless race between close request and oplock
|
||||
break response is expected from time to time writing out
|
||||
large dirty files cached on the client */
|
||||
if ((NT_STATUS_INVALID_HANDLE) ==
|
||||
le32_to_cpu(pSMB->hdr.Status.CifsError)) {
|
||||
cifs_dbg(FYI, "Invalid handle on oplock break\n");
|
||||
return true;
|
||||
} else if (ERRbadfid ==
|
||||
le16_to_cpu(pSMB->hdr.Status.DosError.Error)) {
|
||||
return true;
|
||||
} else {
|
||||
return false; /* on valid oplock brk we get "request" */
|
||||
}
|
||||
}
|
||||
if (pSMB->hdr.WordCount != 8)
|
||||
return false;
|
||||
|
||||
cifs_dbg(FYI, "oplock type 0x%x level 0x%x\n",
|
||||
pSMB->LockType, pSMB->OplockLevel);
|
||||
if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE))
|
||||
return false;
|
||||
|
||||
/* If server is a channel, select the primary channel */
|
||||
pserver = SERVER_IS_CHAN(srv) ? srv->primary_server : srv;
|
||||
|
||||
/* look up tcon based on tid & uid */
|
||||
spin_lock(&cifs_tcp_ses_lock);
|
||||
list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) {
|
||||
if (cifs_ses_exiting(ses))
|
||||
continue;
|
||||
list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
|
||||
if (tcon->tid != buf->Tid)
|
||||
continue;
|
||||
|
||||
cifs_stats_inc(&tcon->stats.cifs_stats.num_oplock_brks);
|
||||
spin_lock(&tcon->open_file_lock);
|
||||
list_for_each_entry(netfile, &tcon->openFileList, tlist) {
|
||||
if (pSMB->Fid != netfile->fid.netfid)
|
||||
continue;
|
||||
|
||||
cifs_dbg(FYI, "file id match, oplock break\n");
|
||||
pCifsInode = CIFS_I(d_inode(netfile->dentry));
|
||||
|
||||
set_bit(CIFS_INODE_PENDING_OPLOCK_BREAK,
|
||||
&pCifsInode->flags);
|
||||
|
||||
netfile->oplock_epoch = 0;
|
||||
netfile->oplock_level = pSMB->OplockLevel;
|
||||
netfile->oplock_break_cancelled = false;
|
||||
cifs_queue_oplock_break(netfile);
|
||||
|
||||
spin_unlock(&tcon->open_file_lock);
|
||||
spin_unlock(&cifs_tcp_ses_lock);
|
||||
return true;
|
||||
}
|
||||
spin_unlock(&tcon->open_file_lock);
|
||||
spin_unlock(&cifs_tcp_ses_lock);
|
||||
cifs_dbg(FYI, "No matching file for oplock break\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
spin_unlock(&cifs_tcp_ses_lock);
|
||||
cifs_dbg(FYI, "Can not process oplock break for non-existent connection\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
dump_smb(void *buf, int smb_buf_length)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
extern struct genl_family cifs_genl_family;
|
||||
|
||||
extern int cifs_genl_init(void);
|
||||
extern void cifs_genl_exit(void);
|
||||
int cifs_genl_init(void);
|
||||
void cifs_genl_exit(void);
|
||||
|
||||
#endif /* _CIFS_NETLINK_H */
|
||||
|
|
|
|||
|
|
@ -17,105 +17,13 @@
|
|||
#include <asm/byteorder.h>
|
||||
#include <linux/inet.h>
|
||||
#include "cifsfs.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "smb1proto.h"
|
||||
#include "smberr.h"
|
||||
#include "cifs_debug.h"
|
||||
#include "nterr.h"
|
||||
|
||||
struct smb_to_posix_error {
|
||||
__u16 smb_err;
|
||||
int posix_code;
|
||||
};
|
||||
|
||||
static const struct smb_to_posix_error mapping_table_ERRDOS[] = {
|
||||
{ERRbadfunc, -EINVAL},
|
||||
{ERRbadfile, -ENOENT},
|
||||
{ERRbadpath, -ENOTDIR},
|
||||
{ERRnofids, -EMFILE},
|
||||
{ERRnoaccess, -EACCES},
|
||||
{ERRbadfid, -EBADF},
|
||||
{ERRbadmcb, -EIO},
|
||||
{ERRnomem, -EREMOTEIO},
|
||||
{ERRbadmem, -EFAULT},
|
||||
{ERRbadenv, -EFAULT},
|
||||
{ERRbadformat, -EINVAL},
|
||||
{ERRbadaccess, -EACCES},
|
||||
{ERRbaddata, -EIO},
|
||||
{ERRbaddrive, -ENXIO},
|
||||
{ERRremcd, -EACCES},
|
||||
{ERRdiffdevice, -EXDEV},
|
||||
{ERRnofiles, -ENOENT},
|
||||
{ERRwriteprot, -EROFS},
|
||||
{ERRbadshare, -EBUSY},
|
||||
{ERRlock, -EACCES},
|
||||
{ERRunsup, -EINVAL},
|
||||
{ERRnosuchshare, -ENXIO},
|
||||
{ERRfilexists, -EEXIST},
|
||||
{ERRinvparm, -EINVAL},
|
||||
{ERRdiskfull, -ENOSPC},
|
||||
{ERRinvname, -ENOENT},
|
||||
{ERRinvlevel, -EOPNOTSUPP},
|
||||
{ERRdirnotempty, -ENOTEMPTY},
|
||||
{ERRnotlocked, -ENOLCK},
|
||||
{ERRcancelviolation, -ENOLCK},
|
||||
{ERRalreadyexists, -EEXIST},
|
||||
{ERRmoredata, -EOVERFLOW},
|
||||
{ERReasnotsupported, -EOPNOTSUPP},
|
||||
{ErrQuota, -EDQUOT},
|
||||
{ErrNotALink, -ENOLINK},
|
||||
{ERRnetlogonNotStarted, -ENOPROTOOPT},
|
||||
{ERRsymlink, -EOPNOTSUPP},
|
||||
{ErrTooManyLinks, -EMLINK},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static const struct smb_to_posix_error mapping_table_ERRSRV[] = {
|
||||
{ERRerror, -EIO},
|
||||
{ERRbadpw, -EACCES}, /* was EPERM */
|
||||
{ERRbadtype, -EREMOTE},
|
||||
{ERRaccess, -EACCES},
|
||||
{ERRinvtid, -ENXIO},
|
||||
{ERRinvnetname, -ENXIO},
|
||||
{ERRinvdevice, -ENXIO},
|
||||
{ERRqfull, -ENOSPC},
|
||||
{ERRqtoobig, -ENOSPC},
|
||||
{ERRqeof, -EIO},
|
||||
{ERRinvpfid, -EBADF},
|
||||
{ERRsmbcmd, -EBADRQC},
|
||||
{ERRsrverror, -EIO},
|
||||
{ERRbadBID, -EIO},
|
||||
{ERRfilespecs, -EINVAL},
|
||||
{ERRbadLink, -EIO},
|
||||
{ERRbadpermits, -EINVAL},
|
||||
{ERRbadPID, -ESRCH},
|
||||
{ERRsetattrmode, -EINVAL},
|
||||
{ERRpaused, -EHOSTDOWN},
|
||||
{ERRmsgoff, -EHOSTDOWN},
|
||||
{ERRnoroom, -ENOSPC},
|
||||
{ERRrmuns, -EUSERS},
|
||||
{ERRtimeout, -ETIME},
|
||||
{ERRnoresource, -EREMOTEIO},
|
||||
{ERRtoomanyuids, -EUSERS},
|
||||
{ERRbaduid, -EACCES},
|
||||
{ERRusempx, -EIO},
|
||||
{ERRusestd, -EIO},
|
||||
{ERR_NOTIFY_ENUM_DIR, -ENOBUFS},
|
||||
{ERRnoSuchUser, -EACCES},
|
||||
/* {ERRaccountexpired, -EACCES},
|
||||
{ERRbadclient, -EACCES},
|
||||
{ERRbadLogonTime, -EACCES},
|
||||
{ERRpasswordExpired, -EACCES},*/
|
||||
{ERRaccountexpired, -EKEYEXPIRED},
|
||||
{ERRbadclient, -EACCES},
|
||||
{ERRbadLogonTime, -EACCES},
|
||||
{ERRpasswordExpired, -EKEYEXPIRED},
|
||||
|
||||
{ERRnosupport, -EINVAL},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
/*
|
||||
* Convert a string containing text IPv4 or IPv6 address to binary form.
|
||||
*
|
||||
|
|
@ -199,736 +107,6 @@ cifs_set_port(struct sockaddr *addr, const unsigned short int port)
|
|||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
*convert a NT status code to a dos class/code
|
||||
*****************************************************************************/
|
||||
/* NT status -> dos error map */
|
||||
static const struct {
|
||||
__u8 dos_class;
|
||||
__u16 dos_code;
|
||||
__u32 ntstatus;
|
||||
} ntstatus_to_dos_map[] = {
|
||||
{
|
||||
ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, {
|
||||
ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, {
|
||||
ERRDOS, ERRinvlevel, NT_STATUS_INVALID_INFO_CLASS}, {
|
||||
ERRDOS, 24, NT_STATUS_INFO_LENGTH_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_INITIAL_STACK}, {
|
||||
ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_CID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER}, {
|
||||
ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE}, {
|
||||
ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, {
|
||||
ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST}, {
|
||||
ERRDOS, 38, NT_STATUS_END_OF_FILE}, {
|
||||
ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, {
|
||||
ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA}, {
|
||||
ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_MORE_PROCESSING_REQUIRED to NT_STATUS_OK
|
||||
during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY}, {
|
||||
ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES}, {
|
||||
ERRDOS, 487, NT_STATUS_NOT_MAPPED_VIEW}, {
|
||||
ERRDOS, 87, NT_STATUS_UNABLE_TO_FREE_VM}, {
|
||||
ERRDOS, 87, NT_STATUS_UNABLE_TO_DELETE_SECTION}, {
|
||||
ERRDOS, 2142, NT_STATUS_INVALID_SYSTEM_SERVICE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_INSTRUCTION}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_INVALID_LOCK_SEQUENCE}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_INVALID_VIEW_SIZE}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_FILE_FOR_SECTION}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_ACCESS_DENIED to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE
|
||||
during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED}, {
|
||||
ERRDOS, 111, NT_STATUS_BUFFER_TOO_SMALL}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_OBJECT_TYPE_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NONCONTINUABLE_EXCEPTION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_DISPOSITION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNWIND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_STACK}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_UNWIND_TARGET}, {
|
||||
ERRDOS, 158, NT_STATUS_NOT_LOCKED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR}, {
|
||||
ERRDOS, 487, NT_STATUS_UNABLE_TO_DECOMMIT_VM}, {
|
||||
ERRDOS, 487, NT_STATUS_NOT_COMMITTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_MIX}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, {
|
||||
/* mapping changed since shell does lookup on * expects FileNotFound */
|
||||
ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_INVALID}, {
|
||||
ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, {
|
||||
ERRDOS, ERRalreadyexists, NT_STATUS_OBJECT_NAME_COLLISION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED}, {
|
||||
ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID}, {
|
||||
ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, {
|
||||
ERRDOS, 161, NT_STATUS_OBJECT_PATH_SYNTAX_BAD}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR}, {
|
||||
ERRDOS, 23, NT_STATUS_DATA_ERROR}, {
|
||||
ERRDOS, 23, NT_STATUS_CRC_ERROR}, {
|
||||
ERRDOS, ERRnomem, NT_STATUS_SECTION_TOO_BIG}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_PORT_CONNECTION_REFUSED}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_INVALID_PORT_HANDLE}, {
|
||||
ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PAGE_PROTECTION}, {
|
||||
ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED}, {
|
||||
ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, {
|
||||
ERRDOS, 87, NT_STATUS_PORT_ALREADY_SET}, {
|
||||
ERRDOS, 87, NT_STATUS_SECTION_NOT_IMAGE}, {
|
||||
ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING}, {
|
||||
ERRDOS, 87, NT_STATUS_BAD_WORKING_SET_LIMIT}, {
|
||||
ERRDOS, 87, NT_STATUS_INCOMPATIBLE_FILE_MAP}, {
|
||||
ERRDOS, 87, NT_STATUS_SECTION_PROTECTION}, {
|
||||
ERRDOS, ERReasnotsupported, NT_STATUS_EAS_NOT_SUPPORTED}, {
|
||||
ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR}, {
|
||||
ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, {
|
||||
ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED}, {
|
||||
ERRDOS, ERRbadfile, NT_STATUS_DELETE_PENDING}, {
|
||||
ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_OWNER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_PRIMARY_GROUP}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_IMPERSONATION_TOKEN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANT_DISABLE_MANDATORY}, {
|
||||
ERRDOS, 2215, NT_STATUS_NO_LOGON_SERVERS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_LOGON_SESSION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PRIVILEGE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACCOUNT_NAME}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_USER_EXISTS},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_NO_SUCH_USER to NT_STATUS_LOGON_FAILURE
|
||||
during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, { /* could map to 2238 */
|
||||
ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_GROUP}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LAST_ADMIN},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_WRONG_PASSWORD to NT_STATUS_LOGON_FAILURE
|
||||
during the session setup } */
|
||||
{
|
||||
ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION}, {
|
||||
ERRSRV, ERRbadLogonTime, NT_STATUS_INVALID_LOGON_HOURS}, {
|
||||
ERRSRV, ERRbadclient, NT_STATUS_INVALID_WORKSTATION}, {
|
||||
ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_EXPIRED}, {
|
||||
ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_DISABLED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_SUB_AUTHORITY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACL}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_SID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_SECURITY_DESCR}, {
|
||||
ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_FORMAT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_TOKEN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_INHERITANCE_ACL}, {
|
||||
ERRDOS, 158, NT_STATUS_RANGE_NOT_LOCKED}, {
|
||||
ERRDOS, 112, NT_STATUS_DISK_FULL}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SERVER_DISABLED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SERVER_NOT_DISABLED}, {
|
||||
ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, {
|
||||
ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_ID_AUTHORITY}, {
|
||||
ERRDOS, 259, NT_STATUS_AGENTS_EXHAUSTED}, {
|
||||
ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL}, {
|
||||
ERRDOS, 14, NT_STATUS_SECTION_NOT_EXTENDED}, {
|
||||
ERRDOS, 487, NT_STATUS_NOT_MAPPED_DATA}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_DATA_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_TYPE_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_NAME_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ARRAY_BOUNDS_EXCEEDED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DENORMAL_OPERAND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DIVIDE_BY_ZERO}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INEXACT_RESULT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INVALID_OPERATION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_OVERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_STACK_CHECK}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_UNDERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INTEGER_DIVIDE_BY_ZERO}, {
|
||||
ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PRIVILEGED_INSTRUCTION}, {
|
||||
ERRDOS, ERRnomem, NT_STATUS_TOO_MANY_PAGING_FILES}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FILE_INVALID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ALLOTTED_SPACE_EXCEEDED},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_INSUFFICIENT_RESOURCES to
|
||||
NT_STATUS_INSUFF_SERVER_RESOURCES during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnoresource, NT_STATUS_INSUFFICIENT_RESOURCES}, {
|
||||
ERRDOS, ERRbadpath, NT_STATUS_DFS_EXIT_PATH_FOUND}, {
|
||||
ERRDOS, 23, NT_STATUS_DEVICE_DATA_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_CONNECTED}, {
|
||||
ERRDOS, 21, NT_STATUS_DEVICE_POWER_FAILURE}, {
|
||||
ERRDOS, 487, NT_STATUS_FREE_VM_NOT_AT_BASE}, {
|
||||
ERRDOS, 487, NT_STATUS_MEMORY_NOT_ALLOCATED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_WORKING_SET_QUOTA}, {
|
||||
ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED}, {
|
||||
ERRDOS, 21, NT_STATUS_DEVICE_NOT_READY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_GROUP_ATTRIBUTES}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_IMPERSONATION_LEVEL}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANT_OPEN_ANONYMOUS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_VALIDATION_CLASS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_TOKEN_TYPE}, {
|
||||
ERRDOS, 87, NT_STATUS_BAD_MASTER_BOOT_RECORD}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INSTRUCTION_MISALIGNMENT}, {
|
||||
ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE}, {
|
||||
ERRDOS, ERRpipebusy, NT_STATUS_PIPE_NOT_AVAILABLE}, {
|
||||
ERRDOS, ERRbadpipe, NT_STATUS_INVALID_PIPE_STATE}, {
|
||||
ERRDOS, ERRpipebusy, NT_STATUS_PIPE_BUSY}, {
|
||||
ERRDOS, ERRbadfunc, NT_STATUS_ILLEGAL_FUNCTION}, {
|
||||
ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED}, {
|
||||
ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PIPE_CONNECTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PIPE_LISTENING}, {
|
||||
ERRDOS, ERRbadpipe, NT_STATUS_INVALID_READ_MODE}, {
|
||||
ERRDOS, 121, NT_STATUS_IO_TIMEOUT}, {
|
||||
ERRDOS, 38, NT_STATUS_FILE_FORCED_CLOSED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STARTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STOPPED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_COULD_NOT_INTERPRET}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY}, {
|
||||
ERRDOS, ERRunsup, NT_STATUS_NOT_SUPPORTED}, {
|
||||
ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING}, {
|
||||
ERRDOS, 52, NT_STATUS_DUPLICATE_NAME}, {
|
||||
ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH}, {
|
||||
ERRDOS, 54, NT_STATUS_NETWORK_BUSY}, {
|
||||
ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, {
|
||||
ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS}, {
|
||||
ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, {
|
||||
ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, {
|
||||
ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, {
|
||||
ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, {
|
||||
ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL}, {
|
||||
ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE}, {
|
||||
ERRDOS, 63, NT_STATUS_PRINT_CANCELLED}, {
|
||||
ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED}, {
|
||||
ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, {
|
||||
ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE}, {
|
||||
ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME}, {
|
||||
ERRDOS, 68, NT_STATUS_TOO_MANY_NAMES}, {
|
||||
ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS}, {
|
||||
ERRDOS, 70, NT_STATUS_SHARING_PAUSED}, {
|
||||
ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, {
|
||||
ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED}, {
|
||||
ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PROFILING_AT_LIMIT}, {
|
||||
ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_FILE_RENAMED}, {
|
||||
ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SECURITY_ON_OBJECT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANT_WAIT}, {
|
||||
ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_EMPTY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANT_ACCESS_DOMAIN_INFO}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANT_TERMINATE_SELF}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_SERVER_STATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_STATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_ROLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_DOMAIN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_EXISTS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_LIMIT_EXCEEDED}, {
|
||||
ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, {
|
||||
ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_CORRUPTION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_GENERIC_NOT_MAPPED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_DESCRIPTOR_FORMAT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_USER_BUFFER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_IO_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_CREATE_ERR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_MAP_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_EXTEND_ERR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NOT_LOGON_PROCESS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_EXISTS}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_1}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_2}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_3}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_4}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_5}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_6}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_7}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_8}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_9}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_10}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_11}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_12}, {
|
||||
ERRDOS, ERRbadpath, NT_STATUS_REDIRECTOR_NOT_STARTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REDIRECTOR_STARTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PACKAGE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_FUNCTION_TABLE}, {
|
||||
ERRDOS, 203, 0xc0000100}, {
|
||||
ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FILE_CORRUPT_ERROR}, {
|
||||
ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_LOGON_SESSION_STATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_COLLISION}, {
|
||||
ERRDOS, 206, NT_STATUS_NAME_TOO_LONG}, {
|
||||
ERRDOS, 2401, NT_STATUS_FILES_OPEN}, {
|
||||
ERRDOS, 2404, NT_STATUS_CONNECTION_IN_USE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MESSAGE_NOT_FOUND}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_PROCESS_IS_TERMINATING}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_LOGON_TYPE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_GUID_TRANSLATION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANNOT_IMPERSONATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IMAGE_ALREADY_LOADED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_PRESENT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_NOT_EXIST}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_ALREADY_OWNED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_LID_OWNER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_COMMAND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_LID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_SELECTOR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_LDT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_SIZE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_OFFSET}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_DESCRIPTOR}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NE_FORMAT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RXACT_INVALID_STATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RXACT_COMMIT_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MAPPED_FILE_SIZE_ZERO}, {
|
||||
ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANCELLED}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_CANNOT_DELETE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_COMPUTER_NAME}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_FILE_DELETED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_ACCOUNT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_GROUP}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_USER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MEMBERS_PRIMARY_GROUP}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_FILE_CLOSED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_THREADS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_THREAD_NOT_IN_PROCESS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOKEN_ALREADY_IN_USE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA_EXCEEDED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_COMMITMENT_LIMIT}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_LE_FORMAT}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NOT_MZ}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_PROTECT}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_WIN_16}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGON_SERVER_CONFLICT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TIME_DIFFERENCE_AT_DC}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SYNCHRONIZATION_REQUIRED}, {
|
||||
ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_OPEN_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IO_PRIVILEGE_FAILED}, {
|
||||
ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND}, {
|
||||
ERRDOS, 127, NT_STATUS_ENTRYPOINT_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONTROL_C_EXIT}, {
|
||||
ERRDOS, 64, NT_STATUS_LOCAL_DISCONNECT}, {
|
||||
ERRDOS, 64, NT_STATUS_REMOTE_DISCONNECT}, {
|
||||
ERRDOS, 51, NT_STATUS_REMOTE_RESOURCES}, {
|
||||
ERRDOS, 59, NT_STATUS_LINK_FAILED}, {
|
||||
ERRDOS, 59, NT_STATUS_LINK_TIMEOUT}, {
|
||||
ERRDOS, 59, NT_STATUS_INVALID_CONNECTION}, {
|
||||
ERRDOS, 59, NT_STATUS_INVALID_ADDRESS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DLL_INIT_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MISSING_SYSTEMFILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNHANDLED_EXCEPTION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_APP_INIT_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_CREATE_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_PAGEFILE}, {
|
||||
ERRDOS, 124, NT_STATUS_INVALID_LEVEL}, {
|
||||
ERRDOS, 86, NT_STATUS_WRONG_PASSWORD_CORE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_FLOAT_CONTEXT}, {
|
||||
ERRDOS, 109, NT_STATUS_PIPE_BROKEN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_CORRUPT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_IO_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_EVENT_PAIR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_VOLUME}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SERIAL_NO_DEVICE_INITED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_ALIAS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_ALIAS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_ALIAS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ALIAS_EXISTS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGON_NOT_GRANTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SECRETS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SECRET_TOO_LONG}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FULLSCREEN_MODE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_CONTEXT_IDS}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_LOGON_TYPE_NOT_GRANTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NOT_REGISTRY_FILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FT_MISSING_MEMBER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_SERVICE_ENTRY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_CHARACTER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNMAPPABLE_CHARACTER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNDEFINED_CHARACTER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_VOLUME}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_WRONG_CYLINDER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_UNKNOWN_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_BAD_REGISTERS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DISK_RECALIBRATE_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DISK_OPERATION_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DISK_RESET_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SHARED_IRQ_BUSY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FT_ORPHANING}, {
|
||||
ERRHRD, ERRgeneral, 0xc000016e}, {
|
||||
ERRHRD, ERRgeneral, 0xc000016f}, {
|
||||
ERRHRD, ERRgeneral, 0xc0000170}, {
|
||||
ERRHRD, ERRgeneral, 0xc0000171}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PARTITION_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_BLOCK_LENGTH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_PARTITIONED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_LOCK_MEDIA}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_UNLOAD_MEDIA}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_EOM_OVERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_MEDIA}, {
|
||||
ERRHRD, ERRgeneral, 0xc0000179}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_MEMBER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_MEMBER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_KEY_DELETED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_LOG_SPACE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SIDS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_KEY_HAS_CHILDREN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CHILD_MUST_BE_VOLATILE}, {
|
||||
ERRDOS, 87, NT_STATUS_DEVICE_CONFIGURATION_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DRIVER_INTERNAL_ERROR}, {
|
||||
ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DEVICE_PROTOCOL_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BACKUP_CONTROLLER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOG_FILE_FULL}, {
|
||||
ERRDOS, 19, NT_STATUS_TOO_LATE}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_LSA_SECRET},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_NO_TRUST_SAM_ACCOUNT to
|
||||
NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_SAM_ACCOUNT}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_DOMAIN_FAILURE}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CORRUPT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_CANT_START}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED}, {
|
||||
ERRDOS, ERRnetlogonNotStarted, NT_STATUS_NETLOGON_NOT_STARTED}, {
|
||||
ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_EXPIRED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CHANGED}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_DOMAIN_TRUST_INCONSISTENT to NT_STATUS_LOGON_FAILURE
|
||||
during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_DOMAIN_TRUST_INCONSISTENT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FS_DRIVER_REQUIRED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_USER_SESSION_KEY}, {
|
||||
ERRDOS, 59, NT_STATUS_USER_SESSION_DELETED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_LANG_NOT_FOUND}, {
|
||||
ERRDOS, ERRnoresource, NT_STATUS_INSUFF_SERVER_RESOURCES}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_BUFFER_SIZE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_COMPONENT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_WILDCARD}, {
|
||||
ERRDOS, 68, NT_STATUS_TOO_MANY_ADDRESSES}, {
|
||||
ERRDOS, 52, NT_STATUS_ADDRESS_ALREADY_EXISTS}, {
|
||||
ERRDOS, 64, NT_STATUS_ADDRESS_CLOSED}, {
|
||||
ERRDOS, 64, NT_STATUS_CONNECTION_DISCONNECTED}, {
|
||||
ERRDOS, 64, NT_STATUS_CONNECTION_RESET}, {
|
||||
ERRDOS, 68, NT_STATUS_TOO_MANY_NODES}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_ABORTED}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_TIMED_OUT}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_NO_RELEASE}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_NO_MATCH}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_RESPONDED}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_ID}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_TYPE}, {
|
||||
ERRDOS, ERRunsup, NT_STATUS_NOT_SERVER_SESSION}, {
|
||||
ERRDOS, ERRunsup, NT_STATUS_NOT_CLIENT_SESSION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANNOT_LOAD_REGISTRY_FILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DEBUG_ATTACH_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SYSTEM_PROCESS_TERMINATED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DATA_NOT_ACCEPTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_BROWSER_SERVERS_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_VDM_HARD_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DRIVER_CANCEL_TIMEOUT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REPLY_MESSAGE_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MAPPED_ALIGNMENT}, {
|
||||
ERRDOS, 193, NT_STATUS_IMAGE_CHECKSUM_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOST_WRITEBEHIND_DATA}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID}, {
|
||||
ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_MUST_CHANGE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW_READ}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FAIL_CHECK}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DUPLICATE_OBJECTID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_OBJECTID_EXISTS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONVERT_TO_LARGE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RETRY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FOUND_OUT_OF_SCOPE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ALLOCATE_BUCKET}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PROPSET_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MARSHALL_OVERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_VARIANT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_ACCOUNT_LOCKED_OUT}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_HANDLE_NOT_CLOSABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_GRACEFUL_DISCONNECT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_NOT_ASSOCIATED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_INVALID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ACTIVE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PROTOCOL_UNREACHABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PORT_UNREACHABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REQUEST_ABORTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_COMPRESSION_BUFFER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_USER_MAPPED_FILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_AUDIT_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TIMER_RESOLUTION_NOT_SET}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_COUNT_LIMIT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGIN_TIME_RESTRICTION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGIN_WKSTA_RESTRICTION}, {
|
||||
ERRDOS, 193, NT_STATUS_IMAGE_MP_UP_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, 0xc000024a}, {
|
||||
ERRHRD, ERRgeneral, 0xc000024b}, {
|
||||
ERRHRD, ERRgeneral, 0xc000024c}, {
|
||||
ERRHRD, ERRgeneral, 0xc000024d}, {
|
||||
ERRHRD, ERRgeneral, 0xc000024e}, {
|
||||
ERRHRD, ERRgeneral, 0xc000024f}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LPC_REPLY_LOST}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT1}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT2}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_QUOTA_LIMIT}, {
|
||||
ERRSRV, 3, NT_STATUS_PATH_NOT_COVERED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_CALLBACK_ACTIVE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LICENSE_QUOTA_EXCEEDED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT}, {
|
||||
ERRHRD, ERRgeneral, 0xc000025d}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PLUGPLAY_NO_DEVICE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNSUPPORTED_COMPRESSION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_HW_PROFILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH}, {
|
||||
ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, {
|
||||
ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, {
|
||||
ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED}, {
|
||||
ERRDOS, ErrTooManyLinks, NT_STATUS_TOO_MANY_LINKS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE}, {
|
||||
ERRDOS, 21, 0xc000026e}, {
|
||||
ERRDOS, 161, 0xc0000281}, {
|
||||
ERRDOS, ERRnoaccess, 0xc000028a}, {
|
||||
ERRDOS, ERRnoaccess, 0xc000028b}, {
|
||||
ERRHRD, ERRgeneral, 0xc000028c}, {
|
||||
ERRDOS, ERRnoaccess, 0xc000028d}, {
|
||||
ERRDOS, ERRnoaccess, 0xc000028e}, {
|
||||
ERRDOS, ERRnoaccess, 0xc000028f}, {
|
||||
ERRDOS, ERRnoaccess, 0xc0000290}, {
|
||||
ERRDOS, ERRbadfunc, 0xc000029c}, {
|
||||
ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
|
||||
ERRDOS, ERRinvlevel, 0x007c0001}, {
|
||||
0, 0, 0 }
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
Print an error message from the status code
|
||||
*****************************************************************************/
|
||||
static void
|
||||
cifs_print_status(__u32 status_code)
|
||||
{
|
||||
int idx = 0;
|
||||
|
||||
while (nt_errs[idx].nt_errstr != NULL) {
|
||||
if (nt_errs[idx].nt_errcode == status_code) {
|
||||
pr_notice("Status code returned 0x%08x %s\n",
|
||||
status_code, nt_errs[idx].nt_errstr);
|
||||
return;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ntstatus_to_dos(__u32 ntstatus, __u8 *eclass, __u16 *ecode)
|
||||
{
|
||||
int i;
|
||||
if (ntstatus == 0) {
|
||||
*eclass = 0;
|
||||
*ecode = 0;
|
||||
return;
|
||||
}
|
||||
for (i = 0; ntstatus_to_dos_map[i].ntstatus; i++) {
|
||||
if (ntstatus == ntstatus_to_dos_map[i].ntstatus) {
|
||||
*eclass = ntstatus_to_dos_map[i].dos_class;
|
||||
*ecode = ntstatus_to_dos_map[i].dos_code;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*eclass = ERRHRD;
|
||||
*ecode = ERRgeneral;
|
||||
}
|
||||
|
||||
int
|
||||
map_smb_to_linux_error(char *buf, bool logErr)
|
||||
{
|
||||
struct smb_hdr *smb = (struct smb_hdr *)buf;
|
||||
unsigned int i;
|
||||
int rc = -EIO; /* if transport error smb error may not be set */
|
||||
__u8 smberrclass;
|
||||
__u16 smberrcode;
|
||||
|
||||
/* BB if NT Status codes - map NT BB */
|
||||
|
||||
/* old style smb error codes */
|
||||
if (smb->Status.CifsError == 0)
|
||||
return 0;
|
||||
|
||||
if (smb->Flags2 & SMBFLG2_ERR_STATUS) {
|
||||
/* translate the newer STATUS codes to old style SMB errors
|
||||
* and then to POSIX errors */
|
||||
__u32 err = le32_to_cpu(smb->Status.CifsError);
|
||||
if (logErr && (err != (NT_STATUS_MORE_PROCESSING_REQUIRED)))
|
||||
cifs_print_status(err);
|
||||
else if (cifsFYI & CIFS_RC)
|
||||
cifs_print_status(err);
|
||||
ntstatus_to_dos(err, &smberrclass, &smberrcode);
|
||||
} else {
|
||||
smberrclass = smb->Status.DosError.ErrorClass;
|
||||
smberrcode = le16_to_cpu(smb->Status.DosError.Error);
|
||||
}
|
||||
|
||||
/* old style errors */
|
||||
|
||||
/* DOS class smb error codes - map DOS */
|
||||
if (smberrclass == ERRDOS) {
|
||||
/* 1 byte field no need to byte reverse */
|
||||
for (i = 0;
|
||||
i <
|
||||
sizeof(mapping_table_ERRDOS) /
|
||||
sizeof(struct smb_to_posix_error); i++) {
|
||||
if (mapping_table_ERRDOS[i].smb_err == 0)
|
||||
break;
|
||||
else if (mapping_table_ERRDOS[i].smb_err ==
|
||||
smberrcode) {
|
||||
rc = mapping_table_ERRDOS[i].posix_code;
|
||||
break;
|
||||
}
|
||||
/* else try next error mapping one to see if match */
|
||||
}
|
||||
} else if (smberrclass == ERRSRV) {
|
||||
/* server class of error codes */
|
||||
for (i = 0;
|
||||
i <
|
||||
sizeof(mapping_table_ERRSRV) /
|
||||
sizeof(struct smb_to_posix_error); i++) {
|
||||
if (mapping_table_ERRSRV[i].smb_err == 0)
|
||||
break;
|
||||
else if (mapping_table_ERRSRV[i].smb_err ==
|
||||
smberrcode) {
|
||||
rc = mapping_table_ERRSRV[i].posix_code;
|
||||
break;
|
||||
}
|
||||
/* else try next error mapping to see if match */
|
||||
}
|
||||
}
|
||||
/* else ERRHRD class errors or junk - return EIO */
|
||||
|
||||
/* special cases for NT status codes which cannot be translated to DOS codes */
|
||||
if (smb->Flags2 & SMBFLG2_ERR_STATUS) {
|
||||
__u32 err = le32_to_cpu(smb->Status.CifsError);
|
||||
if (err == (NT_STATUS_NOT_A_REPARSE_POINT))
|
||||
rc = -ENODATA;
|
||||
else if (err == (NT_STATUS_PRIVILEGE_NOT_HELD))
|
||||
rc = -EPERM;
|
||||
}
|
||||
|
||||
cifs_dbg(FYI, "Mapping smb error code 0x%x to POSIX err %d\n",
|
||||
le32_to_cpu(smb->Status.CifsError), rc);
|
||||
|
||||
/* generic corrective action e.g. reconnect SMB session on
|
||||
* ERRbaduid could be added */
|
||||
|
||||
if (rc == -EIO)
|
||||
smb_EIO2(smb_eio_trace_smb1_received_error,
|
||||
le32_to_cpu(smb->Status.CifsError),
|
||||
le16_to_cpu(smb->Flags2));
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
map_and_check_smb_error(struct TCP_Server_Info *server,
|
||||
struct mid_q_entry *mid, bool logErr)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *smb = (struct smb_hdr *)mid->resp_buf;
|
||||
|
||||
rc = map_smb_to_linux_error((char *)smb, logErr);
|
||||
if (rc == -EACCES && !(smb->Flags2 & SMBFLG2_ERR_STATUS)) {
|
||||
/* possible ERRBaduid */
|
||||
__u8 class = smb->Status.DosError.ErrorClass;
|
||||
__u16 code = le16_to_cpu(smb->Status.DosError.Error);
|
||||
|
||||
/* switch can be used to handle different errors */
|
||||
if (class == ERRSRV && code == ERRbaduid) {
|
||||
cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n",
|
||||
code);
|
||||
cifs_signal_cifsd_for_reconnect(server, false);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* calculate the size of the SMB message based on the fixed header
|
||||
* portion, the number of word parameters and the data portion of the message
|
||||
*/
|
||||
unsigned int
|
||||
smbCalcSize(void *buf)
|
||||
{
|
||||
struct smb_hdr *ptr = buf;
|
||||
return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +
|
||||
2 /* size of the bcc field */ + get_bcc(ptr));
|
||||
}
|
||||
|
||||
/* The following are taken from fs/ntfs/util.c */
|
||||
|
||||
#define NTFS_TIME_OFFSET ((u64)(369*365 + 89) * 24 * 3600 * 10000000)
|
||||
|
|
|
|||
|
|
@ -346,6 +346,7 @@ const struct nt_err_code_struct nt_errs[] = {
|
|||
{"NT_STATUS_STACK_OVERFLOW", NT_STATUS_STACK_OVERFLOW},
|
||||
{"NT_STATUS_NO_SUCH_PACKAGE", NT_STATUS_NO_SUCH_PACKAGE},
|
||||
{"NT_STATUS_BAD_FUNCTION_TABLE", NT_STATUS_BAD_FUNCTION_TABLE},
|
||||
{"NT_STATUS_VARIABLE_NOT_FOUND", NT_STATUS_VARIABLE_NOT_FOUND},
|
||||
{"NT_STATUS_DIRECTORY_NOT_EMPTY", NT_STATUS_DIRECTORY_NOT_EMPTY},
|
||||
{"NT_STATUS_FILE_CORRUPT_ERROR", NT_STATUS_FILE_CORRUPT_ERROR},
|
||||
{"NT_STATUS_NOT_A_DIRECTORY", NT_STATUS_NOT_A_DIRECTORY},
|
||||
|
|
@ -486,6 +487,8 @@ const struct nt_err_code_struct nt_errs[] = {
|
|||
{"NT_STATUS_DISK_RESET_FAILED", NT_STATUS_DISK_RESET_FAILED},
|
||||
{"NT_STATUS_SHARED_IRQ_BUSY", NT_STATUS_SHARED_IRQ_BUSY},
|
||||
{"NT_STATUS_FT_ORPHANING", NT_STATUS_FT_ORPHANING},
|
||||
{"NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT",
|
||||
NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT},
|
||||
{"NT_STATUS_PARTITION_FAILURE", NT_STATUS_PARTITION_FAILURE},
|
||||
{"NT_STATUS_INVALID_BLOCK_LENGTH", NT_STATUS_INVALID_BLOCK_LENGTH},
|
||||
{"NT_STATUS_DEVICE_NOT_PARTITIONED",
|
||||
|
|
@ -676,7 +679,18 @@ const struct nt_err_code_struct nt_errs[] = {
|
|||
{"NT_STATUS_QUOTA_LIST_INCONSISTENT",
|
||||
NT_STATUS_QUOTA_LIST_INCONSISTENT},
|
||||
{"NT_STATUS_FILE_IS_OFFLINE", NT_STATUS_FILE_IS_OFFLINE},
|
||||
{"NT_STATUS_VOLUME_DISMOUNTED", NT_STATUS_VOLUME_DISMOUNTED},
|
||||
{"NT_STATUS_NOT_A_REPARSE_POINT", NT_STATUS_NOT_A_REPARSE_POINT},
|
||||
{"NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT",
|
||||
NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT},
|
||||
{"NT_STATUS_ENCRYPTION_FAILED", NT_STATUS_ENCRYPTION_FAILED},
|
||||
{"NT_STATUS_DECRYPTION_FAILED", NT_STATUS_DECRYPTION_FAILED},
|
||||
{"NT_STATUS_RANGE_NOT_FOUND", NT_STATUS_RANGE_NOT_FOUND},
|
||||
{"NT_STATUS_NO_RECOVERY_POLICY", NT_STATUS_NO_RECOVERY_POLICY},
|
||||
{"NT_STATUS_NO_EFS", NT_STATUS_NO_EFS},
|
||||
{"NT_STATUS_WRONG_EFS", NT_STATUS_WRONG_EFS},
|
||||
{"NT_STATUS_NO_USER_KEYS", NT_STATUS_NO_USER_KEYS},
|
||||
{"NT_STATUS_VOLUME_NOT_UPGRADED", NT_STATUS_VOLUME_NOT_UPGRADED},
|
||||
{"NT_STATUS_NETWORK_SESSION_EXPIRED", NT_STATUS_NETWORK_SESSION_EXPIRED},
|
||||
{"NT_STATUS_NO_MORE_ENTRIES", NT_STATUS_NO_MORE_ENTRIES},
|
||||
{"NT_STATUS_MORE_ENTRIES", NT_STATUS_MORE_ENTRIES},
|
||||
|
|
@ -684,5 +698,6 @@ const struct nt_err_code_struct nt_errs[] = {
|
|||
{"NT_STATUS_NO_SUCH_JOB", NT_STATUS_NO_SUCH_JOB},
|
||||
{"NT_STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP",
|
||||
NT_STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP},
|
||||
{"NT_STATUS_OS2_INVALID_LEVEL", NT_STATUS_OS2_INVALID_LEVEL},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -301,6 +301,7 @@ extern const struct nt_err_code_struct nt_errs[];
|
|||
#define NT_STATUS_STACK_OVERFLOW (0xC0000000 | 0x00fd)
|
||||
#define NT_STATUS_NO_SUCH_PACKAGE (0xC0000000 | 0x00fe)
|
||||
#define NT_STATUS_BAD_FUNCTION_TABLE (0xC0000000 | 0x00ff)
|
||||
#define NT_STATUS_VARIABLE_NOT_FOUND (0xC0000000 | 0x0100)
|
||||
#define NT_STATUS_DIRECTORY_NOT_EMPTY (0xC0000000 | 0x0101)
|
||||
#define NT_STATUS_FILE_CORRUPT_ERROR (0xC0000000 | 0x0102)
|
||||
#define NT_STATUS_NOT_A_DIRECTORY (0xC0000000 | 0x0103)
|
||||
|
|
@ -410,6 +411,7 @@ extern const struct nt_err_code_struct nt_errs[];
|
|||
#define NT_STATUS_DISK_RESET_FAILED (0xC0000000 | 0x016b)
|
||||
#define NT_STATUS_SHARED_IRQ_BUSY (0xC0000000 | 0x016c)
|
||||
#define NT_STATUS_FT_ORPHANING (0xC0000000 | 0x016d)
|
||||
#define NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT (0xC0000000 | 0x016e)
|
||||
#define NT_STATUS_PARTITION_FAILURE (0xC0000000 | 0x0172)
|
||||
#define NT_STATUS_INVALID_BLOCK_LENGTH (0xC0000000 | 0x0173)
|
||||
#define NT_STATUS_DEVICE_NOT_PARTITIONED (0xC0000000 | 0x0174)
|
||||
|
|
@ -548,9 +550,20 @@ extern const struct nt_err_code_struct nt_errs[];
|
|||
#define NT_STATUS_TOO_MANY_LINKS (0xC0000000 | 0x0265)
|
||||
#define NT_STATUS_QUOTA_LIST_INCONSISTENT (0xC0000000 | 0x0266)
|
||||
#define NT_STATUS_FILE_IS_OFFLINE (0xC0000000 | 0x0267)
|
||||
#define NT_STATUS_VOLUME_DISMOUNTED (0xC0000000 | 0x026e)
|
||||
#define NT_STATUS_NOT_A_REPARSE_POINT (0xC0000000 | 0x0275)
|
||||
#define NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT (0xC0000000 | 0x0281)
|
||||
#define NT_STATUS_ENCRYPTION_FAILED (0xC0000000 | 0x028a)
|
||||
#define NT_STATUS_DECRYPTION_FAILED (0xC0000000 | 0x028b)
|
||||
#define NT_STATUS_RANGE_NOT_FOUND (0xC0000000 | 0x028c)
|
||||
#define NT_STATUS_NO_RECOVERY_POLICY (0xC0000000 | 0x028d)
|
||||
#define NT_STATUS_NO_EFS (0xC0000000 | 0x028e)
|
||||
#define NT_STATUS_WRONG_EFS (0xC0000000 | 0x028f)
|
||||
#define NT_STATUS_NO_USER_KEYS (0xC0000000 | 0x0290)
|
||||
#define NT_STATUS_VOLUME_NOT_UPGRADED (0xC0000000 | 0x029c)
|
||||
#define NT_STATUS_NETWORK_SESSION_EXPIRED (0xC0000000 | 0x035c)
|
||||
#define NT_STATUS_NO_SUCH_JOB (0xC0000000 | 0xEDE) /* scheduler */
|
||||
#define NT_STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP (0xC0000000 | 0x5D0000)
|
||||
#define NT_STATUS_OS2_INVALID_LEVEL 0x007c0001
|
||||
|
||||
#endif /* _NTERR_H */
|
||||
|
|
|
|||
|
|
@ -142,16 +142,17 @@ typedef struct _AUTHENTICATE_MESSAGE {
|
|||
* Size of the session key (crypto key encrypted with the password
|
||||
*/
|
||||
|
||||
int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, struct cifs_ses *ses);
|
||||
int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
|
||||
struct cifs_ses *ses);
|
||||
int build_ntlmssp_negotiate_blob(unsigned char **pbuffer, u16 *buflen,
|
||||
struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const struct nls_table *nls_cp);
|
||||
int build_ntlmssp_smb3_negotiate_blob(unsigned char **pbuffer, u16 *buflen,
|
||||
struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const struct nls_table *nls_cp);
|
||||
struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const struct nls_table *nls_cp);
|
||||
int build_ntlmssp_auth_blob(unsigned char **pbuffer, u16 *buflen,
|
||||
struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const struct nls_table *nls_cp);
|
||||
struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const struct nls_table *nls_cp);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
#include <linux/pagemap.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/stat.h>
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_unicode.h"
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <linux/uidgid.h>
|
||||
#include "fs_context.h"
|
||||
#include "cifsglob.h"
|
||||
#include "../common/smbfsctl.h"
|
||||
|
||||
#define REPARSE_SYM_PATH_MAX 4060
|
||||
|
||||
|
|
@ -130,11 +131,12 @@ bool cifs_reparse_point_to_fattr(struct cifs_sb_info *cifs_sb,
|
|||
struct cifs_fattr *fattr,
|
||||
struct cifs_open_info_data *data);
|
||||
int create_reparse_symlink(const unsigned int xid, struct inode *inode,
|
||||
struct dentry *dentry, struct cifs_tcon *tcon,
|
||||
const char *full_path, const char *symname);
|
||||
int mknod_reparse(unsigned int xid, struct inode *inode,
|
||||
struct dentry *dentry, struct cifs_tcon *tcon,
|
||||
const char *full_path, umode_t mode, dev_t dev);
|
||||
struct reparse_data_buffer *smb2_get_reparse_point_buffer(const struct kvec *rsp_iov, u32 *len);
|
||||
struct dentry *dentry, struct cifs_tcon *tcon,
|
||||
const char *full_path, const char *symname);
|
||||
int mknod_reparse(unsigned int xid, struct inode *inode, struct dentry *dentry,
|
||||
struct cifs_tcon *tcon, const char *full_path, umode_t mode,
|
||||
dev_t dev);
|
||||
struct reparse_data_buffer *smb2_get_reparse_point_buffer(const struct kvec *rsp_iov,
|
||||
u32 *plen);
|
||||
|
||||
#endif /* _CIFS_REPARSE_H */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_unicode.h"
|
||||
|
|
@ -639,279 +638,6 @@ out_free_xid:
|
|||
return rc;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
|
||||
static __u32 cifs_ssetup_hdr(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
SESSION_SETUP_ANDX *pSMB)
|
||||
{
|
||||
__u32 capabilities = 0;
|
||||
|
||||
/* init fields common to all four types of SessSetup */
|
||||
/* Note that offsets for first seven fields in req struct are same */
|
||||
/* in CIFS Specs so does not matter which of 3 forms of struct */
|
||||
/* that we use in next few lines */
|
||||
/* Note that header is initialized to zero in header_assemble */
|
||||
pSMB->req.AndXCommand = 0xFF;
|
||||
pSMB->req.MaxBufferSize = cpu_to_le16(min_t(u32,
|
||||
CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4,
|
||||
USHRT_MAX));
|
||||
pSMB->req.MaxMpxCount = cpu_to_le16(server->maxReq);
|
||||
pSMB->req.VcNumber = cpu_to_le16(1);
|
||||
pSMB->req.SessionKey = server->session_key_id;
|
||||
|
||||
/* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */
|
||||
|
||||
/* BB verify whether signing required on neg or just auth frame (and NTLM case) */
|
||||
|
||||
capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
|
||||
CAP_LARGE_WRITE_X | CAP_LARGE_READ_X;
|
||||
|
||||
if (server->sign)
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
|
||||
|
||||
if (ses->capabilities & CAP_UNICODE) {
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_UNICODE;
|
||||
capabilities |= CAP_UNICODE;
|
||||
}
|
||||
if (ses->capabilities & CAP_STATUS32) {
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_ERR_STATUS;
|
||||
capabilities |= CAP_STATUS32;
|
||||
}
|
||||
if (ses->capabilities & CAP_DFS) {
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_DFS;
|
||||
capabilities |= CAP_DFS;
|
||||
}
|
||||
if (ses->capabilities & CAP_UNIX)
|
||||
capabilities |= CAP_UNIX;
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
static void
|
||||
unicode_oslm_strings(char **pbcc_area, const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
int bytes_ret = 0;
|
||||
|
||||
/* Copy OS version */
|
||||
bytes_ret = cifs_strtoUTF16((__le16 *)bcc_ptr, "Linux version ", 32,
|
||||
nls_cp);
|
||||
bcc_ptr += 2 * bytes_ret;
|
||||
bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, init_utsname()->release,
|
||||
32, nls_cp);
|
||||
bcc_ptr += 2 * bytes_ret;
|
||||
bcc_ptr += 2; /* trailing null */
|
||||
|
||||
bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
|
||||
32, nls_cp);
|
||||
bcc_ptr += 2 * bytes_ret;
|
||||
bcc_ptr += 2; /* trailing null */
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void
|
||||
ascii_oslm_strings(char **pbcc_area, const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
|
||||
strcpy(bcc_ptr, "Linux version ");
|
||||
bcc_ptr += strlen("Linux version ");
|
||||
strcpy(bcc_ptr, init_utsname()->release);
|
||||
bcc_ptr += strlen(init_utsname()->release) + 1;
|
||||
|
||||
strcpy(bcc_ptr, CIFS_NETWORK_OPSYS);
|
||||
bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1;
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
int bytes_ret = 0;
|
||||
|
||||
/* copy domain */
|
||||
if (ses->domainName == NULL) {
|
||||
/*
|
||||
* Sending null domain better than using a bogus domain name (as
|
||||
* we did briefly in 2.6.18) since server will use its default
|
||||
*/
|
||||
*bcc_ptr = 0;
|
||||
*(bcc_ptr+1) = 0;
|
||||
bytes_ret = 0;
|
||||
} else
|
||||
bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName,
|
||||
CIFS_MAX_DOMAINNAME_LEN, nls_cp);
|
||||
bcc_ptr += 2 * bytes_ret;
|
||||
bcc_ptr += 2; /* account for null terminator */
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void ascii_domain_string(char **pbcc_area, struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
int len;
|
||||
|
||||
/* copy domain */
|
||||
if (ses->domainName != NULL) {
|
||||
len = strscpy(bcc_ptr, ses->domainName, CIFS_MAX_DOMAINNAME_LEN);
|
||||
if (WARN_ON_ONCE(len < 0))
|
||||
len = CIFS_MAX_DOMAINNAME_LEN - 1;
|
||||
bcc_ptr += len;
|
||||
} /* else we send a null domain name so server will default to its own domain */
|
||||
*bcc_ptr = 0;
|
||||
bcc_ptr++;
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
int bytes_ret = 0;
|
||||
|
||||
/* BB FIXME add check that strings less than 335 or will need to send as arrays */
|
||||
|
||||
/* copy user */
|
||||
if (ses->user_name == NULL) {
|
||||
/* null user mount */
|
||||
*bcc_ptr = 0;
|
||||
*(bcc_ptr+1) = 0;
|
||||
} else {
|
||||
bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->user_name,
|
||||
CIFS_MAX_USERNAME_LEN, nls_cp);
|
||||
}
|
||||
bcc_ptr += 2 * bytes_ret;
|
||||
bcc_ptr += 2; /* account for null termination */
|
||||
|
||||
unicode_domain_string(&bcc_ptr, ses, nls_cp);
|
||||
unicode_oslm_strings(&bcc_ptr, nls_cp);
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
int len;
|
||||
|
||||
/* copy user */
|
||||
/* BB what about null user mounts - check that we do this BB */
|
||||
/* copy user */
|
||||
if (ses->user_name != NULL) {
|
||||
len = strscpy(bcc_ptr, ses->user_name, CIFS_MAX_USERNAME_LEN);
|
||||
if (WARN_ON_ONCE(len < 0))
|
||||
len = CIFS_MAX_USERNAME_LEN - 1;
|
||||
bcc_ptr += len;
|
||||
}
|
||||
/* else null user mount */
|
||||
*bcc_ptr = 0;
|
||||
bcc_ptr++; /* account for null termination */
|
||||
|
||||
/* BB check for overflow here */
|
||||
|
||||
ascii_domain_string(&bcc_ptr, ses, nls_cp);
|
||||
ascii_oslm_strings(&bcc_ptr, nls_cp);
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void
|
||||
decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
int len;
|
||||
char *data = *pbcc_area;
|
||||
|
||||
cifs_dbg(FYI, "bleft %d\n", bleft);
|
||||
|
||||
kfree(ses->serverOS);
|
||||
ses->serverOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp);
|
||||
cifs_dbg(FYI, "serverOS=%s\n", ses->serverOS);
|
||||
len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
|
||||
data += len;
|
||||
bleft -= len;
|
||||
if (bleft <= 0)
|
||||
return;
|
||||
|
||||
kfree(ses->serverNOS);
|
||||
ses->serverNOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp);
|
||||
cifs_dbg(FYI, "serverNOS=%s\n", ses->serverNOS);
|
||||
len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
|
||||
data += len;
|
||||
bleft -= len;
|
||||
if (bleft <= 0)
|
||||
return;
|
||||
|
||||
kfree(ses->serverDomain);
|
||||
ses->serverDomain = cifs_strndup_from_utf16(data, bleft, true, nls_cp);
|
||||
cifs_dbg(FYI, "serverDomain=%s\n", ses->serverDomain);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void decode_ascii_ssetup(char **pbcc_area, __u16 bleft,
|
||||
struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
int len;
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
|
||||
cifs_dbg(FYI, "decode sessetup ascii. bleft %d\n", bleft);
|
||||
|
||||
len = strnlen(bcc_ptr, bleft);
|
||||
if (len >= bleft)
|
||||
return;
|
||||
|
||||
kfree(ses->serverOS);
|
||||
|
||||
ses->serverOS = kmalloc(len + 1, GFP_KERNEL);
|
||||
if (ses->serverOS) {
|
||||
memcpy(ses->serverOS, bcc_ptr, len);
|
||||
ses->serverOS[len] = 0;
|
||||
if (strncmp(ses->serverOS, "OS/2", 4) == 0)
|
||||
cifs_dbg(FYI, "OS/2 server\n");
|
||||
}
|
||||
|
||||
bcc_ptr += len + 1;
|
||||
bleft -= len + 1;
|
||||
|
||||
len = strnlen(bcc_ptr, bleft);
|
||||
if (len >= bleft)
|
||||
return;
|
||||
|
||||
kfree(ses->serverNOS);
|
||||
|
||||
ses->serverNOS = kmalloc(len + 1, GFP_KERNEL);
|
||||
if (ses->serverNOS) {
|
||||
memcpy(ses->serverNOS, bcc_ptr, len);
|
||||
ses->serverNOS[len] = 0;
|
||||
}
|
||||
|
||||
bcc_ptr += len + 1;
|
||||
bleft -= len + 1;
|
||||
|
||||
len = strnlen(bcc_ptr, bleft);
|
||||
if (len > bleft)
|
||||
return;
|
||||
|
||||
/*
|
||||
* No domain field in LANMAN case. Domain is
|
||||
* returned by old servers in the SMB negprot response
|
||||
*
|
||||
* BB For newer servers which do not support Unicode,
|
||||
* but thus do return domain here, we could add parsing
|
||||
* for it later, but it is not very important
|
||||
*/
|
||||
cifs_dbg(FYI, "ascii: bytes left %d\n", bleft);
|
||||
}
|
||||
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
|
||||
|
||||
int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
|
||||
struct cifs_ses *ses)
|
||||
|
|
@ -1322,711 +1048,3 @@ cifs_select_sectype(struct TCP_Server_Info *server, enum securityEnum requested)
|
|||
return Unspecified;
|
||||
}
|
||||
}
|
||||
|
||||
struct sess_data {
|
||||
unsigned int xid;
|
||||
struct cifs_ses *ses;
|
||||
struct TCP_Server_Info *server;
|
||||
struct nls_table *nls_cp;
|
||||
void (*func)(struct sess_data *);
|
||||
int result;
|
||||
unsigned int in_len;
|
||||
|
||||
/* we will send the SMB in three pieces:
|
||||
* a fixed length beginning part, an optional
|
||||
* SPNEGO blob (which can be zero length), and a
|
||||
* last part which will include the strings
|
||||
* and rest of bcc area. This allows us to avoid
|
||||
* a large buffer 17K allocation
|
||||
*/
|
||||
int buf0_type;
|
||||
struct kvec iov[3];
|
||||
};
|
||||
|
||||
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
|
||||
static int
|
||||
sess_alloc_buffer(struct sess_data *sess_data, int wct)
|
||||
{
|
||||
int rc;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct smb_hdr *smb_buf;
|
||||
|
||||
rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses,
|
||||
(void **)&smb_buf);
|
||||
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
sess_data->in_len = rc;
|
||||
sess_data->iov[0].iov_base = (char *)smb_buf;
|
||||
sess_data->iov[0].iov_len = sess_data->in_len;
|
||||
/*
|
||||
* This variable will be used to clear the buffer
|
||||
* allocated above in case of any error in the calling function.
|
||||
*/
|
||||
sess_data->buf0_type = CIFS_SMALL_BUFFER;
|
||||
|
||||
/* 2000 big enough to fit max user, domain, NOS name etc. */
|
||||
sess_data->iov[2].iov_base = kmalloc(2000, GFP_KERNEL);
|
||||
if (!sess_data->iov[2].iov_base) {
|
||||
rc = -ENOMEM;
|
||||
goto out_free_smb_buf;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
out_free_smb_buf:
|
||||
cifs_small_buf_release(smb_buf);
|
||||
sess_data->iov[0].iov_base = NULL;
|
||||
sess_data->iov[0].iov_len = 0;
|
||||
sess_data->buf0_type = CIFS_NO_BUFFER;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void
|
||||
sess_free_buffer(struct sess_data *sess_data)
|
||||
{
|
||||
struct kvec *iov = sess_data->iov;
|
||||
|
||||
/*
|
||||
* Zero the session data before freeing, as it might contain sensitive info (keys, etc).
|
||||
* Note that iov[1] is already freed by caller.
|
||||
*/
|
||||
if (sess_data->buf0_type != CIFS_NO_BUFFER && iov[0].iov_base)
|
||||
memzero_explicit(iov[0].iov_base, iov[0].iov_len);
|
||||
|
||||
free_rsp_buf(sess_data->buf0_type, iov[0].iov_base);
|
||||
sess_data->buf0_type = CIFS_NO_BUFFER;
|
||||
kfree_sensitive(iov[2].iov_base);
|
||||
}
|
||||
|
||||
static int
|
||||
sess_establish_session(struct sess_data *sess_data)
|
||||
{
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
|
||||
cifs_server_lock(server);
|
||||
if (!server->session_estab) {
|
||||
if (server->sign) {
|
||||
server->session_key.response =
|
||||
kmemdup(ses->auth_key.response,
|
||||
ses->auth_key.len, GFP_KERNEL);
|
||||
if (!server->session_key.response) {
|
||||
cifs_server_unlock(server);
|
||||
return -ENOMEM;
|
||||
}
|
||||
server->session_key.len =
|
||||
ses->auth_key.len;
|
||||
}
|
||||
server->sequence_number = 0x2;
|
||||
server->session_estab = true;
|
||||
}
|
||||
cifs_server_unlock(server);
|
||||
|
||||
cifs_dbg(FYI, "CIFS session established successfully\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sess_sendreceive(struct sess_data *sess_data)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *smb_buf = (struct smb_hdr *) sess_data->iov[0].iov_base;
|
||||
__u16 count;
|
||||
struct kvec rsp_iov = { NULL, 0 };
|
||||
|
||||
count = sess_data->iov[1].iov_len + sess_data->iov[2].iov_len;
|
||||
sess_data->in_len += count;
|
||||
put_bcc(count, smb_buf);
|
||||
|
||||
rc = SendReceive2(sess_data->xid, sess_data->ses,
|
||||
sess_data->iov, 3 /* num_iovecs */,
|
||||
&sess_data->buf0_type,
|
||||
CIFS_LOG_ERROR, &rsp_iov);
|
||||
cifs_small_buf_release(sess_data->iov[0].iov_base);
|
||||
memcpy(&sess_data->iov[0], &rsp_iov, sizeof(struct kvec));
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void
|
||||
sess_auth_ntlmv2(struct sess_data *sess_data)
|
||||
{
|
||||
int rc = 0;
|
||||
struct smb_hdr *smb_buf;
|
||||
SESSION_SETUP_ANDX *pSMB;
|
||||
char *bcc_ptr;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
__u32 capabilities;
|
||||
__u16 bytes_remaining;
|
||||
|
||||
/* old style NTLM sessionsetup */
|
||||
/* wct = 13 */
|
||||
rc = sess_alloc_buffer(sess_data, 13);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
bcc_ptr = sess_data->iov[2].iov_base;
|
||||
capabilities = cifs_ssetup_hdr(ses, server, pSMB);
|
||||
|
||||
pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);
|
||||
|
||||
/* LM2 password would be here if we supported it */
|
||||
pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
|
||||
|
||||
if (ses->user_name != NULL) {
|
||||
/* calculate nlmv2 response and session key */
|
||||
rc = setup_ntlmv2_rsp(ses, sess_data->nls_cp);
|
||||
if (rc) {
|
||||
cifs_dbg(VFS, "Error %d during NTLMv2 authentication\n", rc);
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
|
||||
ses->auth_key.len - CIFS_SESS_KEY_SIZE);
|
||||
bcc_ptr += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
|
||||
|
||||
/* set case sensitive password length after tilen may get
|
||||
* assigned, tilen is 0 otherwise.
|
||||
*/
|
||||
pSMB->req_no_secext.CaseSensitivePasswordLength =
|
||||
cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
|
||||
} else {
|
||||
pSMB->req_no_secext.CaseSensitivePasswordLength = 0;
|
||||
}
|
||||
|
||||
if (ses->capabilities & CAP_UNICODE) {
|
||||
if (!IS_ALIGNED(sess_data->iov[0].iov_len, 2)) {
|
||||
*bcc_ptr = 0;
|
||||
bcc_ptr++;
|
||||
}
|
||||
unicode_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp);
|
||||
} else {
|
||||
ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp);
|
||||
}
|
||||
|
||||
|
||||
sess_data->iov[2].iov_len = (long) bcc_ptr -
|
||||
(long) sess_data->iov[2].iov_base;
|
||||
|
||||
rc = sess_sendreceive(sess_data);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base;
|
||||
|
||||
if (smb_buf->WordCount != 3) {
|
||||
rc = smb_EIO1(smb_eio_trace_sess_nl2_wcc, smb_buf->WordCount);
|
||||
cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (le16_to_cpu(pSMB->resp.Action) & GUEST_LOGIN)
|
||||
cifs_dbg(FYI, "Guest login\n"); /* BB mark SesInfo struct? */
|
||||
|
||||
ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */
|
||||
cifs_dbg(FYI, "UID = %llu\n", ses->Suid);
|
||||
|
||||
bytes_remaining = get_bcc(smb_buf);
|
||||
bcc_ptr = pByteArea(smb_buf);
|
||||
|
||||
/* BB check if Unicode and decode strings */
|
||||
if (bytes_remaining == 0) {
|
||||
/* no string area to decode, do nothing */
|
||||
} else if (smb_buf->Flags2 & SMBFLG2_UNICODE) {
|
||||
/* unicode string area must be word-aligned */
|
||||
if (!IS_ALIGNED((unsigned long)bcc_ptr - (unsigned long)smb_buf, 2)) {
|
||||
++bcc_ptr;
|
||||
--bytes_remaining;
|
||||
}
|
||||
decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
} else {
|
||||
decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
}
|
||||
|
||||
rc = sess_establish_session(sess_data);
|
||||
out:
|
||||
sess_data->result = rc;
|
||||
sess_data->func = NULL;
|
||||
sess_free_buffer(sess_data);
|
||||
kfree_sensitive(ses->auth_key.response);
|
||||
ses->auth_key.response = NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CIFS_UPCALL
|
||||
static void
|
||||
sess_auth_kerberos(struct sess_data *sess_data)
|
||||
{
|
||||
int rc = 0;
|
||||
struct smb_hdr *smb_buf;
|
||||
SESSION_SETUP_ANDX *pSMB;
|
||||
char *bcc_ptr;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
__u32 capabilities;
|
||||
__u16 bytes_remaining;
|
||||
struct key *spnego_key = NULL;
|
||||
struct cifs_spnego_msg *msg;
|
||||
u16 blob_len;
|
||||
|
||||
/* extended security */
|
||||
/* wct = 12 */
|
||||
rc = sess_alloc_buffer(sess_data, 12);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
bcc_ptr = sess_data->iov[2].iov_base;
|
||||
capabilities = cifs_ssetup_hdr(ses, server, pSMB);
|
||||
|
||||
spnego_key = cifs_get_spnego_key(ses, server);
|
||||
if (IS_ERR(spnego_key)) {
|
||||
rc = PTR_ERR(spnego_key);
|
||||
spnego_key = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
msg = spnego_key->payload.data[0];
|
||||
/*
|
||||
* check version field to make sure that cifs.upcall is
|
||||
* sending us a response in an expected form
|
||||
*/
|
||||
if (msg->version != CIFS_SPNEGO_UPCALL_VERSION) {
|
||||
cifs_dbg(VFS, "incorrect version of cifs.upcall (expected %d but got %d)\n",
|
||||
CIFS_SPNEGO_UPCALL_VERSION, msg->version);
|
||||
rc = -EKEYREJECTED;
|
||||
goto out_put_spnego_key;
|
||||
}
|
||||
|
||||
kfree_sensitive(ses->auth_key.response);
|
||||
ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len,
|
||||
GFP_KERNEL);
|
||||
if (!ses->auth_key.response) {
|
||||
cifs_dbg(VFS, "Kerberos can't allocate (%u bytes) memory\n",
|
||||
msg->sesskey_len);
|
||||
rc = -ENOMEM;
|
||||
goto out_put_spnego_key;
|
||||
}
|
||||
ses->auth_key.len = msg->sesskey_len;
|
||||
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
|
||||
capabilities |= CAP_EXTENDED_SECURITY;
|
||||
pSMB->req.Capabilities = cpu_to_le32(capabilities);
|
||||
sess_data->iov[1].iov_base = msg->data + msg->sesskey_len;
|
||||
sess_data->iov[1].iov_len = msg->secblob_len;
|
||||
pSMB->req.SecurityBlobLength = cpu_to_le16(sess_data->iov[1].iov_len);
|
||||
|
||||
if (pSMB->req.hdr.Flags2 & SMBFLG2_UNICODE) {
|
||||
/* unicode strings must be word aligned */
|
||||
if (!IS_ALIGNED(sess_data->iov[0].iov_len + sess_data->iov[1].iov_len, 2)) {
|
||||
*bcc_ptr = 0;
|
||||
bcc_ptr++;
|
||||
}
|
||||
unicode_oslm_strings(&bcc_ptr, sess_data->nls_cp);
|
||||
unicode_domain_string(&bcc_ptr, ses, sess_data->nls_cp);
|
||||
} else {
|
||||
ascii_oslm_strings(&bcc_ptr, sess_data->nls_cp);
|
||||
ascii_domain_string(&bcc_ptr, ses, sess_data->nls_cp);
|
||||
}
|
||||
|
||||
sess_data->iov[2].iov_len = (long) bcc_ptr -
|
||||
(long) sess_data->iov[2].iov_base;
|
||||
|
||||
rc = sess_sendreceive(sess_data);
|
||||
if (rc)
|
||||
goto out_put_spnego_key;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base;
|
||||
|
||||
if (smb_buf->WordCount != 4) {
|
||||
rc = smb_EIO1(smb_eio_trace_sess_krb_wcc, smb_buf->WordCount);
|
||||
cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount);
|
||||
goto out_put_spnego_key;
|
||||
}
|
||||
|
||||
if (le16_to_cpu(pSMB->resp.Action) & GUEST_LOGIN)
|
||||
cifs_dbg(FYI, "Guest login\n"); /* BB mark SesInfo struct? */
|
||||
|
||||
ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */
|
||||
cifs_dbg(FYI, "UID = %llu\n", ses->Suid);
|
||||
|
||||
bytes_remaining = get_bcc(smb_buf);
|
||||
bcc_ptr = pByteArea(smb_buf);
|
||||
|
||||
blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
|
||||
if (blob_len > bytes_remaining) {
|
||||
cifs_dbg(VFS, "bad security blob length %d\n",
|
||||
blob_len);
|
||||
rc = -EINVAL;
|
||||
goto out_put_spnego_key;
|
||||
}
|
||||
bcc_ptr += blob_len;
|
||||
bytes_remaining -= blob_len;
|
||||
|
||||
/* BB check if Unicode and decode strings */
|
||||
if (bytes_remaining == 0) {
|
||||
/* no string area to decode, do nothing */
|
||||
} else if (smb_buf->Flags2 & SMBFLG2_UNICODE) {
|
||||
/* unicode string area must be word-aligned */
|
||||
if (!IS_ALIGNED((unsigned long)bcc_ptr - (unsigned long)smb_buf, 2)) {
|
||||
++bcc_ptr;
|
||||
--bytes_remaining;
|
||||
}
|
||||
decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
} else {
|
||||
decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
}
|
||||
|
||||
rc = sess_establish_session(sess_data);
|
||||
out_put_spnego_key:
|
||||
key_invalidate(spnego_key);
|
||||
key_put(spnego_key);
|
||||
out:
|
||||
sess_data->result = rc;
|
||||
sess_data->func = NULL;
|
||||
sess_free_buffer(sess_data);
|
||||
kfree_sensitive(ses->auth_key.response);
|
||||
ses->auth_key.response = NULL;
|
||||
}
|
||||
|
||||
#endif /* ! CONFIG_CIFS_UPCALL */
|
||||
|
||||
/*
|
||||
* The required kvec buffers have to be allocated before calling this
|
||||
* function.
|
||||
*/
|
||||
static int
|
||||
_sess_auth_rawntlmssp_assemble_req(struct sess_data *sess_data)
|
||||
{
|
||||
SESSION_SETUP_ANDX *pSMB;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
__u32 capabilities;
|
||||
char *bcc_ptr;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
|
||||
capabilities = cifs_ssetup_hdr(ses, server, pSMB);
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
|
||||
capabilities |= CAP_EXTENDED_SECURITY;
|
||||
pSMB->req.Capabilities |= cpu_to_le32(capabilities);
|
||||
|
||||
bcc_ptr = sess_data->iov[2].iov_base;
|
||||
|
||||
if (pSMB->req.hdr.Flags2 & SMBFLG2_UNICODE) {
|
||||
/* unicode strings must be word aligned */
|
||||
if (!IS_ALIGNED(sess_data->iov[0].iov_len + sess_data->iov[1].iov_len, 2)) {
|
||||
*bcc_ptr = 0;
|
||||
bcc_ptr++;
|
||||
}
|
||||
unicode_oslm_strings(&bcc_ptr, sess_data->nls_cp);
|
||||
} else {
|
||||
ascii_oslm_strings(&bcc_ptr, sess_data->nls_cp);
|
||||
}
|
||||
|
||||
sess_data->iov[2].iov_len = (long) bcc_ptr -
|
||||
(long) sess_data->iov[2].iov_base;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data);
|
||||
|
||||
static void
|
||||
sess_auth_rawntlmssp_negotiate(struct sess_data *sess_data)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *smb_buf;
|
||||
SESSION_SETUP_ANDX *pSMB;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
__u16 bytes_remaining;
|
||||
char *bcc_ptr;
|
||||
unsigned char *ntlmsspblob = NULL;
|
||||
u16 blob_len;
|
||||
|
||||
cifs_dbg(FYI, "rawntlmssp session setup negotiate phase\n");
|
||||
|
||||
/*
|
||||
* if memory allocation is successful, caller of this function
|
||||
* frees it.
|
||||
*/
|
||||
ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL);
|
||||
if (!ses->ntlmssp) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
ses->ntlmssp->sesskey_per_smbsess = false;
|
||||
|
||||
/* wct = 12 */
|
||||
rc = sess_alloc_buffer(sess_data, 12);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
|
||||
/* Build security blob before we assemble the request */
|
||||
rc = build_ntlmssp_negotiate_blob(&ntlmsspblob,
|
||||
&blob_len, ses, server,
|
||||
sess_data->nls_cp);
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
|
||||
sess_data->iov[1].iov_len = blob_len;
|
||||
sess_data->iov[1].iov_base = ntlmsspblob;
|
||||
pSMB->req.SecurityBlobLength = cpu_to_le16(blob_len);
|
||||
|
||||
rc = _sess_auth_rawntlmssp_assemble_req(sess_data);
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
|
||||
rc = sess_sendreceive(sess_data);
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base;
|
||||
|
||||
/* If true, rc here is expected and not an error */
|
||||
if (sess_data->buf0_type != CIFS_NO_BUFFER &&
|
||||
smb_buf->Status.CifsError ==
|
||||
cpu_to_le32(NT_STATUS_MORE_PROCESSING_REQUIRED))
|
||||
rc = 0;
|
||||
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
|
||||
cifs_dbg(FYI, "rawntlmssp session setup challenge phase\n");
|
||||
|
||||
if (smb_buf->WordCount != 4) {
|
||||
rc = smb_EIO1(smb_eio_trace_sess_rawnl_neg_wcc, smb_buf->WordCount);
|
||||
cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount);
|
||||
goto out_free_ntlmsspblob;
|
||||
}
|
||||
|
||||
ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */
|
||||
cifs_dbg(FYI, "UID = %llu\n", ses->Suid);
|
||||
|
||||
bytes_remaining = get_bcc(smb_buf);
|
||||
bcc_ptr = pByteArea(smb_buf);
|
||||
|
||||
blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
|
||||
if (blob_len > bytes_remaining) {
|
||||
cifs_dbg(VFS, "bad security blob length %d\n",
|
||||
blob_len);
|
||||
rc = -EINVAL;
|
||||
goto out_free_ntlmsspblob;
|
||||
}
|
||||
|
||||
rc = decode_ntlmssp_challenge(bcc_ptr, blob_len, ses);
|
||||
|
||||
out_free_ntlmsspblob:
|
||||
kfree_sensitive(ntlmsspblob);
|
||||
out:
|
||||
sess_free_buffer(sess_data);
|
||||
|
||||
if (!rc) {
|
||||
sess_data->func = sess_auth_rawntlmssp_authenticate;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Else error. Cleanup */
|
||||
kfree_sensitive(ses->auth_key.response);
|
||||
ses->auth_key.response = NULL;
|
||||
kfree_sensitive(ses->ntlmssp);
|
||||
ses->ntlmssp = NULL;
|
||||
|
||||
sess_data->func = NULL;
|
||||
sess_data->result = rc;
|
||||
}
|
||||
|
||||
static void
|
||||
sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *smb_buf;
|
||||
SESSION_SETUP_ANDX *pSMB;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
__u16 bytes_remaining;
|
||||
char *bcc_ptr;
|
||||
unsigned char *ntlmsspblob = NULL;
|
||||
u16 blob_len;
|
||||
|
||||
cifs_dbg(FYI, "rawntlmssp session setup authenticate phase\n");
|
||||
|
||||
/* wct = 12 */
|
||||
rc = sess_alloc_buffer(sess_data, 12);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
/* Build security blob before we assemble the request */
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
smb_buf = (struct smb_hdr *)pSMB;
|
||||
rc = build_ntlmssp_auth_blob(&ntlmsspblob,
|
||||
&blob_len, ses, server,
|
||||
sess_data->nls_cp);
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
sess_data->iov[1].iov_len = blob_len;
|
||||
sess_data->iov[1].iov_base = ntlmsspblob;
|
||||
pSMB->req.SecurityBlobLength = cpu_to_le16(blob_len);
|
||||
/*
|
||||
* Make sure that we tell the server that we are using
|
||||
* the uid that it just gave us back on the response
|
||||
* (challenge)
|
||||
*/
|
||||
smb_buf->Uid = ses->Suid;
|
||||
|
||||
rc = _sess_auth_rawntlmssp_assemble_req(sess_data);
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
|
||||
rc = sess_sendreceive(sess_data);
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base;
|
||||
if (smb_buf->WordCount != 4) {
|
||||
rc = smb_EIO1(smb_eio_trace_sess_rawnl_auth_wcc, smb_buf->WordCount);
|
||||
cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount);
|
||||
goto out_free_ntlmsspblob;
|
||||
}
|
||||
|
||||
if (le16_to_cpu(pSMB->resp.Action) & GUEST_LOGIN)
|
||||
cifs_dbg(FYI, "Guest login\n"); /* BB mark SesInfo struct? */
|
||||
|
||||
if (ses->Suid != smb_buf->Uid) {
|
||||
ses->Suid = smb_buf->Uid;
|
||||
cifs_dbg(FYI, "UID changed! new UID = %llu\n", ses->Suid);
|
||||
}
|
||||
|
||||
bytes_remaining = get_bcc(smb_buf);
|
||||
bcc_ptr = pByteArea(smb_buf);
|
||||
blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
|
||||
if (blob_len > bytes_remaining) {
|
||||
cifs_dbg(VFS, "bad security blob length %d\n",
|
||||
blob_len);
|
||||
rc = -EINVAL;
|
||||
goto out_free_ntlmsspblob;
|
||||
}
|
||||
bcc_ptr += blob_len;
|
||||
bytes_remaining -= blob_len;
|
||||
|
||||
|
||||
/* BB check if Unicode and decode strings */
|
||||
if (bytes_remaining == 0) {
|
||||
/* no string area to decode, do nothing */
|
||||
} else if (smb_buf->Flags2 & SMBFLG2_UNICODE) {
|
||||
/* unicode string area must be word-aligned */
|
||||
if (!IS_ALIGNED((unsigned long)bcc_ptr - (unsigned long)smb_buf, 2)) {
|
||||
++bcc_ptr;
|
||||
--bytes_remaining;
|
||||
}
|
||||
decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
} else {
|
||||
decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
}
|
||||
|
||||
out_free_ntlmsspblob:
|
||||
kfree_sensitive(ntlmsspblob);
|
||||
out:
|
||||
sess_free_buffer(sess_data);
|
||||
|
||||
if (!rc)
|
||||
rc = sess_establish_session(sess_data);
|
||||
|
||||
/* Cleanup */
|
||||
kfree_sensitive(ses->auth_key.response);
|
||||
ses->auth_key.response = NULL;
|
||||
kfree_sensitive(ses->ntlmssp);
|
||||
ses->ntlmssp = NULL;
|
||||
|
||||
sess_data->func = NULL;
|
||||
sess_data->result = rc;
|
||||
}
|
||||
|
||||
static int select_sec(struct sess_data *sess_data)
|
||||
{
|
||||
int type;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
|
||||
type = cifs_select_sectype(server, ses->sectype);
|
||||
cifs_dbg(FYI, "sess setup type %d\n", type);
|
||||
if (type == Unspecified) {
|
||||
cifs_dbg(VFS, "Unable to select appropriate authentication method!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case NTLMv2:
|
||||
sess_data->func = sess_auth_ntlmv2;
|
||||
break;
|
||||
case Kerberos:
|
||||
#ifdef CONFIG_CIFS_UPCALL
|
||||
sess_data->func = sess_auth_kerberos;
|
||||
break;
|
||||
#else
|
||||
cifs_dbg(VFS, "Kerberos negotiated but upcall support disabled!\n");
|
||||
return -ENOSYS;
|
||||
#endif /* CONFIG_CIFS_UPCALL */
|
||||
case RawNTLMSSP:
|
||||
sess_data->func = sess_auth_rawntlmssp_negotiate;
|
||||
break;
|
||||
default:
|
||||
cifs_dbg(VFS, "secType %d not supported!\n", type);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
int rc = 0;
|
||||
struct sess_data *sess_data;
|
||||
|
||||
if (ses == NULL) {
|
||||
WARN(1, "%s: ses == NULL!", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
sess_data = kzalloc(sizeof(struct sess_data), GFP_KERNEL);
|
||||
if (!sess_data)
|
||||
return -ENOMEM;
|
||||
|
||||
sess_data->xid = xid;
|
||||
sess_data->ses = ses;
|
||||
sess_data->server = server;
|
||||
sess_data->buf0_type = CIFS_NO_BUFFER;
|
||||
sess_data->nls_cp = (struct nls_table *) nls_cp;
|
||||
|
||||
rc = select_sec(sess_data);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
while (sess_data->func)
|
||||
sess_data->func(sess_data);
|
||||
|
||||
/* Store result before we free sess_data */
|
||||
rc = sess_data->result;
|
||||
|
||||
out:
|
||||
kfree_sensitive(sess_data);
|
||||
return rc;
|
||||
}
|
||||
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
|
||||
|
|
|
|||
25
fs/smb/client/smb1debug.c
Normal file
25
fs/smb/client/smb1debug.c
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
*
|
||||
* Copyright (C) International Business Machines Corp., 2000,2005
|
||||
*
|
||||
* Modified by Steve French (sfrench@us.ibm.com)
|
||||
*/
|
||||
#include "cifsproto.h"
|
||||
#include "smb1proto.h"
|
||||
#include "cifs_debug.h"
|
||||
|
||||
void cifs_dump_detail(void *buf, size_t buf_len, struct TCP_Server_Info *server)
|
||||
{
|
||||
#ifdef CONFIG_CIFS_DEBUG2
|
||||
struct smb_hdr *smb = buf;
|
||||
|
||||
cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d Wct: %d\n",
|
||||
smb->Command, smb->Status.CifsError, smb->Flags,
|
||||
smb->Flags2, smb->Mid, smb->Pid, smb->WordCount);
|
||||
if (!server->ops->check_message(buf, buf_len, server->total_read, server)) {
|
||||
cifs_dbg(VFS, "smb buf %p len %u\n", smb,
|
||||
server->ops->calc_smb_size(smb));
|
||||
}
|
||||
#endif /* CONFIG_CIFS_DEBUG2 */
|
||||
}
|
||||
139
fs/smb/client/smb1encrypt.c
Normal file
139
fs/smb/client/smb1encrypt.c
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
// SPDX-License-Identifier: LGPL-2.1
|
||||
/*
|
||||
*
|
||||
* Encryption and hashing operations relating to NTLM, NTLMv2. See MS-NLMP
|
||||
* for more detailed information
|
||||
*
|
||||
* Copyright (C) International Business Machines Corp., 2005,2013
|
||||
* Author(s): Steve French (sfrench@us.ibm.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/fips.h>
|
||||
#include <crypto/md5.h>
|
||||
#include "cifsproto.h"
|
||||
#include "smb1proto.h"
|
||||
#include "cifs_debug.h"
|
||||
|
||||
/*
|
||||
* Calculate and return the CIFS signature based on the mac key and SMB PDU.
|
||||
* The 16 byte signature must be allocated by the caller. Note we only use the
|
||||
* 1st eight bytes and that the smb header signature field on input contains
|
||||
* the sequence number before this function is called. Also, this function
|
||||
* should be called with the server->srv_mutex held.
|
||||
*/
|
||||
static int cifs_calc_signature(struct smb_rqst *rqst,
|
||||
struct TCP_Server_Info *server, char *signature)
|
||||
{
|
||||
struct md5_ctx ctx;
|
||||
|
||||
if (!rqst->rq_iov || !signature || !server)
|
||||
return -EINVAL;
|
||||
if (fips_enabled) {
|
||||
cifs_dbg(VFS,
|
||||
"MD5 signature support is disabled due to FIPS\n");
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
md5_init(&ctx);
|
||||
md5_update(&ctx, server->session_key.response, server->session_key.len);
|
||||
|
||||
return __cifs_calc_signature(
|
||||
rqst, server, signature,
|
||||
&(struct cifs_calc_sig_ctx){ .md5 = &ctx });
|
||||
}
|
||||
|
||||
/* must be called with server->srv_mutex held */
|
||||
int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
|
||||
__u32 *pexpected_response_sequence_number)
|
||||
{
|
||||
int rc = 0;
|
||||
char smb_signature[20];
|
||||
struct smb_hdr *cifs_pdu = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
|
||||
|
||||
if ((cifs_pdu == NULL) || (server == NULL))
|
||||
return -EINVAL;
|
||||
|
||||
spin_lock(&server->srv_lock);
|
||||
if (!(cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) ||
|
||||
server->tcpStatus == CifsNeedNegotiate) {
|
||||
spin_unlock(&server->srv_lock);
|
||||
return rc;
|
||||
}
|
||||
spin_unlock(&server->srv_lock);
|
||||
|
||||
if (!server->session_estab) {
|
||||
memcpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
|
||||
return rc;
|
||||
}
|
||||
|
||||
cifs_pdu->Signature.Sequence.SequenceNumber =
|
||||
cpu_to_le32(server->sequence_number);
|
||||
cifs_pdu->Signature.Sequence.Reserved = 0;
|
||||
|
||||
*pexpected_response_sequence_number = ++server->sequence_number;
|
||||
++server->sequence_number;
|
||||
|
||||
rc = cifs_calc_signature(rqst, server, smb_signature);
|
||||
if (rc)
|
||||
memset(cifs_pdu->Signature.SecuritySignature, 0, 8);
|
||||
else
|
||||
memcpy(cifs_pdu->Signature.SecuritySignature, smb_signature, 8);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int cifs_verify_signature(struct smb_rqst *rqst,
|
||||
struct TCP_Server_Info *server,
|
||||
__u32 expected_sequence_number)
|
||||
{
|
||||
unsigned int rc;
|
||||
char server_response_sig[8];
|
||||
char what_we_think_sig_should_be[20];
|
||||
struct smb_hdr *cifs_pdu = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
|
||||
|
||||
if (cifs_pdu == NULL || server == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
if (!server->session_estab)
|
||||
return 0;
|
||||
|
||||
if (cifs_pdu->Command == SMB_COM_LOCKING_ANDX) {
|
||||
struct smb_com_lock_req *pSMB =
|
||||
(struct smb_com_lock_req *)cifs_pdu;
|
||||
if (pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* BB what if signatures are supposed to be on for session but
|
||||
server does not send one? BB */
|
||||
|
||||
/* Do not need to verify session setups with signature "BSRSPYL " */
|
||||
if (memcmp(cifs_pdu->Signature.SecuritySignature, "BSRSPYL ", 8) == 0)
|
||||
cifs_dbg(FYI, "dummy signature received for smb command 0x%x\n",
|
||||
cifs_pdu->Command);
|
||||
|
||||
/* save off the original signature so we can modify the smb and check
|
||||
its signature against what the server sent */
|
||||
memcpy(server_response_sig, cifs_pdu->Signature.SecuritySignature, 8);
|
||||
|
||||
cifs_pdu->Signature.Sequence.SequenceNumber =
|
||||
cpu_to_le32(expected_sequence_number);
|
||||
cifs_pdu->Signature.Sequence.Reserved = 0;
|
||||
|
||||
cifs_server_lock(server);
|
||||
rc = cifs_calc_signature(rqst, server, what_we_think_sig_should_be);
|
||||
cifs_server_unlock(server);
|
||||
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
/* cifs_dump_mem("what we think it should be: ",
|
||||
what_we_think_sig_should_be, 16); */
|
||||
|
||||
if (memcmp(server_response_sig, what_we_think_sig_should_be, 8))
|
||||
return -EACCES;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
809
fs/smb/client/smb1maperror.c
Normal file
809
fs/smb/client/smb1maperror.c
Normal file
|
|
@ -0,0 +1,809 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
/*
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2002,2008
|
||||
* Author(s): Steve French (sfrench@us.ibm.com)
|
||||
*
|
||||
* Error mapping routines from Samba libsmb/errormap.c
|
||||
* Copyright (C) Andrew Tridgell 2001
|
||||
*/
|
||||
|
||||
#include "cifsproto.h"
|
||||
#include "smb1proto.h"
|
||||
#include "smberr.h"
|
||||
#include "nterr.h"
|
||||
#include "cifs_debug.h"
|
||||
|
||||
struct smb_to_posix_error {
|
||||
__u16 smb_err;
|
||||
int posix_code;
|
||||
};
|
||||
|
||||
static const struct smb_to_posix_error mapping_table_ERRDOS[] = {
|
||||
{ERRbadfunc, -EINVAL},
|
||||
{ERRbadfile, -ENOENT},
|
||||
{ERRbadpath, -ENOTDIR},
|
||||
{ERRnofids, -EMFILE},
|
||||
{ERRnoaccess, -EACCES},
|
||||
{ERRbadfid, -EBADF},
|
||||
{ERRbadmcb, -EIO},
|
||||
{ERRnomem, -EREMOTEIO},
|
||||
{ERRbadmem, -EFAULT},
|
||||
{ERRbadenv, -EFAULT},
|
||||
{ERRbadformat, -EINVAL},
|
||||
{ERRbadaccess, -EACCES},
|
||||
{ERRbaddata, -EIO},
|
||||
{ERRbaddrive, -ENXIO},
|
||||
{ERRremcd, -EACCES},
|
||||
{ERRdiffdevice, -EXDEV},
|
||||
{ERRnofiles, -ENOENT},
|
||||
{ERRwriteprot, -EROFS},
|
||||
{ERRbadshare, -EBUSY},
|
||||
{ERRlock, -EACCES},
|
||||
{ERRunsup, -EINVAL},
|
||||
{ERRnosuchshare, -ENXIO},
|
||||
{ERRfilexists, -EEXIST},
|
||||
{ERRinvparm, -EINVAL},
|
||||
{ERRdiskfull, -ENOSPC},
|
||||
{ERRinvname, -ENOENT},
|
||||
{ERRunknownlevel, -EOPNOTSUPP},
|
||||
{ERRdirnotempty, -ENOTEMPTY},
|
||||
{ERRnotlocked, -ENOLCK},
|
||||
{ERRcancelviolation, -ENOLCK},
|
||||
{ERRalreadyexists, -EEXIST},
|
||||
{ERRmoredata, -EOVERFLOW},
|
||||
{ERReasnotsupported, -EOPNOTSUPP},
|
||||
{ErrQuota, -EDQUOT},
|
||||
{ErrNotALink, -ENOLINK},
|
||||
{ERRnetlogonNotStarted, -ENOPROTOOPT},
|
||||
{ERRsymlink, -EOPNOTSUPP},
|
||||
{ErrTooManyLinks, -EMLINK},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static const struct smb_to_posix_error mapping_table_ERRSRV[] = {
|
||||
{ERRerror, -EIO},
|
||||
{ERRbadpw, -EACCES}, /* was EPERM */
|
||||
{ERRbadtype, -EREMOTE},
|
||||
{ERRaccess, -EACCES},
|
||||
{ERRinvtid, -ENXIO},
|
||||
{ERRinvnetname, -ENXIO},
|
||||
{ERRinvdevice, -ENXIO},
|
||||
{ERRqfull, -ENOSPC},
|
||||
{ERRqtoobig, -ENOSPC},
|
||||
{ERRqeof, -EIO},
|
||||
{ERRinvpfid, -EBADF},
|
||||
{ERRsmbcmd, -EBADRQC},
|
||||
{ERRsrverror, -EIO},
|
||||
{ERRbadBID, -EIO},
|
||||
{ERRfilespecs, -EINVAL},
|
||||
{ERRbadLink, -EIO},
|
||||
{ERRbadpermits, -EINVAL},
|
||||
{ERRbadPID, -ESRCH},
|
||||
{ERRsetattrmode, -EINVAL},
|
||||
{ERRpaused, -EHOSTDOWN},
|
||||
{ERRmsgoff, -EHOSTDOWN},
|
||||
{ERRnoroom, -ENOSPC},
|
||||
{ERRrmuns, -EUSERS},
|
||||
{ERRtimeout, -ETIME},
|
||||
{ERRnoresource, -EREMOTEIO},
|
||||
{ERRtoomanyuids, -EUSERS},
|
||||
{ERRbaduid, -EACCES},
|
||||
{ERRusempx, -EIO},
|
||||
{ERRusestd, -EIO},
|
||||
{ERR_NOTIFY_ENUM_DIR, -ENOBUFS},
|
||||
{ERRnoSuchUser, -EACCES},
|
||||
{ERRaccountexpired, -EKEYEXPIRED},
|
||||
{ERRbadclient, -EACCES},
|
||||
{ERRbadLogonTime, -EACCES},
|
||||
{ERRpasswordExpired, -EKEYEXPIRED},
|
||||
|
||||
{ERRnosupport, -EINVAL},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
*convert a NT status code to a dos class/code
|
||||
*****************************************************************************/
|
||||
/* NT status -> dos error map */
|
||||
static const struct {
|
||||
__u8 dos_class;
|
||||
__u16 dos_code;
|
||||
__u32 ntstatus;
|
||||
} ntstatus_to_dos_map[] = {
|
||||
{
|
||||
ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, {
|
||||
ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, {
|
||||
ERRDOS, ERRbadpipe, NT_STATUS_INVALID_INFO_CLASS}, {
|
||||
ERRDOS, 24, NT_STATUS_INFO_LENGTH_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_INITIAL_STACK}, {
|
||||
ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_CID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER}, {
|
||||
ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE}, {
|
||||
ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, {
|
||||
ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST}, {
|
||||
ERRDOS, 38, NT_STATUS_END_OF_FILE}, {
|
||||
ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, {
|
||||
ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA}, {
|
||||
ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_MORE_PROCESSING_REQUIRED to NT_STATUS_OK
|
||||
during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY}, {
|
||||
ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES}, {
|
||||
ERRDOS, 487, NT_STATUS_NOT_MAPPED_VIEW}, {
|
||||
ERRDOS, 87, NT_STATUS_UNABLE_TO_FREE_VM}, {
|
||||
ERRDOS, 87, NT_STATUS_UNABLE_TO_DELETE_SECTION}, {
|
||||
ERRDOS, 2142, NT_STATUS_INVALID_SYSTEM_SERVICE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_INSTRUCTION}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_INVALID_LOCK_SEQUENCE}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_INVALID_VIEW_SIZE}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_FILE_FOR_SECTION}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_ACCESS_DENIED to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE
|
||||
during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED}, {
|
||||
ERRDOS, 111, NT_STATUS_BUFFER_TOO_SMALL}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_OBJECT_TYPE_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NONCONTINUABLE_EXCEPTION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_DISPOSITION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNWIND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_STACK}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_UNWIND_TARGET}, {
|
||||
ERRDOS, 158, NT_STATUS_NOT_LOCKED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR}, {
|
||||
ERRDOS, 487, NT_STATUS_UNABLE_TO_DECOMMIT_VM}, {
|
||||
ERRDOS, 487, NT_STATUS_NOT_COMMITTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_MIX}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, {
|
||||
/* mapping changed since shell does lookup on * expects FileNotFound */
|
||||
ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_INVALID}, {
|
||||
ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, {
|
||||
ERRDOS, ERRalreadyexists, NT_STATUS_OBJECT_NAME_COLLISION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED}, {
|
||||
ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID}, {
|
||||
ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, {
|
||||
ERRDOS, 161, NT_STATUS_OBJECT_PATH_SYNTAX_BAD}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR}, {
|
||||
ERRDOS, 23, NT_STATUS_DATA_ERROR}, {
|
||||
ERRDOS, 23, NT_STATUS_CRC_ERROR}, {
|
||||
ERRDOS, ERRnomem, NT_STATUS_SECTION_TOO_BIG}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_PORT_CONNECTION_REFUSED}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_INVALID_PORT_HANDLE}, {
|
||||
ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PAGE_PROTECTION}, {
|
||||
ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED}, {
|
||||
ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, {
|
||||
ERRDOS, 87, NT_STATUS_PORT_ALREADY_SET}, {
|
||||
ERRDOS, 87, NT_STATUS_SECTION_NOT_IMAGE}, {
|
||||
ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING}, {
|
||||
ERRDOS, 87, NT_STATUS_BAD_WORKING_SET_LIMIT}, {
|
||||
ERRDOS, 87, NT_STATUS_INCOMPATIBLE_FILE_MAP}, {
|
||||
ERRDOS, 87, NT_STATUS_SECTION_PROTECTION}, {
|
||||
ERRDOS, ERReasnotsupported, NT_STATUS_EAS_NOT_SUPPORTED}, {
|
||||
ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR}, {
|
||||
ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, {
|
||||
ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED}, {
|
||||
ERRDOS, ERRbadfile, NT_STATUS_DELETE_PENDING}, {
|
||||
ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_OWNER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_PRIMARY_GROUP}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_IMPERSONATION_TOKEN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANT_DISABLE_MANDATORY}, {
|
||||
ERRDOS, 2215, NT_STATUS_NO_LOGON_SERVERS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_LOGON_SESSION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PRIVILEGE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACCOUNT_NAME}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_USER_EXISTS},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_NO_SUCH_USER to NT_STATUS_LOGON_FAILURE
|
||||
during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, { /* could map to 2238 */
|
||||
ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_GROUP}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LAST_ADMIN},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_WRONG_PASSWORD to NT_STATUS_LOGON_FAILURE
|
||||
during the session setup } */
|
||||
{
|
||||
ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION}, {
|
||||
ERRSRV, ERRbadLogonTime, NT_STATUS_INVALID_LOGON_HOURS}, {
|
||||
ERRSRV, ERRbadclient, NT_STATUS_INVALID_WORKSTATION}, {
|
||||
ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_EXPIRED}, {
|
||||
ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_DISABLED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_SUB_AUTHORITY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACL}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_SID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_SECURITY_DESCR}, {
|
||||
ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_FORMAT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_TOKEN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_INHERITANCE_ACL}, {
|
||||
ERRDOS, 158, NT_STATUS_RANGE_NOT_LOCKED}, {
|
||||
ERRDOS, 112, NT_STATUS_DISK_FULL}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SERVER_DISABLED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SERVER_NOT_DISABLED}, {
|
||||
ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, {
|
||||
ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_ID_AUTHORITY}, {
|
||||
ERRDOS, 259, NT_STATUS_AGENTS_EXHAUSTED}, {
|
||||
ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL}, {
|
||||
ERRDOS, 14, NT_STATUS_SECTION_NOT_EXTENDED}, {
|
||||
ERRDOS, 487, NT_STATUS_NOT_MAPPED_DATA}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_DATA_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_TYPE_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_NAME_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ARRAY_BOUNDS_EXCEEDED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DENORMAL_OPERAND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DIVIDE_BY_ZERO}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INEXACT_RESULT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INVALID_OPERATION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_OVERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_STACK_CHECK}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOAT_UNDERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INTEGER_DIVIDE_BY_ZERO}, {
|
||||
ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PRIVILEGED_INSTRUCTION}, {
|
||||
ERRDOS, ERRnomem, NT_STATUS_TOO_MANY_PAGING_FILES}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FILE_INVALID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ALLOTTED_SPACE_EXCEEDED},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_INSUFFICIENT_RESOURCES to
|
||||
NT_STATUS_INSUFF_SERVER_RESOURCES during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnoresource, NT_STATUS_INSUFFICIENT_RESOURCES}, {
|
||||
ERRDOS, ERRbadpath, NT_STATUS_DFS_EXIT_PATH_FOUND}, {
|
||||
ERRDOS, 23, NT_STATUS_DEVICE_DATA_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_CONNECTED}, {
|
||||
ERRDOS, 21, NT_STATUS_DEVICE_POWER_FAILURE}, {
|
||||
ERRDOS, 487, NT_STATUS_FREE_VM_NOT_AT_BASE}, {
|
||||
ERRDOS, 487, NT_STATUS_MEMORY_NOT_ALLOCATED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_WORKING_SET_QUOTA}, {
|
||||
ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED}, {
|
||||
ERRDOS, 21, NT_STATUS_DEVICE_NOT_READY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_GROUP_ATTRIBUTES}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_IMPERSONATION_LEVEL}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANT_OPEN_ANONYMOUS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_VALIDATION_CLASS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_TOKEN_TYPE}, {
|
||||
ERRDOS, 87, NT_STATUS_BAD_MASTER_BOOT_RECORD}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INSTRUCTION_MISALIGNMENT}, {
|
||||
ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE}, {
|
||||
ERRDOS, ERRpipebusy, NT_STATUS_PIPE_NOT_AVAILABLE}, {
|
||||
ERRDOS, ERRbadpipe, NT_STATUS_INVALID_PIPE_STATE}, {
|
||||
ERRDOS, ERRpipebusy, NT_STATUS_PIPE_BUSY}, {
|
||||
ERRDOS, ERRbadfunc, NT_STATUS_ILLEGAL_FUNCTION}, {
|
||||
ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED}, {
|
||||
ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PIPE_CONNECTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PIPE_LISTENING}, {
|
||||
ERRDOS, ERRbadpipe, NT_STATUS_INVALID_READ_MODE}, {
|
||||
ERRDOS, 121, NT_STATUS_IO_TIMEOUT}, {
|
||||
ERRDOS, 38, NT_STATUS_FILE_FORCED_CLOSED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STARTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STOPPED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_COULD_NOT_INTERPRET}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY}, {
|
||||
ERRDOS, ERRunsup, NT_STATUS_NOT_SUPPORTED}, {
|
||||
ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING}, {
|
||||
ERRDOS, 52, NT_STATUS_DUPLICATE_NAME}, {
|
||||
ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH}, {
|
||||
ERRDOS, 54, NT_STATUS_NETWORK_BUSY}, {
|
||||
ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, {
|
||||
ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS}, {
|
||||
ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, {
|
||||
ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, {
|
||||
ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, {
|
||||
ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, {
|
||||
ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL}, {
|
||||
ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE}, {
|
||||
ERRDOS, 63, NT_STATUS_PRINT_CANCELLED}, {
|
||||
ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED}, {
|
||||
ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, {
|
||||
ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE}, {
|
||||
ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME}, {
|
||||
ERRDOS, 68, NT_STATUS_TOO_MANY_NAMES}, {
|
||||
ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS}, {
|
||||
ERRDOS, 70, NT_STATUS_SHARING_PAUSED}, {
|
||||
ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, {
|
||||
ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED}, {
|
||||
ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PROFILING_AT_LIMIT}, {
|
||||
ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_FILE_RENAMED}, {
|
||||
ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SECURITY_ON_OBJECT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANT_WAIT}, {
|
||||
ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_EMPTY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANT_ACCESS_DOMAIN_INFO}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANT_TERMINATE_SELF}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_SERVER_STATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_STATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_ROLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_DOMAIN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_EXISTS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_LIMIT_EXCEEDED}, {
|
||||
ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, {
|
||||
ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_CORRUPTION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_GENERIC_NOT_MAPPED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_DESCRIPTOR_FORMAT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_USER_BUFFER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_IO_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_CREATE_ERR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_MAP_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_EXTEND_ERR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NOT_LOGON_PROCESS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_EXISTS}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_1}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_2}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_3}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_4}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_5}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_6}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_7}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_8}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_9}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_10}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_11}, {
|
||||
ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_12}, {
|
||||
ERRDOS, ERRbadpath, NT_STATUS_REDIRECTOR_NOT_STARTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REDIRECTOR_STARTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PACKAGE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_FUNCTION_TABLE}, {
|
||||
ERRDOS, 203, NT_STATUS_VARIABLE_NOT_FOUND}, {
|
||||
ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FILE_CORRUPT_ERROR}, {
|
||||
ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_LOGON_SESSION_STATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_COLLISION}, {
|
||||
ERRDOS, 206, NT_STATUS_NAME_TOO_LONG}, {
|
||||
ERRDOS, 2401, NT_STATUS_FILES_OPEN}, {
|
||||
ERRDOS, 2404, NT_STATUS_CONNECTION_IN_USE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MESSAGE_NOT_FOUND}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_PROCESS_IS_TERMINATING}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_LOGON_TYPE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_GUID_TRANSLATION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANNOT_IMPERSONATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IMAGE_ALREADY_LOADED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_PRESENT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_NOT_EXIST}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_ALREADY_OWNED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_LID_OWNER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_COMMAND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_LID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_SELECTOR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_LDT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_SIZE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_OFFSET}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_DESCRIPTOR}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NE_FORMAT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RXACT_INVALID_STATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RXACT_COMMIT_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MAPPED_FILE_SIZE_ZERO}, {
|
||||
ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANCELLED}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_CANNOT_DELETE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_COMPUTER_NAME}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_FILE_DELETED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_ACCOUNT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_GROUP}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_USER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MEMBERS_PRIMARY_GROUP}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_FILE_CLOSED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_THREADS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_THREAD_NOT_IN_PROCESS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOKEN_ALREADY_IN_USE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA_EXCEEDED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_COMMITMENT_LIMIT}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_LE_FORMAT}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NOT_MZ}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_PROTECT}, {
|
||||
ERRDOS, 193, NT_STATUS_INVALID_IMAGE_WIN_16}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGON_SERVER_CONFLICT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TIME_DIFFERENCE_AT_DC}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SYNCHRONIZATION_REQUIRED}, {
|
||||
ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_OPEN_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IO_PRIVILEGE_FAILED}, {
|
||||
ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND}, {
|
||||
ERRDOS, 127, NT_STATUS_ENTRYPOINT_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONTROL_C_EXIT}, {
|
||||
ERRDOS, 64, NT_STATUS_LOCAL_DISCONNECT}, {
|
||||
ERRDOS, 64, NT_STATUS_REMOTE_DISCONNECT}, {
|
||||
ERRDOS, 51, NT_STATUS_REMOTE_RESOURCES}, {
|
||||
ERRDOS, 59, NT_STATUS_LINK_FAILED}, {
|
||||
ERRDOS, 59, NT_STATUS_LINK_TIMEOUT}, {
|
||||
ERRDOS, 59, NT_STATUS_INVALID_CONNECTION}, {
|
||||
ERRDOS, 59, NT_STATUS_INVALID_ADDRESS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DLL_INIT_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MISSING_SYSTEMFILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNHANDLED_EXCEPTION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_APP_INIT_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_CREATE_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_PAGEFILE}, {
|
||||
ERRDOS, 124, NT_STATUS_INVALID_LEVEL}, {
|
||||
ERRDOS, 86, NT_STATUS_WRONG_PASSWORD_CORE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_FLOAT_CONTEXT}, {
|
||||
ERRDOS, 109, NT_STATUS_PIPE_BROKEN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_CORRUPT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_IO_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_EVENT_PAIR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_VOLUME}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SERIAL_NO_DEVICE_INITED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_ALIAS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_ALIAS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_ALIAS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ALIAS_EXISTS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGON_NOT_GRANTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SECRETS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SECRET_TOO_LONG}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FULLSCREEN_MODE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_CONTEXT_IDS}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_LOGON_TYPE_NOT_GRANTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NOT_REGISTRY_FILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FT_MISSING_MEMBER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_SERVICE_ENTRY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_CHARACTER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNMAPPABLE_CHARACTER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNDEFINED_CHARACTER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_VOLUME}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_WRONG_CYLINDER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_UNKNOWN_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_BAD_REGISTERS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DISK_RECALIBRATE_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DISK_OPERATION_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DISK_RESET_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SHARED_IRQ_BUSY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FT_ORPHANING}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PARTITION_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_BLOCK_LENGTH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_PARTITIONED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_LOCK_MEDIA}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_UNLOAD_MEDIA}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_EOM_OVERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_MEDIA}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_MEMBER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_MEMBER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_KEY_DELETED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_LOG_SPACE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SIDS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_KEY_HAS_CHILDREN}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CHILD_MUST_BE_VOLATILE}, {
|
||||
ERRDOS, 87, NT_STATUS_DEVICE_CONFIGURATION_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DRIVER_INTERNAL_ERROR}, {
|
||||
ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DEVICE_PROTOCOL_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BACKUP_CONTROLLER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOG_FILE_FULL}, {
|
||||
ERRDOS, 19, NT_STATUS_TOO_LATE}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_LSA_SECRET},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_NO_TRUST_SAM_ACCOUNT to
|
||||
NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_SAM_ACCOUNT}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_DOMAIN_FAILURE}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CORRUPT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_CANT_START}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED}, {
|
||||
ERRDOS, ERRnetlogonNotStarted, NT_STATUS_NETLOGON_NOT_STARTED}, {
|
||||
ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_EXPIRED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CHANGED}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT},
|
||||
/* { This NT error code was 'sqashed'
|
||||
from NT_STATUS_DOMAIN_TRUST_INCONSISTENT to NT_STATUS_LOGON_FAILURE
|
||||
during the session setup } */
|
||||
{
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_DOMAIN_TRUST_INCONSISTENT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FS_DRIVER_REQUIRED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_USER_SESSION_KEY}, {
|
||||
ERRDOS, 59, NT_STATUS_USER_SESSION_DELETED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_LANG_NOT_FOUND}, {
|
||||
ERRDOS, ERRnoresource, NT_STATUS_INSUFF_SERVER_RESOURCES}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_BUFFER_SIZE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_COMPONENT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_WILDCARD}, {
|
||||
ERRDOS, 68, NT_STATUS_TOO_MANY_ADDRESSES}, {
|
||||
ERRDOS, 52, NT_STATUS_ADDRESS_ALREADY_EXISTS}, {
|
||||
ERRDOS, 64, NT_STATUS_ADDRESS_CLOSED}, {
|
||||
ERRDOS, 64, NT_STATUS_CONNECTION_DISCONNECTED}, {
|
||||
ERRDOS, 64, NT_STATUS_CONNECTION_RESET}, {
|
||||
ERRDOS, 68, NT_STATUS_TOO_MANY_NODES}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_ABORTED}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_TIMED_OUT}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_NO_RELEASE}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_NO_MATCH}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_RESPONDED}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_ID}, {
|
||||
ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_TYPE}, {
|
||||
ERRDOS, ERRunsup, NT_STATUS_NOT_SERVER_SESSION}, {
|
||||
ERRDOS, ERRunsup, NT_STATUS_NOT_CLIENT_SESSION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CANNOT_LOAD_REGISTRY_FILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DEBUG_ATTACH_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_SYSTEM_PROCESS_TERMINATED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DATA_NOT_ACCEPTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_BROWSER_SERVERS_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_VDM_HARD_ERROR}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DRIVER_CANCEL_TIMEOUT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REPLY_MESSAGE_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MAPPED_ALIGNMENT}, {
|
||||
ERRDOS, 193, NT_STATUS_IMAGE_CHECKSUM_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOST_WRITEBEHIND_DATA}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID}, {
|
||||
ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_MUST_CHANGE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW_READ}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FAIL_CHECK}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DUPLICATE_OBJECTID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_OBJECTID_EXISTS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONVERT_TO_LARGE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RETRY}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FOUND_OUT_OF_SCOPE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ALLOCATE_BUCKET}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PROPSET_NOT_FOUND}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_MARSHALL_OVERFLOW}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_VARIANT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_ACCOUNT_LOCKED_OUT}, {
|
||||
ERRDOS, ERRbadfid, NT_STATUS_HANDLE_NOT_CLOSABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_GRACEFUL_DISCONNECT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_NOT_ASSOCIATED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_INVALID}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ACTIVE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PROTOCOL_UNREACHABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PORT_UNREACHABLE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REQUEST_ABORTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_COMPRESSION_BUFFER}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_USER_MAPPED_FILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_AUDIT_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_TIMER_RESOLUTION_NOT_SET}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_COUNT_LIMIT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGIN_TIME_RESTRICTION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LOGIN_WKSTA_RESTRICTION}, {
|
||||
ERRDOS, 193, NT_STATUS_IMAGE_MP_UP_MISMATCH}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LPC_REPLY_LOST}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT1}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT2}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_QUOTA_LIMIT}, {
|
||||
ERRSRV, 3, NT_STATUS_PATH_NOT_COVERED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_NO_CALLBACK_ACTIVE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_LICENSE_QUOTA_EXCEEDED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_PLUGPLAY_NO_DEVICE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_UNSUPPORTED_COMPRESSION}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_HW_PROFILE}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH}, {
|
||||
ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, {
|
||||
ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, {
|
||||
ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED}, {
|
||||
ERRDOS, ErrTooManyLinks, NT_STATUS_TOO_MANY_LINKS}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE}, {
|
||||
ERRDOS, 21, NT_STATUS_VOLUME_DISMOUNTED}, {
|
||||
ERRDOS, 161, NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_ENCRYPTION_FAILED}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_DECRYPTION_FAILED}, {
|
||||
ERRHRD, ERRgeneral, NT_STATUS_RANGE_NOT_FOUND}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NO_RECOVERY_POLICY}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NO_EFS}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_WRONG_EFS}, {
|
||||
ERRDOS, ERRnoaccess, NT_STATUS_NO_USER_KEYS}, {
|
||||
ERRDOS, ERRbadfunc, NT_STATUS_VOLUME_NOT_UPGRADED}, {
|
||||
ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
|
||||
ERRDOS, ERRunknownlevel, NT_STATUS_OS2_INVALID_LEVEL}, {
|
||||
0, 0, 0 }
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
Print an error message from the status code
|
||||
*****************************************************************************/
|
||||
static void
|
||||
cifs_print_status(__u32 status_code)
|
||||
{
|
||||
int idx = 0;
|
||||
|
||||
while (nt_errs[idx].nt_errstr != NULL) {
|
||||
if (nt_errs[idx].nt_errcode == status_code) {
|
||||
pr_notice("Status code returned 0x%08x %s\n",
|
||||
status_code, nt_errs[idx].nt_errstr);
|
||||
return;
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ntstatus_to_dos(__u32 ntstatus, __u8 *eclass, __u16 *ecode)
|
||||
{
|
||||
int i;
|
||||
if (ntstatus == 0) {
|
||||
*eclass = 0;
|
||||
*ecode = 0;
|
||||
return;
|
||||
}
|
||||
for (i = 0; ntstatus_to_dos_map[i].ntstatus; i++) {
|
||||
if (ntstatus == ntstatus_to_dos_map[i].ntstatus) {
|
||||
*eclass = ntstatus_to_dos_map[i].dos_class;
|
||||
*ecode = ntstatus_to_dos_map[i].dos_code;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*eclass = ERRHRD;
|
||||
*ecode = ERRgeneral;
|
||||
}
|
||||
|
||||
int
|
||||
map_smb_to_linux_error(char *buf, bool logErr)
|
||||
{
|
||||
struct smb_hdr *smb = (struct smb_hdr *)buf;
|
||||
unsigned int i;
|
||||
int rc = -EIO; /* if transport error smb error may not be set */
|
||||
__u8 smberrclass;
|
||||
__u16 smberrcode;
|
||||
|
||||
/* BB if NT Status codes - map NT BB */
|
||||
|
||||
/* old style smb error codes */
|
||||
if (smb->Status.CifsError == 0)
|
||||
return 0;
|
||||
|
||||
if (smb->Flags2 & SMBFLG2_ERR_STATUS) {
|
||||
/* translate the newer STATUS codes to old style SMB errors
|
||||
* and then to POSIX errors */
|
||||
__u32 err = le32_to_cpu(smb->Status.CifsError);
|
||||
if (logErr && (err != (NT_STATUS_MORE_PROCESSING_REQUIRED)))
|
||||
cifs_print_status(err);
|
||||
else if (cifsFYI & CIFS_RC)
|
||||
cifs_print_status(err);
|
||||
ntstatus_to_dos(err, &smberrclass, &smberrcode);
|
||||
} else {
|
||||
smberrclass = smb->Status.DosError.ErrorClass;
|
||||
smberrcode = le16_to_cpu(smb->Status.DosError.Error);
|
||||
}
|
||||
|
||||
/* old style errors */
|
||||
|
||||
/* DOS class smb error codes - map DOS */
|
||||
if (smberrclass == ERRDOS) {
|
||||
/* 1 byte field no need to byte reverse */
|
||||
for (i = 0;
|
||||
i <
|
||||
sizeof(mapping_table_ERRDOS) /
|
||||
sizeof(struct smb_to_posix_error); i++) {
|
||||
if (mapping_table_ERRDOS[i].smb_err == 0)
|
||||
break;
|
||||
else if (mapping_table_ERRDOS[i].smb_err ==
|
||||
smberrcode) {
|
||||
rc = mapping_table_ERRDOS[i].posix_code;
|
||||
break;
|
||||
}
|
||||
/* else try next error mapping one to see if match */
|
||||
}
|
||||
} else if (smberrclass == ERRSRV) {
|
||||
/* server class of error codes */
|
||||
for (i = 0;
|
||||
i <
|
||||
sizeof(mapping_table_ERRSRV) /
|
||||
sizeof(struct smb_to_posix_error); i++) {
|
||||
if (mapping_table_ERRSRV[i].smb_err == 0)
|
||||
break;
|
||||
else if (mapping_table_ERRSRV[i].smb_err ==
|
||||
smberrcode) {
|
||||
rc = mapping_table_ERRSRV[i].posix_code;
|
||||
break;
|
||||
}
|
||||
/* else try next error mapping to see if match */
|
||||
}
|
||||
}
|
||||
/* else ERRHRD class errors or junk - return EIO */
|
||||
|
||||
/* special cases for NT status codes which cannot be translated to DOS codes */
|
||||
if (smb->Flags2 & SMBFLG2_ERR_STATUS) {
|
||||
__u32 err = le32_to_cpu(smb->Status.CifsError);
|
||||
if (err == (NT_STATUS_NOT_A_REPARSE_POINT))
|
||||
rc = -ENODATA;
|
||||
else if (err == (NT_STATUS_PRIVILEGE_NOT_HELD))
|
||||
rc = -EPERM;
|
||||
}
|
||||
|
||||
cifs_dbg(FYI, "Mapping smb error code 0x%x to POSIX err %d\n",
|
||||
le32_to_cpu(smb->Status.CifsError), rc);
|
||||
|
||||
/* generic corrective action e.g. reconnect SMB session on
|
||||
* ERRbaduid could be added */
|
||||
|
||||
if (rc == -EIO)
|
||||
smb_EIO2(smb_eio_trace_smb1_received_error,
|
||||
le32_to_cpu(smb->Status.CifsError),
|
||||
le16_to_cpu(smb->Flags2));
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
map_and_check_smb_error(struct TCP_Server_Info *server,
|
||||
struct mid_q_entry *mid, bool logErr)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *smb = (struct smb_hdr *)mid->resp_buf;
|
||||
|
||||
rc = map_smb_to_linux_error((char *)smb, logErr);
|
||||
if (rc == -EACCES && !(smb->Flags2 & SMBFLG2_ERR_STATUS)) {
|
||||
/* possible ERRBaduid */
|
||||
__u8 class = smb->Status.DosError.ErrorClass;
|
||||
__u16 code = le16_to_cpu(smb->Status.DosError.Error);
|
||||
|
||||
/* switch can be used to handle different errors */
|
||||
if (class == ERRSRV && code == ERRbaduid) {
|
||||
cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n",
|
||||
code);
|
||||
cifs_signal_cifsd_for_reconnect(server, false);
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
189
fs/smb/client/smb1misc.c
Normal file
189
fs/smb/client/smb1misc.c
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
// SPDX-License-Identifier: LGPL-2.1
|
||||
/*
|
||||
*
|
||||
* Copyright (C) International Business Machines Corp., 2002,2008
|
||||
* Author(s): Steve French (sfrench@us.ibm.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#include "smb1proto.h"
|
||||
#include "smberr.h"
|
||||
#include "nterr.h"
|
||||
#include "cifs_debug.h"
|
||||
|
||||
/* NB: MID can not be set if treeCon not passed in, in that
|
||||
case it is responsibility of caller to set the mid */
|
||||
unsigned int
|
||||
header_assemble(struct smb_hdr *buffer, char smb_command,
|
||||
const struct cifs_tcon *treeCon, int word_count
|
||||
/* length of fixed section (word count) in two byte units */)
|
||||
{
|
||||
unsigned int in_len;
|
||||
char *temp = (char *) buffer;
|
||||
|
||||
memset(temp, 0, 256); /* bigger than MAX_CIFS_HDR_SIZE */
|
||||
|
||||
in_len = (2 * word_count) + sizeof(struct smb_hdr) +
|
||||
2 /* for bcc field itself */;
|
||||
|
||||
buffer->Protocol[0] = 0xFF;
|
||||
buffer->Protocol[1] = 'S';
|
||||
buffer->Protocol[2] = 'M';
|
||||
buffer->Protocol[3] = 'B';
|
||||
buffer->Command = smb_command;
|
||||
buffer->Flags = 0x00; /* case sensitive */
|
||||
buffer->Flags2 = SMBFLG2_KNOWS_LONG_NAMES;
|
||||
buffer->Pid = cpu_to_le16((__u16)current->tgid);
|
||||
buffer->PidHigh = cpu_to_le16((__u16)(current->tgid >> 16));
|
||||
if (treeCon) {
|
||||
buffer->Tid = treeCon->tid;
|
||||
if (treeCon->ses) {
|
||||
if (treeCon->ses->capabilities & CAP_UNICODE)
|
||||
buffer->Flags2 |= SMBFLG2_UNICODE;
|
||||
if (treeCon->ses->capabilities & CAP_STATUS32)
|
||||
buffer->Flags2 |= SMBFLG2_ERR_STATUS;
|
||||
|
||||
/* Uid is not converted */
|
||||
buffer->Uid = treeCon->ses->Suid;
|
||||
if (treeCon->ses->server)
|
||||
buffer->Mid = get_next_mid(treeCon->ses->server);
|
||||
}
|
||||
if (treeCon->Flags & SMB_SHARE_IS_IN_DFS)
|
||||
buffer->Flags2 |= SMBFLG2_DFS;
|
||||
if (treeCon->nocase)
|
||||
buffer->Flags |= SMBFLG_CASELESS;
|
||||
if ((treeCon->ses) && (treeCon->ses->server))
|
||||
if (treeCon->ses->server->sign)
|
||||
buffer->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
|
||||
}
|
||||
|
||||
/* endian conversion of flags is now done just before sending */
|
||||
buffer->WordCount = (char) word_count;
|
||||
return in_len;
|
||||
}
|
||||
|
||||
bool
|
||||
is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv)
|
||||
{
|
||||
struct smb_hdr *buf = (struct smb_hdr *)buffer;
|
||||
struct smb_com_lock_req *pSMB = (struct smb_com_lock_req *)buf;
|
||||
struct TCP_Server_Info *pserver;
|
||||
struct cifs_ses *ses;
|
||||
struct cifs_tcon *tcon;
|
||||
struct cifsInodeInfo *pCifsInode;
|
||||
struct cifsFileInfo *netfile;
|
||||
|
||||
cifs_dbg(FYI, "Checking for oplock break or dnotify response\n");
|
||||
if ((pSMB->hdr.Command == SMB_COM_NT_TRANSACT) &&
|
||||
(pSMB->hdr.Flags & SMBFLG_RESPONSE)) {
|
||||
struct smb_com_transaction_change_notify_rsp *pSMBr =
|
||||
(struct smb_com_transaction_change_notify_rsp *)buf;
|
||||
struct file_notify_information *pnotify;
|
||||
__u32 data_offset = 0;
|
||||
size_t len = srv->total_read - srv->pdu_size;
|
||||
|
||||
if (get_bcc(buf) > sizeof(struct file_notify_information)) {
|
||||
data_offset = le32_to_cpu(pSMBr->DataOffset);
|
||||
|
||||
if (data_offset >
|
||||
len - sizeof(struct file_notify_information)) {
|
||||
cifs_dbg(FYI, "Invalid data_offset %u\n",
|
||||
data_offset);
|
||||
return true;
|
||||
}
|
||||
pnotify = (struct file_notify_information *)
|
||||
((char *)&pSMBr->hdr.Protocol + data_offset);
|
||||
cifs_dbg(FYI, "dnotify on %s Action: 0x%x\n",
|
||||
pnotify->FileName, pnotify->Action);
|
||||
/* cifs_dump_mem("Rcvd notify Data: ",buf,
|
||||
sizeof(struct smb_hdr)+60); */
|
||||
return true;
|
||||
}
|
||||
if (pSMBr->hdr.Status.CifsError) {
|
||||
cifs_dbg(FYI, "notify err 0x%x\n",
|
||||
pSMBr->hdr.Status.CifsError);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (pSMB->hdr.Command != SMB_COM_LOCKING_ANDX)
|
||||
return false;
|
||||
if (pSMB->hdr.Flags & SMBFLG_RESPONSE) {
|
||||
/* no sense logging error on invalid handle on oplock
|
||||
break - harmless race between close request and oplock
|
||||
break response is expected from time to time writing out
|
||||
large dirty files cached on the client */
|
||||
if ((NT_STATUS_INVALID_HANDLE) ==
|
||||
le32_to_cpu(pSMB->hdr.Status.CifsError)) {
|
||||
cifs_dbg(FYI, "Invalid handle on oplock break\n");
|
||||
return true;
|
||||
} else if (ERRbadfid ==
|
||||
le16_to_cpu(pSMB->hdr.Status.DosError.Error)) {
|
||||
return true;
|
||||
} else {
|
||||
return false; /* on valid oplock brk we get "request" */
|
||||
}
|
||||
}
|
||||
if (pSMB->hdr.WordCount != 8)
|
||||
return false;
|
||||
|
||||
cifs_dbg(FYI, "oplock type 0x%x level 0x%x\n",
|
||||
pSMB->LockType, pSMB->OplockLevel);
|
||||
if (!(pSMB->LockType & LOCKING_ANDX_OPLOCK_RELEASE))
|
||||
return false;
|
||||
|
||||
/* If server is a channel, select the primary channel */
|
||||
pserver = SERVER_IS_CHAN(srv) ? srv->primary_server : srv;
|
||||
|
||||
/* look up tcon based on tid & uid */
|
||||
spin_lock(&cifs_tcp_ses_lock);
|
||||
list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) {
|
||||
if (cifs_ses_exiting(ses))
|
||||
continue;
|
||||
list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
|
||||
if (tcon->tid != buf->Tid)
|
||||
continue;
|
||||
|
||||
cifs_stats_inc(&tcon->stats.cifs_stats.num_oplock_brks);
|
||||
spin_lock(&tcon->open_file_lock);
|
||||
list_for_each_entry(netfile, &tcon->openFileList, tlist) {
|
||||
if (pSMB->Fid != netfile->fid.netfid)
|
||||
continue;
|
||||
|
||||
cifs_dbg(FYI, "file id match, oplock break\n");
|
||||
pCifsInode = CIFS_I(d_inode(netfile->dentry));
|
||||
|
||||
set_bit(CIFS_INODE_PENDING_OPLOCK_BREAK,
|
||||
&pCifsInode->flags);
|
||||
|
||||
netfile->oplock_epoch = 0;
|
||||
netfile->oplock_level = pSMB->OplockLevel;
|
||||
netfile->oplock_break_cancelled = false;
|
||||
cifs_queue_oplock_break(netfile);
|
||||
|
||||
spin_unlock(&tcon->open_file_lock);
|
||||
spin_unlock(&cifs_tcp_ses_lock);
|
||||
return true;
|
||||
}
|
||||
spin_unlock(&tcon->open_file_lock);
|
||||
spin_unlock(&cifs_tcp_ses_lock);
|
||||
cifs_dbg(FYI, "No matching file for oplock break\n");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
spin_unlock(&cifs_tcp_ses_lock);
|
||||
cifs_dbg(FYI, "Can not process oplock break for non-existent connection\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* calculate the size of the SMB message based on the fixed header
|
||||
* portion, the number of word parameters and the data portion of the message
|
||||
*/
|
||||
unsigned int
|
||||
smbCalcSize(void *buf)
|
||||
{
|
||||
struct smb_hdr *ptr = buf;
|
||||
return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +
|
||||
2 /* size of the bcc field */ + get_bcc(ptr));
|
||||
}
|
||||
|
|
@ -12,13 +12,119 @@
|
|||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_debug.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifs_unicode.h"
|
||||
#include "fs_context.h"
|
||||
#include "nterr.h"
|
||||
#include "smberr.h"
|
||||
#include "reparse.h"
|
||||
|
||||
void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
|
||||
{
|
||||
/*
|
||||
* If we are reconnecting then should we check to see if
|
||||
* any requested capabilities changed locally e.g. via
|
||||
* remount but we can not do much about it here
|
||||
* if they have (even if we could detect it by the following)
|
||||
* Perhaps we could add a backpointer to array of sb from tcon
|
||||
* or if we change to make all sb to same share the same
|
||||
* sb as NFS - then we only have one backpointer to sb.
|
||||
* What if we wanted to mount the server share twice once with
|
||||
* and once without posixacls or posix paths?
|
||||
*/
|
||||
__u64 saved_cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
|
||||
|
||||
if (ctx && ctx->no_linux_ext) {
|
||||
tcon->fsUnixInfo.Capability = 0;
|
||||
tcon->unix_ext = 0; /* Unix Extensions disabled */
|
||||
cifs_dbg(FYI, "Linux protocol extensions disabled\n");
|
||||
return;
|
||||
} else if (ctx)
|
||||
tcon->unix_ext = 1; /* Unix Extensions supported */
|
||||
|
||||
if (!tcon->unix_ext) {
|
||||
cifs_dbg(FYI, "Unix extensions disabled so not set on reconnect\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CIFSSMBQFSUnixInfo(xid, tcon)) {
|
||||
__u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
|
||||
|
||||
cifs_dbg(FYI, "unix caps which server supports %lld\n", cap);
|
||||
/*
|
||||
* check for reconnect case in which we do not
|
||||
* want to change the mount behavior if we can avoid it
|
||||
*/
|
||||
if (ctx == NULL) {
|
||||
/*
|
||||
* turn off POSIX ACL and PATHNAMES if not set
|
||||
* originally at mount time
|
||||
*/
|
||||
if ((saved_cap & CIFS_UNIX_POSIX_ACL_CAP) == 0)
|
||||
cap &= ~CIFS_UNIX_POSIX_ACL_CAP;
|
||||
if ((saved_cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0) {
|
||||
if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP)
|
||||
cifs_dbg(VFS, "POSIXPATH support change\n");
|
||||
cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
|
||||
} else if ((cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) == 0) {
|
||||
cifs_dbg(VFS, "possible reconnect error\n");
|
||||
cifs_dbg(VFS, "server disabled POSIX path support\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (cap & CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP)
|
||||
cifs_dbg(VFS, "per-share encryption not supported yet\n");
|
||||
|
||||
cap &= CIFS_UNIX_CAP_MASK;
|
||||
if (ctx && ctx->no_psx_acl)
|
||||
cap &= ~CIFS_UNIX_POSIX_ACL_CAP;
|
||||
else if (CIFS_UNIX_POSIX_ACL_CAP & cap) {
|
||||
cifs_dbg(FYI, "negotiated posix acl support\n");
|
||||
if (cifs_sb)
|
||||
cifs_sb->mnt_cifs_flags |=
|
||||
CIFS_MOUNT_POSIXACL;
|
||||
}
|
||||
|
||||
if (ctx && ctx->posix_paths == 0)
|
||||
cap &= ~CIFS_UNIX_POSIX_PATHNAMES_CAP;
|
||||
else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
|
||||
cifs_dbg(FYI, "negotiate posix pathnames\n");
|
||||
if (cifs_sb)
|
||||
cifs_sb->mnt_cifs_flags |=
|
||||
CIFS_MOUNT_POSIX_PATHS;
|
||||
}
|
||||
|
||||
cifs_dbg(FYI, "Negotiate caps 0x%x\n", (int)cap);
|
||||
#ifdef CONFIG_CIFS_DEBUG2
|
||||
if (cap & CIFS_UNIX_FCNTL_CAP)
|
||||
cifs_dbg(FYI, "FCNTL cap\n");
|
||||
if (cap & CIFS_UNIX_EXTATTR_CAP)
|
||||
cifs_dbg(FYI, "EXTATTR cap\n");
|
||||
if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP)
|
||||
cifs_dbg(FYI, "POSIX path cap\n");
|
||||
if (cap & CIFS_UNIX_XATTR_CAP)
|
||||
cifs_dbg(FYI, "XATTR cap\n");
|
||||
if (cap & CIFS_UNIX_POSIX_ACL_CAP)
|
||||
cifs_dbg(FYI, "POSIX ACL cap\n");
|
||||
if (cap & CIFS_UNIX_LARGE_READ_CAP)
|
||||
cifs_dbg(FYI, "very large read cap\n");
|
||||
if (cap & CIFS_UNIX_LARGE_WRITE_CAP)
|
||||
cifs_dbg(FYI, "very large write cap\n");
|
||||
if (cap & CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP)
|
||||
cifs_dbg(FYI, "transport encryption cap\n");
|
||||
if (cap & CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP)
|
||||
cifs_dbg(FYI, "mandatory transport encryption cap\n");
|
||||
#endif /* CIFS_DEBUG2 */
|
||||
if (CIFSSMBSetFSUnixInfo(xid, tcon, cap)) {
|
||||
if (ctx == NULL)
|
||||
cifs_dbg(FYI, "resetting capabilities failed\n");
|
||||
else
|
||||
cifs_dbg(VFS, "Negotiating Unix capabilities with the server failed. Consider mounting with the Unix Extensions disabled if problems are found by specifying the nounix mount option.\n");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* An NT cancel request header looks just like the original request except:
|
||||
*
|
||||
|
|
@ -284,146 +390,6 @@ cifs_get_next_mid(struct TCP_Server_Info *server)
|
|||
return mid;
|
||||
}
|
||||
|
||||
/*
|
||||
return codes:
|
||||
0 not a transact2, or all data present
|
||||
>0 transact2 with that much data missing
|
||||
-EINVAL invalid transact2
|
||||
*/
|
||||
static int
|
||||
check2ndT2(char *buf)
|
||||
{
|
||||
struct smb_hdr *pSMB = (struct smb_hdr *)buf;
|
||||
struct smb_t2_rsp *pSMBt;
|
||||
int remaining;
|
||||
__u16 total_data_size, data_in_this_rsp;
|
||||
|
||||
if (pSMB->Command != SMB_COM_TRANSACTION2)
|
||||
return 0;
|
||||
|
||||
/* check for plausible wct, bcc and t2 data and parm sizes */
|
||||
/* check for parm and data offset going beyond end of smb */
|
||||
if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */
|
||||
cifs_dbg(FYI, "Invalid transact2 word count\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pSMBt = (struct smb_t2_rsp *)pSMB;
|
||||
|
||||
total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
|
||||
data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
|
||||
|
||||
if (total_data_size == data_in_this_rsp)
|
||||
return 0;
|
||||
else if (total_data_size < data_in_this_rsp) {
|
||||
cifs_dbg(FYI, "total data %d smaller than data in frame %d\n",
|
||||
total_data_size, data_in_this_rsp);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
remaining = total_data_size - data_in_this_rsp;
|
||||
|
||||
cifs_dbg(FYI, "missing %d bytes from transact2, check next response\n",
|
||||
remaining);
|
||||
if (total_data_size > CIFSMaxBufSize) {
|
||||
cifs_dbg(VFS, "TotalDataSize %d is over maximum buffer %d\n",
|
||||
total_data_size, CIFSMaxBufSize);
|
||||
return -EINVAL;
|
||||
}
|
||||
return remaining;
|
||||
}
|
||||
|
||||
static int
|
||||
coalesce_t2(char *second_buf, struct smb_hdr *target_hdr, unsigned int *pdu_len)
|
||||
{
|
||||
struct smb_t2_rsp *pSMBs = (struct smb_t2_rsp *)second_buf;
|
||||
struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)target_hdr;
|
||||
char *data_area_of_tgt;
|
||||
char *data_area_of_src;
|
||||
int remaining;
|
||||
unsigned int byte_count, total_in_tgt;
|
||||
__u16 tgt_total_cnt, src_total_cnt, total_in_src;
|
||||
|
||||
src_total_cnt = get_unaligned_le16(&pSMBs->t2_rsp.TotalDataCount);
|
||||
tgt_total_cnt = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
|
||||
|
||||
if (tgt_total_cnt != src_total_cnt)
|
||||
cifs_dbg(FYI, "total data count of primary and secondary t2 differ source=%hu target=%hu\n",
|
||||
src_total_cnt, tgt_total_cnt);
|
||||
|
||||
total_in_tgt = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
|
||||
|
||||
remaining = tgt_total_cnt - total_in_tgt;
|
||||
|
||||
if (remaining < 0) {
|
||||
cifs_dbg(FYI, "Server sent too much data. tgt_total_cnt=%hu total_in_tgt=%u\n",
|
||||
tgt_total_cnt, total_in_tgt);
|
||||
return -EPROTO;
|
||||
}
|
||||
|
||||
if (remaining == 0) {
|
||||
/* nothing to do, ignore */
|
||||
cifs_dbg(FYI, "no more data remains\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
total_in_src = get_unaligned_le16(&pSMBs->t2_rsp.DataCount);
|
||||
if (remaining < total_in_src)
|
||||
cifs_dbg(FYI, "transact2 2nd response contains too much data\n");
|
||||
|
||||
/* find end of first SMB data area */
|
||||
data_area_of_tgt = (char *)&pSMBt->hdr.Protocol +
|
||||
get_unaligned_le16(&pSMBt->t2_rsp.DataOffset);
|
||||
|
||||
/* validate target area */
|
||||
data_area_of_src = (char *)&pSMBs->hdr.Protocol +
|
||||
get_unaligned_le16(&pSMBs->t2_rsp.DataOffset);
|
||||
|
||||
data_area_of_tgt += total_in_tgt;
|
||||
|
||||
total_in_tgt += total_in_src;
|
||||
/* is the result too big for the field? */
|
||||
if (total_in_tgt > USHRT_MAX) {
|
||||
cifs_dbg(FYI, "coalesced DataCount too large (%u)\n",
|
||||
total_in_tgt);
|
||||
return -EPROTO;
|
||||
}
|
||||
put_unaligned_le16(total_in_tgt, &pSMBt->t2_rsp.DataCount);
|
||||
|
||||
/* fix up the BCC */
|
||||
byte_count = get_bcc(target_hdr);
|
||||
byte_count += total_in_src;
|
||||
/* is the result too big for the field? */
|
||||
if (byte_count > USHRT_MAX) {
|
||||
cifs_dbg(FYI, "coalesced BCC too large (%u)\n", byte_count);
|
||||
return -EPROTO;
|
||||
}
|
||||
put_bcc(byte_count, target_hdr);
|
||||
|
||||
byte_count = *pdu_len;
|
||||
byte_count += total_in_src;
|
||||
/* don't allow buffer to overflow */
|
||||
if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
|
||||
cifs_dbg(FYI, "coalesced BCC exceeds buffer size (%u)\n",
|
||||
byte_count);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
*pdu_len = byte_count;
|
||||
|
||||
/* copy second buffer into end of first buffer */
|
||||
memcpy(data_area_of_tgt, data_area_of_src, total_in_src);
|
||||
|
||||
if (remaining != total_in_src) {
|
||||
/* more responses to go */
|
||||
cifs_dbg(FYI, "waiting for more secondary responses\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* we are done */
|
||||
cifs_dbg(FYI, "found the last secondary response\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
cifs_downgrade_oplock(struct TCP_Server_Info *server,
|
||||
struct cifsInodeInfo *cinode, __u32 oplock,
|
||||
|
|
@ -432,37 +398,6 @@ cifs_downgrade_oplock(struct TCP_Server_Info *server,
|
|||
cifs_set_oplock_level(cinode, oplock);
|
||||
}
|
||||
|
||||
static bool
|
||||
cifs_check_trans2(struct mid_q_entry *mid, struct TCP_Server_Info *server,
|
||||
char *buf, int malformed)
|
||||
{
|
||||
if (malformed)
|
||||
return false;
|
||||
if (check2ndT2(buf) <= 0)
|
||||
return false;
|
||||
mid->multiRsp = true;
|
||||
if (mid->resp_buf) {
|
||||
/* merge response - fix up 1st*/
|
||||
malformed = coalesce_t2(buf, mid->resp_buf, &mid->response_pdu_len);
|
||||
if (malformed > 0)
|
||||
return true;
|
||||
/* All parts received or packet is malformed. */
|
||||
mid->multiEnd = true;
|
||||
dequeue_mid(server, mid, malformed);
|
||||
return true;
|
||||
}
|
||||
if (!server->large_buf) {
|
||||
/*FIXME: switch to already allocated largebuf?*/
|
||||
cifs_dbg(VFS, "1st trans2 resp needs bigbuf\n");
|
||||
} else {
|
||||
/* Have first buffer */
|
||||
mid->resp_buf = buf;
|
||||
mid->large_buf = true;
|
||||
server->bigbuf = NULL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
cifs_need_neg(struct TCP_Server_Info *server)
|
||||
{
|
||||
|
|
|
|||
2354
fs/smb/client/smb1pdu.h
Normal file
2354
fs/smb/client/smb1pdu.h
Normal file
File diff suppressed because it is too large
Load diff
335
fs/smb/client/smb1proto.h
Normal file
335
fs/smb/client/smb1proto.h
Normal file
|
|
@ -0,0 +1,335 @@
|
|||
/* SPDX-License-Identifier: LGPL-2.1 */
|
||||
/*
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2002,2008
|
||||
* Author(s): Steve French (sfrench@us.ibm.com)
|
||||
*
|
||||
*/
|
||||
#ifndef _SMB1PROTO_H
|
||||
#define _SMB1PROTO_H
|
||||
|
||||
#include <linux/uidgid_types.h>
|
||||
#include <linux/unaligned.h>
|
||||
#include "../common/smb2pdu.h"
|
||||
#include "cifsglob.h"
|
||||
|
||||
struct cifs_unix_set_info_args {
|
||||
__u64 ctime;
|
||||
__u64 atime;
|
||||
__u64 mtime;
|
||||
__u64 mode;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
dev_t device;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
|
||||
|
||||
/*
|
||||
* cifssmb.c
|
||||
*/
|
||||
int small_smb_init_no_tc(const int smb_command, const int wct,
|
||||
struct cifs_ses *ses, void **request_buf);
|
||||
int CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
int CIFSTCon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
|
||||
struct cifs_tcon *tcon, const struct nls_table *nls_codepage);
|
||||
int CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon);
|
||||
int CIFSSMBEcho(struct TCP_Server_Info *server);
|
||||
int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses);
|
||||
int CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *fileName, __u16 type,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
int CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *name, struct cifs_sb_info *cifs_sb,
|
||||
struct dentry *dentry);
|
||||
int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *name, struct cifs_sb_info *cifs_sb);
|
||||
int CIFSSMBMkDir(const unsigned int xid, struct inode *inode, umode_t mode,
|
||||
struct cifs_tcon *tcon, const char *name,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
int CIFSPOSIXCreate(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
__u32 posix_flags, __u64 mode, __u16 *netfid,
|
||||
FILE_UNIX_BASIC_INFO *pRetData, __u32 *pOplock,
|
||||
const char *name, const struct nls_table *nls_codepage,
|
||||
int remap);
|
||||
int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *fileName, const int openDisposition,
|
||||
const int access_flags, const int create_options,
|
||||
__u16 *netfid, int *pOplock, FILE_ALL_INFO *pfile_info,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
int CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms,
|
||||
int *oplock, FILE_ALL_INFO *buf);
|
||||
int cifs_async_readv(struct cifs_io_subrequest *rdata);
|
||||
int CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms,
|
||||
unsigned int *nbytes, char **buf, int *pbuf_type);
|
||||
int CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
|
||||
unsigned int *nbytes, const char *buf);
|
||||
void cifs_async_writev(struct cifs_io_subrequest *wdata);
|
||||
int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
|
||||
unsigned int *nbytes, struct kvec *iov, int n_vec);
|
||||
int cifs_lockv(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u16 netfid, const __u8 lock_type,
|
||||
const __u32 num_unlock, const __u32 num_lock,
|
||||
LOCKING_ANDX_RANGE *buf);
|
||||
int CIFSSMBLock(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u16 smb_file_id, const __u32 netpid, const __u64 len,
|
||||
const __u64 offset, const __u32 numUnlock, const __u32 numLock,
|
||||
const __u8 lockType, const bool waitFlag,
|
||||
const __u8 oplock_level);
|
||||
int CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u16 smb_file_id, const __u32 netpid,
|
||||
const loff_t start_offset, const __u64 len,
|
||||
struct file_lock *pLockData, const __u16 lock_type,
|
||||
const bool waitFlag);
|
||||
int CIFSSMBClose(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
int smb_file_id);
|
||||
int CIFSSMBFlush(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
int smb_file_id);
|
||||
int CIFSSMBRename(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct dentry *source_dentry, const char *from_name,
|
||||
const char *to_name, struct cifs_sb_info *cifs_sb);
|
||||
int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *pTcon,
|
||||
int netfid, const char *target_name,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
int CIFSUnixCreateSymLink(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *fromName, const char *toName,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
int CIFSUnixCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *fromName, const char *toName,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
int CIFSCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct dentry *source_dentry, const char *from_name,
|
||||
const char *to_name, struct cifs_sb_info *cifs_sb);
|
||||
int CIFSSMBUnixQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const unsigned char *searchName,
|
||||
char **symlinkinfo,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
int cifs_query_reparse_point(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
const char *full_path, u32 *tag, struct kvec *rsp,
|
||||
int *rsp_buftype);
|
||||
struct inode *cifs_create_reparse_inode(struct cifs_open_info_data *data,
|
||||
struct super_block *sb,
|
||||
const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
const char *full_path, bool directory,
|
||||
struct kvec *reparse_iov,
|
||||
struct kvec *xattr_iov);
|
||||
int CIFSSMB_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
__u16 fid);
|
||||
int cifs_do_get_acl(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const unsigned char *searchName, struct posix_acl **acl,
|
||||
const int acl_type, const struct nls_table *nls_codepage,
|
||||
int remap);
|
||||
int cifs_do_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const unsigned char *fileName, const struct posix_acl *acl,
|
||||
const int acl_type, const struct nls_table *nls_codepage,
|
||||
int remap);
|
||||
int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
|
||||
int CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
__u16 fid, struct smb_ntsd **acl_inf, __u32 *pbuflen,
|
||||
__u32 info);
|
||||
int CIFSSMBSetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
__u16 fid, struct smb_ntsd *pntsd, __u32 acllen,
|
||||
int aclflag);
|
||||
int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *search_name, FILE_ALL_INFO *data,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
int CIFSSMBQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u16 netfid, FILE_ALL_INFO *pFindData);
|
||||
int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *search_name, FILE_ALL_INFO *data,
|
||||
int legacy /* old style infolevel */,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
int CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u16 netfid, FILE_UNIX_BASIC_INFO *pFindData);
|
||||
int CIFSSMBUnixQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const unsigned char *searchName,
|
||||
FILE_UNIX_BASIC_INFO *pFindData,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
int CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *searchName, struct cifs_sb_info *cifs_sb,
|
||||
__u16 *pnetfid, __u16 search_flags,
|
||||
struct cifs_search_info *psrch_inf, bool msearch);
|
||||
int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
__u16 searchHandle, __u16 search_flags,
|
||||
struct cifs_search_info *psrch_inf);
|
||||
int CIFSFindClose(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u16 searchHandle);
|
||||
int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *search_name, __u64 *inode_number,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
int CIFSGetDFSRefer(const unsigned int xid, struct cifs_ses *ses,
|
||||
const char *search_name,
|
||||
struct dfs_info3_param **target_nodes,
|
||||
unsigned int *num_of_nodes,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
int SMBOldQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct kstatfs *FSData);
|
||||
int CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct kstatfs *FSData);
|
||||
int CIFSSMBQFSAttributeInfo(const unsigned int xid, struct cifs_tcon *tcon);
|
||||
int CIFSSMBQFSDeviceInfo(const unsigned int xid, struct cifs_tcon *tcon);
|
||||
int CIFSSMBQFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon);
|
||||
int CIFSSMBSetFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
__u64 cap);
|
||||
int CIFSSMBQFSPosixInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct kstatfs *FSData);
|
||||
int CIFSSMBSetEOF(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *file_name, __u64 size,
|
||||
struct cifs_sb_info *cifs_sb, bool set_allocation,
|
||||
struct dentry *dentry);
|
||||
int CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifsFileInfo *cfile, __u64 size,
|
||||
bool set_allocation);
|
||||
int SMBSetInformation(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *fileName, __le32 attributes,
|
||||
__le64 write_time, const struct nls_table *nls_codepage,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const FILE_BASIC_INFO *data, __u16 fid,
|
||||
__u32 pid_of_opener);
|
||||
int CIFSSMBSetFileDisposition(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
bool delete_file, __u16 fid,
|
||||
__u32 pid_of_opener);
|
||||
int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *fileName, const FILE_BASIC_INFO *data,
|
||||
const struct nls_table *nls_codepage,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
int CIFSSMBUnixSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const struct cifs_unix_set_info_args *args, u16 fid,
|
||||
u32 pid_of_opener);
|
||||
int CIFSSMBUnixSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *file_name,
|
||||
const struct cifs_unix_set_info_args *args,
|
||||
const struct nls_table *nls_codepage, int remap);
|
||||
ssize_t CIFSSMBQAllEAs(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const unsigned char *searchName,
|
||||
const unsigned char *ea_name, char *EAData,
|
||||
size_t buf_size, struct cifs_sb_info *cifs_sb);
|
||||
int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *fileName, const char *ea_name,
|
||||
const void *ea_value, const __u16 ea_value_len,
|
||||
const struct nls_table *nls_codepage,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
|
||||
/*
|
||||
* smb1debug.c
|
||||
*/
|
||||
void cifs_dump_detail(void *buf, size_t buf_len,
|
||||
struct TCP_Server_Info *server);
|
||||
|
||||
/*
|
||||
* smb1encrypt.c
|
||||
*/
|
||||
int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
|
||||
__u32 *pexpected_response_sequence_number);
|
||||
int cifs_verify_signature(struct smb_rqst *rqst,
|
||||
struct TCP_Server_Info *server,
|
||||
__u32 expected_sequence_number);
|
||||
|
||||
/*
|
||||
* smb1maperror.c
|
||||
*/
|
||||
int map_smb_to_linux_error(char *buf, bool logErr);
|
||||
int map_and_check_smb_error(struct TCP_Server_Info *server,
|
||||
struct mid_q_entry *mid, bool logErr);
|
||||
|
||||
/*
|
||||
* smb1misc.c
|
||||
*/
|
||||
unsigned int header_assemble(struct smb_hdr *buffer, char smb_command,
|
||||
const struct cifs_tcon *treeCon, int word_count);
|
||||
bool is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv);
|
||||
unsigned int smbCalcSize(void *buf);
|
||||
|
||||
/*
|
||||
* smb1ops.c
|
||||
*/
|
||||
extern struct smb_version_operations smb1_operations;
|
||||
extern struct smb_version_values smb1_values;
|
||||
|
||||
void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
struct smb3_fs_context *ctx);
|
||||
|
||||
/*
|
||||
* smb1session.c
|
||||
*/
|
||||
int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const struct nls_table *nls_cp);
|
||||
|
||||
/*
|
||||
* smb1transport.c
|
||||
*/
|
||||
struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst);
|
||||
int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
|
||||
char *in_buf, unsigned int in_len, int flags);
|
||||
int cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
|
||||
bool log_error);
|
||||
struct mid_q_entry *cifs_setup_request(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst);
|
||||
int SendReceive2(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct kvec *iov, int n_vec, int *resp_buf_type /* ret */,
|
||||
const int flags, struct kvec *resp_iov);
|
||||
int SendReceive(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct smb_hdr *in_buf, unsigned int in_len,
|
||||
struct smb_hdr *out_buf, int *pbytes_returned,
|
||||
const int flags);
|
||||
bool cifs_check_trans2(struct mid_q_entry *mid, struct TCP_Server_Info *server,
|
||||
char *buf, int malformed);
|
||||
int checkSMB(char *buf, unsigned int pdu_len, unsigned int total_read,
|
||||
struct TCP_Server_Info *server);
|
||||
|
||||
|
||||
static inline __u16
|
||||
get_mid(const struct smb_hdr *smb)
|
||||
{
|
||||
return le16_to_cpu(smb->Mid);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
compare_mid(__u16 mid, const struct smb_hdr *smb)
|
||||
{
|
||||
return mid == le16_to_cpu(smb->Mid);
|
||||
}
|
||||
|
||||
#define GETU16(var) (*((__u16 *)var)) /* BB check for endian issues */
|
||||
#define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */
|
||||
|
||||
/* given a pointer to an smb_hdr, retrieve a void pointer to the ByteCount */
|
||||
static inline void *
|
||||
BCC(struct smb_hdr *smb)
|
||||
{
|
||||
return (void *)smb + sizeof(*smb) + 2 * smb->WordCount;
|
||||
}
|
||||
|
||||
/* given a pointer to an smb_hdr retrieve the pointer to the byte area */
|
||||
#define pByteArea(smb_var) (BCC(smb_var) + 2)
|
||||
|
||||
/* get the unconverted ByteCount for a SMB packet and return it */
|
||||
static inline __u16
|
||||
get_bcc(struct smb_hdr *hdr)
|
||||
{
|
||||
__le16 *bc_ptr = (__le16 *)BCC(hdr);
|
||||
|
||||
return get_unaligned_le16(bc_ptr);
|
||||
}
|
||||
|
||||
/* set the ByteCount for a SMB packet in little-endian */
|
||||
static inline void
|
||||
put_bcc(__u16 count, struct smb_hdr *hdr)
|
||||
{
|
||||
__le16 *bc_ptr = (__le16 *)BCC(hdr);
|
||||
|
||||
put_unaligned_le16(count, bc_ptr);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
|
||||
|
||||
#endif /* _SMB1PROTO_H */
|
||||
995
fs/smb/client/smb1session.c
Normal file
995
fs/smb/client/smb1session.c
Normal file
|
|
@ -0,0 +1,995 @@
|
|||
// SPDX-License-Identifier: LGPL-2.1
|
||||
/*
|
||||
*
|
||||
* SMB/CIFS session setup handling routines
|
||||
*
|
||||
* Copyright (c) International Business Machines Corp., 2006, 2009
|
||||
* Author(s): Steve French (sfrench@us.ibm.com)
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cifsproto.h"
|
||||
#include "smb1proto.h"
|
||||
#include "ntlmssp.h"
|
||||
#include "nterr.h"
|
||||
#include "cifs_spnego.h"
|
||||
#include "cifs_unicode.h"
|
||||
#include "cifs_debug.h"
|
||||
|
||||
struct sess_data {
|
||||
unsigned int xid;
|
||||
struct cifs_ses *ses;
|
||||
struct TCP_Server_Info *server;
|
||||
struct nls_table *nls_cp;
|
||||
void (*func)(struct sess_data *);
|
||||
int result;
|
||||
unsigned int in_len;
|
||||
|
||||
/* we will send the SMB in three pieces:
|
||||
* a fixed length beginning part, an optional
|
||||
* SPNEGO blob (which can be zero length), and a
|
||||
* last part which will include the strings
|
||||
* and rest of bcc area. This allows us to avoid
|
||||
* a large buffer 17K allocation
|
||||
*/
|
||||
int buf0_type;
|
||||
struct kvec iov[3];
|
||||
};
|
||||
|
||||
static __u32 cifs_ssetup_hdr(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
SESSION_SETUP_ANDX *pSMB)
|
||||
{
|
||||
__u32 capabilities = 0;
|
||||
|
||||
/* init fields common to all four types of SessSetup */
|
||||
/* Note that offsets for first seven fields in req struct are same */
|
||||
/* in CIFS Specs so does not matter which of 3 forms of struct */
|
||||
/* that we use in next few lines */
|
||||
/* Note that header is initialized to zero in header_assemble */
|
||||
pSMB->req.AndXCommand = 0xFF;
|
||||
pSMB->req.MaxBufferSize = cpu_to_le16(min_t(u32,
|
||||
CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4,
|
||||
USHRT_MAX));
|
||||
pSMB->req.MaxMpxCount = cpu_to_le16(server->maxReq);
|
||||
pSMB->req.VcNumber = cpu_to_le16(1);
|
||||
pSMB->req.SessionKey = server->session_key_id;
|
||||
|
||||
/* Now no need to set SMBFLG_CASELESS or obsolete CANONICAL PATH */
|
||||
|
||||
/* BB verify whether signing required on neg or just auth frame (and NTLM case) */
|
||||
|
||||
capabilities = CAP_LARGE_FILES | CAP_NT_SMBS | CAP_LEVEL_II_OPLOCKS |
|
||||
CAP_LARGE_WRITE_X | CAP_LARGE_READ_X;
|
||||
|
||||
if (server->sign)
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
|
||||
|
||||
if (ses->capabilities & CAP_UNICODE) {
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_UNICODE;
|
||||
capabilities |= CAP_UNICODE;
|
||||
}
|
||||
if (ses->capabilities & CAP_STATUS32) {
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_ERR_STATUS;
|
||||
capabilities |= CAP_STATUS32;
|
||||
}
|
||||
if (ses->capabilities & CAP_DFS) {
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_DFS;
|
||||
capabilities |= CAP_DFS;
|
||||
}
|
||||
if (ses->capabilities & CAP_UNIX)
|
||||
capabilities |= CAP_UNIX;
|
||||
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
static void
|
||||
unicode_oslm_strings(char **pbcc_area, const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
int bytes_ret = 0;
|
||||
|
||||
/* Copy OS version */
|
||||
bytes_ret = cifs_strtoUTF16((__le16 *)bcc_ptr, "Linux version ", 32,
|
||||
nls_cp);
|
||||
bcc_ptr += 2 * bytes_ret;
|
||||
bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, init_utsname()->release,
|
||||
32, nls_cp);
|
||||
bcc_ptr += 2 * bytes_ret;
|
||||
bcc_ptr += 2; /* trailing null */
|
||||
|
||||
bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, CIFS_NETWORK_OPSYS,
|
||||
32, nls_cp);
|
||||
bcc_ptr += 2 * bytes_ret;
|
||||
bcc_ptr += 2; /* trailing null */
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void
|
||||
ascii_oslm_strings(char **pbcc_area, const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
|
||||
strcpy(bcc_ptr, "Linux version ");
|
||||
bcc_ptr += strlen("Linux version ");
|
||||
strcpy(bcc_ptr, init_utsname()->release);
|
||||
bcc_ptr += strlen(init_utsname()->release) + 1;
|
||||
|
||||
strcpy(bcc_ptr, CIFS_NETWORK_OPSYS);
|
||||
bcc_ptr += strlen(CIFS_NETWORK_OPSYS) + 1;
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
int bytes_ret = 0;
|
||||
|
||||
/* copy domain */
|
||||
if (ses->domainName == NULL) {
|
||||
/*
|
||||
* Sending null domain better than using a bogus domain name (as
|
||||
* we did briefly in 2.6.18) since server will use its default
|
||||
*/
|
||||
*bcc_ptr = 0;
|
||||
*(bcc_ptr+1) = 0;
|
||||
bytes_ret = 0;
|
||||
} else
|
||||
bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->domainName,
|
||||
CIFS_MAX_DOMAINNAME_LEN, nls_cp);
|
||||
bcc_ptr += 2 * bytes_ret;
|
||||
bcc_ptr += 2; /* account for null terminator */
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void ascii_domain_string(char **pbcc_area, struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
int len;
|
||||
|
||||
/* copy domain */
|
||||
if (ses->domainName != NULL) {
|
||||
len = strscpy(bcc_ptr, ses->domainName, CIFS_MAX_DOMAINNAME_LEN);
|
||||
if (WARN_ON_ONCE(len < 0))
|
||||
len = CIFS_MAX_DOMAINNAME_LEN - 1;
|
||||
bcc_ptr += len;
|
||||
} /* else we send a null domain name so server will default to its own domain */
|
||||
*bcc_ptr = 0;
|
||||
bcc_ptr++;
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
int bytes_ret = 0;
|
||||
|
||||
/* BB FIXME add check that strings less than 335 or will need to send as arrays */
|
||||
|
||||
/* copy user */
|
||||
if (ses->user_name == NULL) {
|
||||
/* null user mount */
|
||||
*bcc_ptr = 0;
|
||||
*(bcc_ptr+1) = 0;
|
||||
} else {
|
||||
bytes_ret = cifs_strtoUTF16((__le16 *) bcc_ptr, ses->user_name,
|
||||
CIFS_MAX_USERNAME_LEN, nls_cp);
|
||||
}
|
||||
bcc_ptr += 2 * bytes_ret;
|
||||
bcc_ptr += 2; /* account for null termination */
|
||||
|
||||
unicode_domain_string(&bcc_ptr, ses, nls_cp);
|
||||
unicode_oslm_strings(&bcc_ptr, nls_cp);
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void ascii_ssetup_strings(char **pbcc_area, struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
int len;
|
||||
|
||||
/* copy user */
|
||||
/* BB what about null user mounts - check that we do this BB */
|
||||
/* copy user */
|
||||
if (ses->user_name != NULL) {
|
||||
len = strscpy(bcc_ptr, ses->user_name, CIFS_MAX_USERNAME_LEN);
|
||||
if (WARN_ON_ONCE(len < 0))
|
||||
len = CIFS_MAX_USERNAME_LEN - 1;
|
||||
bcc_ptr += len;
|
||||
}
|
||||
/* else null user mount */
|
||||
*bcc_ptr = 0;
|
||||
bcc_ptr++; /* account for null termination */
|
||||
|
||||
/* BB check for overflow here */
|
||||
|
||||
ascii_domain_string(&bcc_ptr, ses, nls_cp);
|
||||
ascii_oslm_strings(&bcc_ptr, nls_cp);
|
||||
|
||||
*pbcc_area = bcc_ptr;
|
||||
}
|
||||
|
||||
static void
|
||||
decode_unicode_ssetup(char **pbcc_area, int bleft, struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
int len;
|
||||
char *data = *pbcc_area;
|
||||
|
||||
cifs_dbg(FYI, "bleft %d\n", bleft);
|
||||
|
||||
kfree(ses->serverOS);
|
||||
ses->serverOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp);
|
||||
cifs_dbg(FYI, "serverOS=%s\n", ses->serverOS);
|
||||
len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
|
||||
data += len;
|
||||
bleft -= len;
|
||||
if (bleft <= 0)
|
||||
return;
|
||||
|
||||
kfree(ses->serverNOS);
|
||||
ses->serverNOS = cifs_strndup_from_utf16(data, bleft, true, nls_cp);
|
||||
cifs_dbg(FYI, "serverNOS=%s\n", ses->serverNOS);
|
||||
len = (UniStrnlen((wchar_t *) data, bleft / 2) * 2) + 2;
|
||||
data += len;
|
||||
bleft -= len;
|
||||
if (bleft <= 0)
|
||||
return;
|
||||
|
||||
kfree(ses->serverDomain);
|
||||
ses->serverDomain = cifs_strndup_from_utf16(data, bleft, true, nls_cp);
|
||||
cifs_dbg(FYI, "serverDomain=%s\n", ses->serverDomain);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void decode_ascii_ssetup(char **pbcc_area, __u16 bleft,
|
||||
struct cifs_ses *ses,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
int len;
|
||||
char *bcc_ptr = *pbcc_area;
|
||||
|
||||
cifs_dbg(FYI, "decode sessetup ascii. bleft %d\n", bleft);
|
||||
|
||||
len = strnlen(bcc_ptr, bleft);
|
||||
if (len >= bleft)
|
||||
return;
|
||||
|
||||
kfree(ses->serverOS);
|
||||
|
||||
ses->serverOS = kmalloc(len + 1, GFP_KERNEL);
|
||||
if (ses->serverOS) {
|
||||
memcpy(ses->serverOS, bcc_ptr, len);
|
||||
ses->serverOS[len] = 0;
|
||||
if (strncmp(ses->serverOS, "OS/2", 4) == 0)
|
||||
cifs_dbg(FYI, "OS/2 server\n");
|
||||
}
|
||||
|
||||
bcc_ptr += len + 1;
|
||||
bleft -= len + 1;
|
||||
|
||||
len = strnlen(bcc_ptr, bleft);
|
||||
if (len >= bleft)
|
||||
return;
|
||||
|
||||
kfree(ses->serverNOS);
|
||||
|
||||
ses->serverNOS = kmalloc(len + 1, GFP_KERNEL);
|
||||
if (ses->serverNOS) {
|
||||
memcpy(ses->serverNOS, bcc_ptr, len);
|
||||
ses->serverNOS[len] = 0;
|
||||
}
|
||||
|
||||
bcc_ptr += len + 1;
|
||||
bleft -= len + 1;
|
||||
|
||||
len = strnlen(bcc_ptr, bleft);
|
||||
if (len > bleft)
|
||||
return;
|
||||
|
||||
/*
|
||||
* No domain field in LANMAN case. Domain is
|
||||
* returned by old servers in the SMB negprot response
|
||||
*
|
||||
* BB For newer servers which do not support Unicode,
|
||||
* but thus do return domain here, we could add parsing
|
||||
* for it later, but it is not very important
|
||||
*/
|
||||
cifs_dbg(FYI, "ascii: bytes left %d\n", bleft);
|
||||
}
|
||||
|
||||
static int
|
||||
sess_alloc_buffer(struct sess_data *sess_data, int wct)
|
||||
{
|
||||
int rc;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct smb_hdr *smb_buf;
|
||||
|
||||
rc = small_smb_init_no_tc(SMB_COM_SESSION_SETUP_ANDX, wct, ses,
|
||||
(void **)&smb_buf);
|
||||
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
sess_data->in_len = rc;
|
||||
sess_data->iov[0].iov_base = (char *)smb_buf;
|
||||
sess_data->iov[0].iov_len = sess_data->in_len;
|
||||
/*
|
||||
* This variable will be used to clear the buffer
|
||||
* allocated above in case of any error in the calling function.
|
||||
*/
|
||||
sess_data->buf0_type = CIFS_SMALL_BUFFER;
|
||||
|
||||
/* 2000 big enough to fit max user, domain, NOS name etc. */
|
||||
sess_data->iov[2].iov_base = kmalloc(2000, GFP_KERNEL);
|
||||
if (!sess_data->iov[2].iov_base) {
|
||||
rc = -ENOMEM;
|
||||
goto out_free_smb_buf;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
out_free_smb_buf:
|
||||
cifs_small_buf_release(smb_buf);
|
||||
sess_data->iov[0].iov_base = NULL;
|
||||
sess_data->iov[0].iov_len = 0;
|
||||
sess_data->buf0_type = CIFS_NO_BUFFER;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void
|
||||
sess_free_buffer(struct sess_data *sess_data)
|
||||
{
|
||||
struct kvec *iov = sess_data->iov;
|
||||
|
||||
/*
|
||||
* Zero the session data before freeing, as it might contain sensitive info (keys, etc).
|
||||
* Note that iov[1] is already freed by caller.
|
||||
*/
|
||||
if (sess_data->buf0_type != CIFS_NO_BUFFER && iov[0].iov_base)
|
||||
memzero_explicit(iov[0].iov_base, iov[0].iov_len);
|
||||
|
||||
free_rsp_buf(sess_data->buf0_type, iov[0].iov_base);
|
||||
sess_data->buf0_type = CIFS_NO_BUFFER;
|
||||
kfree_sensitive(iov[2].iov_base);
|
||||
}
|
||||
|
||||
static int
|
||||
sess_establish_session(struct sess_data *sess_data)
|
||||
{
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
|
||||
cifs_server_lock(server);
|
||||
if (!server->session_estab) {
|
||||
if (server->sign) {
|
||||
server->session_key.response =
|
||||
kmemdup(ses->auth_key.response,
|
||||
ses->auth_key.len, GFP_KERNEL);
|
||||
if (!server->session_key.response) {
|
||||
cifs_server_unlock(server);
|
||||
return -ENOMEM;
|
||||
}
|
||||
server->session_key.len =
|
||||
ses->auth_key.len;
|
||||
}
|
||||
server->sequence_number = 0x2;
|
||||
server->session_estab = true;
|
||||
}
|
||||
cifs_server_unlock(server);
|
||||
|
||||
cifs_dbg(FYI, "CIFS session established successfully\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sess_sendreceive(struct sess_data *sess_data)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *smb_buf = (struct smb_hdr *) sess_data->iov[0].iov_base;
|
||||
__u16 count;
|
||||
struct kvec rsp_iov = { NULL, 0 };
|
||||
|
||||
count = sess_data->iov[1].iov_len + sess_data->iov[2].iov_len;
|
||||
sess_data->in_len += count;
|
||||
put_bcc(count, smb_buf);
|
||||
|
||||
rc = SendReceive2(sess_data->xid, sess_data->ses,
|
||||
sess_data->iov, 3 /* num_iovecs */,
|
||||
&sess_data->buf0_type,
|
||||
CIFS_LOG_ERROR, &rsp_iov);
|
||||
cifs_small_buf_release(sess_data->iov[0].iov_base);
|
||||
memcpy(&sess_data->iov[0], &rsp_iov, sizeof(struct kvec));
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void
|
||||
sess_auth_ntlmv2(struct sess_data *sess_data)
|
||||
{
|
||||
int rc = 0;
|
||||
struct smb_hdr *smb_buf;
|
||||
SESSION_SETUP_ANDX *pSMB;
|
||||
char *bcc_ptr;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
__u32 capabilities;
|
||||
__u16 bytes_remaining;
|
||||
|
||||
/* old style NTLM sessionsetup */
|
||||
/* wct = 13 */
|
||||
rc = sess_alloc_buffer(sess_data, 13);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
bcc_ptr = sess_data->iov[2].iov_base;
|
||||
capabilities = cifs_ssetup_hdr(ses, server, pSMB);
|
||||
|
||||
pSMB->req_no_secext.Capabilities = cpu_to_le32(capabilities);
|
||||
|
||||
/* LM2 password would be here if we supported it */
|
||||
pSMB->req_no_secext.CaseInsensitivePasswordLength = 0;
|
||||
|
||||
if (ses->user_name != NULL) {
|
||||
/* calculate nlmv2 response and session key */
|
||||
rc = setup_ntlmv2_rsp(ses, sess_data->nls_cp);
|
||||
if (rc) {
|
||||
cifs_dbg(VFS, "Error %d during NTLMv2 authentication\n", rc);
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(bcc_ptr, ses->auth_key.response + CIFS_SESS_KEY_SIZE,
|
||||
ses->auth_key.len - CIFS_SESS_KEY_SIZE);
|
||||
bcc_ptr += ses->auth_key.len - CIFS_SESS_KEY_SIZE;
|
||||
|
||||
/* set case sensitive password length after tilen may get
|
||||
* assigned, tilen is 0 otherwise.
|
||||
*/
|
||||
pSMB->req_no_secext.CaseSensitivePasswordLength =
|
||||
cpu_to_le16(ses->auth_key.len - CIFS_SESS_KEY_SIZE);
|
||||
} else {
|
||||
pSMB->req_no_secext.CaseSensitivePasswordLength = 0;
|
||||
}
|
||||
|
||||
if (ses->capabilities & CAP_UNICODE) {
|
||||
if (!IS_ALIGNED(sess_data->iov[0].iov_len, 2)) {
|
||||
*bcc_ptr = 0;
|
||||
bcc_ptr++;
|
||||
}
|
||||
unicode_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp);
|
||||
} else {
|
||||
ascii_ssetup_strings(&bcc_ptr, ses, sess_data->nls_cp);
|
||||
}
|
||||
|
||||
|
||||
sess_data->iov[2].iov_len = (long) bcc_ptr -
|
||||
(long) sess_data->iov[2].iov_base;
|
||||
|
||||
rc = sess_sendreceive(sess_data);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base;
|
||||
|
||||
if (smb_buf->WordCount != 3) {
|
||||
rc = smb_EIO1(smb_eio_trace_sess_nl2_wcc, smb_buf->WordCount);
|
||||
cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (le16_to_cpu(pSMB->resp.Action) & GUEST_LOGIN)
|
||||
cifs_dbg(FYI, "Guest login\n"); /* BB mark SesInfo struct? */
|
||||
|
||||
ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */
|
||||
cifs_dbg(FYI, "UID = %llu\n", ses->Suid);
|
||||
|
||||
bytes_remaining = get_bcc(smb_buf);
|
||||
bcc_ptr = pByteArea(smb_buf);
|
||||
|
||||
/* BB check if Unicode and decode strings */
|
||||
if (bytes_remaining == 0) {
|
||||
/* no string area to decode, do nothing */
|
||||
} else if (smb_buf->Flags2 & SMBFLG2_UNICODE) {
|
||||
/* unicode string area must be word-aligned */
|
||||
if (!IS_ALIGNED((unsigned long)bcc_ptr - (unsigned long)smb_buf, 2)) {
|
||||
++bcc_ptr;
|
||||
--bytes_remaining;
|
||||
}
|
||||
decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
} else {
|
||||
decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
}
|
||||
|
||||
rc = sess_establish_session(sess_data);
|
||||
out:
|
||||
sess_data->result = rc;
|
||||
sess_data->func = NULL;
|
||||
sess_free_buffer(sess_data);
|
||||
kfree_sensitive(ses->auth_key.response);
|
||||
ses->auth_key.response = NULL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CIFS_UPCALL
|
||||
static void
|
||||
sess_auth_kerberos(struct sess_data *sess_data)
|
||||
{
|
||||
int rc = 0;
|
||||
struct smb_hdr *smb_buf;
|
||||
SESSION_SETUP_ANDX *pSMB;
|
||||
char *bcc_ptr;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
__u32 capabilities;
|
||||
__u16 bytes_remaining;
|
||||
struct key *spnego_key = NULL;
|
||||
struct cifs_spnego_msg *msg;
|
||||
u16 blob_len;
|
||||
|
||||
/* extended security */
|
||||
/* wct = 12 */
|
||||
rc = sess_alloc_buffer(sess_data, 12);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
bcc_ptr = sess_data->iov[2].iov_base;
|
||||
capabilities = cifs_ssetup_hdr(ses, server, pSMB);
|
||||
|
||||
spnego_key = cifs_get_spnego_key(ses, server);
|
||||
if (IS_ERR(spnego_key)) {
|
||||
rc = PTR_ERR(spnego_key);
|
||||
spnego_key = NULL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
msg = spnego_key->payload.data[0];
|
||||
/*
|
||||
* check version field to make sure that cifs.upcall is
|
||||
* sending us a response in an expected form
|
||||
*/
|
||||
if (msg->version != CIFS_SPNEGO_UPCALL_VERSION) {
|
||||
cifs_dbg(VFS, "incorrect version of cifs.upcall (expected %d but got %d)\n",
|
||||
CIFS_SPNEGO_UPCALL_VERSION, msg->version);
|
||||
rc = -EKEYREJECTED;
|
||||
goto out_put_spnego_key;
|
||||
}
|
||||
|
||||
kfree_sensitive(ses->auth_key.response);
|
||||
ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len,
|
||||
GFP_KERNEL);
|
||||
if (!ses->auth_key.response) {
|
||||
cifs_dbg(VFS, "Kerberos can't allocate (%u bytes) memory\n",
|
||||
msg->sesskey_len);
|
||||
rc = -ENOMEM;
|
||||
goto out_put_spnego_key;
|
||||
}
|
||||
ses->auth_key.len = msg->sesskey_len;
|
||||
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
|
||||
capabilities |= CAP_EXTENDED_SECURITY;
|
||||
pSMB->req.Capabilities = cpu_to_le32(capabilities);
|
||||
sess_data->iov[1].iov_base = msg->data + msg->sesskey_len;
|
||||
sess_data->iov[1].iov_len = msg->secblob_len;
|
||||
pSMB->req.SecurityBlobLength = cpu_to_le16(sess_data->iov[1].iov_len);
|
||||
|
||||
if (pSMB->req.hdr.Flags2 & SMBFLG2_UNICODE) {
|
||||
/* unicode strings must be word aligned */
|
||||
if (!IS_ALIGNED(sess_data->iov[0].iov_len + sess_data->iov[1].iov_len, 2)) {
|
||||
*bcc_ptr = 0;
|
||||
bcc_ptr++;
|
||||
}
|
||||
unicode_oslm_strings(&bcc_ptr, sess_data->nls_cp);
|
||||
unicode_domain_string(&bcc_ptr, ses, sess_data->nls_cp);
|
||||
} else {
|
||||
ascii_oslm_strings(&bcc_ptr, sess_data->nls_cp);
|
||||
ascii_domain_string(&bcc_ptr, ses, sess_data->nls_cp);
|
||||
}
|
||||
|
||||
sess_data->iov[2].iov_len = (long) bcc_ptr -
|
||||
(long) sess_data->iov[2].iov_base;
|
||||
|
||||
rc = sess_sendreceive(sess_data);
|
||||
if (rc)
|
||||
goto out_put_spnego_key;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base;
|
||||
|
||||
if (smb_buf->WordCount != 4) {
|
||||
rc = smb_EIO1(smb_eio_trace_sess_krb_wcc, smb_buf->WordCount);
|
||||
cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount);
|
||||
goto out_put_spnego_key;
|
||||
}
|
||||
|
||||
if (le16_to_cpu(pSMB->resp.Action) & GUEST_LOGIN)
|
||||
cifs_dbg(FYI, "Guest login\n"); /* BB mark SesInfo struct? */
|
||||
|
||||
ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */
|
||||
cifs_dbg(FYI, "UID = %llu\n", ses->Suid);
|
||||
|
||||
bytes_remaining = get_bcc(smb_buf);
|
||||
bcc_ptr = pByteArea(smb_buf);
|
||||
|
||||
blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
|
||||
if (blob_len > bytes_remaining) {
|
||||
cifs_dbg(VFS, "bad security blob length %d\n",
|
||||
blob_len);
|
||||
rc = -EINVAL;
|
||||
goto out_put_spnego_key;
|
||||
}
|
||||
bcc_ptr += blob_len;
|
||||
bytes_remaining -= blob_len;
|
||||
|
||||
/* BB check if Unicode and decode strings */
|
||||
if (bytes_remaining == 0) {
|
||||
/* no string area to decode, do nothing */
|
||||
} else if (smb_buf->Flags2 & SMBFLG2_UNICODE) {
|
||||
/* unicode string area must be word-aligned */
|
||||
if (!IS_ALIGNED((unsigned long)bcc_ptr - (unsigned long)smb_buf, 2)) {
|
||||
++bcc_ptr;
|
||||
--bytes_remaining;
|
||||
}
|
||||
decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
} else {
|
||||
decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
}
|
||||
|
||||
rc = sess_establish_session(sess_data);
|
||||
out_put_spnego_key:
|
||||
key_invalidate(spnego_key);
|
||||
key_put(spnego_key);
|
||||
out:
|
||||
sess_data->result = rc;
|
||||
sess_data->func = NULL;
|
||||
sess_free_buffer(sess_data);
|
||||
kfree_sensitive(ses->auth_key.response);
|
||||
ses->auth_key.response = NULL;
|
||||
}
|
||||
|
||||
#endif /* ! CONFIG_CIFS_UPCALL */
|
||||
|
||||
/*
|
||||
* The required kvec buffers have to be allocated before calling this
|
||||
* function.
|
||||
*/
|
||||
static int
|
||||
_sess_auth_rawntlmssp_assemble_req(struct sess_data *sess_data)
|
||||
{
|
||||
SESSION_SETUP_ANDX *pSMB;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
__u32 capabilities;
|
||||
char *bcc_ptr;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
|
||||
capabilities = cifs_ssetup_hdr(ses, server, pSMB);
|
||||
pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
|
||||
capabilities |= CAP_EXTENDED_SECURITY;
|
||||
pSMB->req.Capabilities |= cpu_to_le32(capabilities);
|
||||
|
||||
bcc_ptr = sess_data->iov[2].iov_base;
|
||||
|
||||
if (pSMB->req.hdr.Flags2 & SMBFLG2_UNICODE) {
|
||||
/* unicode strings must be word aligned */
|
||||
if (!IS_ALIGNED(sess_data->iov[0].iov_len + sess_data->iov[1].iov_len, 2)) {
|
||||
*bcc_ptr = 0;
|
||||
bcc_ptr++;
|
||||
}
|
||||
unicode_oslm_strings(&bcc_ptr, sess_data->nls_cp);
|
||||
} else {
|
||||
ascii_oslm_strings(&bcc_ptr, sess_data->nls_cp);
|
||||
}
|
||||
|
||||
sess_data->iov[2].iov_len = (long) bcc_ptr -
|
||||
(long) sess_data->iov[2].iov_base;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data);
|
||||
|
||||
static void
|
||||
sess_auth_rawntlmssp_negotiate(struct sess_data *sess_data)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *smb_buf;
|
||||
SESSION_SETUP_ANDX *pSMB;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
__u16 bytes_remaining;
|
||||
char *bcc_ptr;
|
||||
unsigned char *ntlmsspblob = NULL;
|
||||
u16 blob_len;
|
||||
|
||||
cifs_dbg(FYI, "rawntlmssp session setup negotiate phase\n");
|
||||
|
||||
/*
|
||||
* if memory allocation is successful, caller of this function
|
||||
* frees it.
|
||||
*/
|
||||
ses->ntlmssp = kmalloc(sizeof(struct ntlmssp_auth), GFP_KERNEL);
|
||||
if (!ses->ntlmssp) {
|
||||
rc = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
ses->ntlmssp->sesskey_per_smbsess = false;
|
||||
|
||||
/* wct = 12 */
|
||||
rc = sess_alloc_buffer(sess_data, 12);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
|
||||
/* Build security blob before we assemble the request */
|
||||
rc = build_ntlmssp_negotiate_blob(&ntlmsspblob,
|
||||
&blob_len, ses, server,
|
||||
sess_data->nls_cp);
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
|
||||
sess_data->iov[1].iov_len = blob_len;
|
||||
sess_data->iov[1].iov_base = ntlmsspblob;
|
||||
pSMB->req.SecurityBlobLength = cpu_to_le16(blob_len);
|
||||
|
||||
rc = _sess_auth_rawntlmssp_assemble_req(sess_data);
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
|
||||
rc = sess_sendreceive(sess_data);
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base;
|
||||
|
||||
/* If true, rc here is expected and not an error */
|
||||
if (sess_data->buf0_type != CIFS_NO_BUFFER &&
|
||||
smb_buf->Status.CifsError ==
|
||||
cpu_to_le32(NT_STATUS_MORE_PROCESSING_REQUIRED))
|
||||
rc = 0;
|
||||
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
|
||||
cifs_dbg(FYI, "rawntlmssp session setup challenge phase\n");
|
||||
|
||||
if (smb_buf->WordCount != 4) {
|
||||
rc = smb_EIO1(smb_eio_trace_sess_rawnl_neg_wcc, smb_buf->WordCount);
|
||||
cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount);
|
||||
goto out_free_ntlmsspblob;
|
||||
}
|
||||
|
||||
ses->Suid = smb_buf->Uid; /* UID left in wire format (le) */
|
||||
cifs_dbg(FYI, "UID = %llu\n", ses->Suid);
|
||||
|
||||
bytes_remaining = get_bcc(smb_buf);
|
||||
bcc_ptr = pByteArea(smb_buf);
|
||||
|
||||
blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
|
||||
if (blob_len > bytes_remaining) {
|
||||
cifs_dbg(VFS, "bad security blob length %d\n",
|
||||
blob_len);
|
||||
rc = -EINVAL;
|
||||
goto out_free_ntlmsspblob;
|
||||
}
|
||||
|
||||
rc = decode_ntlmssp_challenge(bcc_ptr, blob_len, ses);
|
||||
|
||||
out_free_ntlmsspblob:
|
||||
kfree_sensitive(ntlmsspblob);
|
||||
out:
|
||||
sess_free_buffer(sess_data);
|
||||
|
||||
if (!rc) {
|
||||
sess_data->func = sess_auth_rawntlmssp_authenticate;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Else error. Cleanup */
|
||||
kfree_sensitive(ses->auth_key.response);
|
||||
ses->auth_key.response = NULL;
|
||||
kfree_sensitive(ses->ntlmssp);
|
||||
ses->ntlmssp = NULL;
|
||||
|
||||
sess_data->func = NULL;
|
||||
sess_data->result = rc;
|
||||
}
|
||||
|
||||
static void
|
||||
sess_auth_rawntlmssp_authenticate(struct sess_data *sess_data)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *smb_buf;
|
||||
SESSION_SETUP_ANDX *pSMB;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
__u16 bytes_remaining;
|
||||
char *bcc_ptr;
|
||||
unsigned char *ntlmsspblob = NULL;
|
||||
u16 blob_len;
|
||||
|
||||
cifs_dbg(FYI, "rawntlmssp session setup authenticate phase\n");
|
||||
|
||||
/* wct = 12 */
|
||||
rc = sess_alloc_buffer(sess_data, 12);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
/* Build security blob before we assemble the request */
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
smb_buf = (struct smb_hdr *)pSMB;
|
||||
rc = build_ntlmssp_auth_blob(&ntlmsspblob,
|
||||
&blob_len, ses, server,
|
||||
sess_data->nls_cp);
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
sess_data->iov[1].iov_len = blob_len;
|
||||
sess_data->iov[1].iov_base = ntlmsspblob;
|
||||
pSMB->req.SecurityBlobLength = cpu_to_le16(blob_len);
|
||||
/*
|
||||
* Make sure that we tell the server that we are using
|
||||
* the uid that it just gave us back on the response
|
||||
* (challenge)
|
||||
*/
|
||||
smb_buf->Uid = ses->Suid;
|
||||
|
||||
rc = _sess_auth_rawntlmssp_assemble_req(sess_data);
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
|
||||
rc = sess_sendreceive(sess_data);
|
||||
if (rc)
|
||||
goto out_free_ntlmsspblob;
|
||||
|
||||
pSMB = (SESSION_SETUP_ANDX *)sess_data->iov[0].iov_base;
|
||||
smb_buf = (struct smb_hdr *)sess_data->iov[0].iov_base;
|
||||
if (smb_buf->WordCount != 4) {
|
||||
rc = smb_EIO1(smb_eio_trace_sess_rawnl_auth_wcc, smb_buf->WordCount);
|
||||
cifs_dbg(VFS, "bad word count %d\n", smb_buf->WordCount);
|
||||
goto out_free_ntlmsspblob;
|
||||
}
|
||||
|
||||
if (le16_to_cpu(pSMB->resp.Action) & GUEST_LOGIN)
|
||||
cifs_dbg(FYI, "Guest login\n"); /* BB mark SesInfo struct? */
|
||||
|
||||
if (ses->Suid != smb_buf->Uid) {
|
||||
ses->Suid = smb_buf->Uid;
|
||||
cifs_dbg(FYI, "UID changed! new UID = %llu\n", ses->Suid);
|
||||
}
|
||||
|
||||
bytes_remaining = get_bcc(smb_buf);
|
||||
bcc_ptr = pByteArea(smb_buf);
|
||||
blob_len = le16_to_cpu(pSMB->resp.SecurityBlobLength);
|
||||
if (blob_len > bytes_remaining) {
|
||||
cifs_dbg(VFS, "bad security blob length %d\n",
|
||||
blob_len);
|
||||
rc = -EINVAL;
|
||||
goto out_free_ntlmsspblob;
|
||||
}
|
||||
bcc_ptr += blob_len;
|
||||
bytes_remaining -= blob_len;
|
||||
|
||||
|
||||
/* BB check if Unicode and decode strings */
|
||||
if (bytes_remaining == 0) {
|
||||
/* no string area to decode, do nothing */
|
||||
} else if (smb_buf->Flags2 & SMBFLG2_UNICODE) {
|
||||
/* unicode string area must be word-aligned */
|
||||
if (!IS_ALIGNED((unsigned long)bcc_ptr - (unsigned long)smb_buf, 2)) {
|
||||
++bcc_ptr;
|
||||
--bytes_remaining;
|
||||
}
|
||||
decode_unicode_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
} else {
|
||||
decode_ascii_ssetup(&bcc_ptr, bytes_remaining, ses,
|
||||
sess_data->nls_cp);
|
||||
}
|
||||
|
||||
out_free_ntlmsspblob:
|
||||
kfree_sensitive(ntlmsspblob);
|
||||
out:
|
||||
sess_free_buffer(sess_data);
|
||||
|
||||
if (!rc)
|
||||
rc = sess_establish_session(sess_data);
|
||||
|
||||
/* Cleanup */
|
||||
kfree_sensitive(ses->auth_key.response);
|
||||
ses->auth_key.response = NULL;
|
||||
kfree_sensitive(ses->ntlmssp);
|
||||
ses->ntlmssp = NULL;
|
||||
|
||||
sess_data->func = NULL;
|
||||
sess_data->result = rc;
|
||||
}
|
||||
|
||||
static int select_sec(struct sess_data *sess_data)
|
||||
{
|
||||
int type;
|
||||
struct cifs_ses *ses = sess_data->ses;
|
||||
struct TCP_Server_Info *server = sess_data->server;
|
||||
|
||||
type = cifs_select_sectype(server, ses->sectype);
|
||||
cifs_dbg(FYI, "sess setup type %d\n", type);
|
||||
if (type == Unspecified) {
|
||||
cifs_dbg(VFS, "Unable to select appropriate authentication method!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case NTLMv2:
|
||||
sess_data->func = sess_auth_ntlmv2;
|
||||
break;
|
||||
case Kerberos:
|
||||
#ifdef CONFIG_CIFS_UPCALL
|
||||
sess_data->func = sess_auth_kerberos;
|
||||
break;
|
||||
#else
|
||||
cifs_dbg(VFS, "Kerberos negotiated but upcall support disabled!\n");
|
||||
return -ENOSYS;
|
||||
#endif /* CONFIG_CIFS_UPCALL */
|
||||
case RawNTLMSSP:
|
||||
sess_data->func = sess_auth_rawntlmssp_negotiate;
|
||||
break;
|
||||
default:
|
||||
cifs_dbg(VFS, "secType %d not supported!\n", type);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const struct nls_table *nls_cp)
|
||||
{
|
||||
int rc = 0;
|
||||
struct sess_data *sess_data;
|
||||
|
||||
if (ses == NULL) {
|
||||
WARN(1, "%s: ses == NULL!", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
sess_data = kzalloc(sizeof(struct sess_data), GFP_KERNEL);
|
||||
if (!sess_data)
|
||||
return -ENOMEM;
|
||||
|
||||
sess_data->xid = xid;
|
||||
sess_data->ses = ses;
|
||||
sess_data->server = server;
|
||||
sess_data->buf0_type = CIFS_NO_BUFFER;
|
||||
sess_data->nls_cp = (struct nls_table *) nls_cp;
|
||||
|
||||
rc = select_sec(sess_data);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
while (sess_data->func)
|
||||
sess_data->func(sess_data);
|
||||
|
||||
/* Store result before we free sess_data */
|
||||
rc = sess_data->result;
|
||||
|
||||
out:
|
||||
kfree_sensitive(sess_data);
|
||||
return rc;
|
||||
}
|
||||
563
fs/smb/client/smb1transport.c
Normal file
563
fs/smb/client/smb1transport.c
Normal file
|
|
@ -0,0 +1,563 @@
|
|||
// SPDX-License-Identifier: LGPL-2.1
|
||||
/*
|
||||
*
|
||||
* Copyright (C) International Business Machines Corp., 2002,2008
|
||||
* Author(s): Steve French (sfrench@us.ibm.com)
|
||||
* Jeremy Allison (jra@samba.org) 2006.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/fs.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/gfp.h>
|
||||
#include <linux/wait.h>
|
||||
#include <linux/net.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/freezer.h>
|
||||
#include <linux/tcp.h>
|
||||
#include <linux/bvec.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/processor.h>
|
||||
#include <linux/mempool.h>
|
||||
#include <linux/sched/signal.h>
|
||||
#include <linux/task_io_accounting_ops.h>
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "smb1proto.h"
|
||||
#include "smb2proto.h"
|
||||
#include "cifs_debug.h"
|
||||
#include "smbdirect.h"
|
||||
#include "compress.h"
|
||||
#include "cifs_debug.h"
|
||||
|
||||
/* Max number of iovectors we can use off the stack when sending requests. */
|
||||
#define CIFS_MAX_IOV_SIZE 8
|
||||
|
||||
static struct mid_q_entry *
|
||||
alloc_mid(const struct smb_hdr *smb_buffer, struct TCP_Server_Info *server)
|
||||
{
|
||||
struct mid_q_entry *temp;
|
||||
|
||||
if (server == NULL) {
|
||||
cifs_dbg(VFS, "%s: null TCP session\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
temp = mempool_alloc(&cifs_mid_pool, GFP_NOFS);
|
||||
memset(temp, 0, sizeof(struct mid_q_entry));
|
||||
refcount_set(&temp->refcount, 1);
|
||||
spin_lock_init(&temp->mid_lock);
|
||||
temp->mid = get_mid(smb_buffer);
|
||||
temp->pid = current->pid;
|
||||
temp->command = cpu_to_le16(smb_buffer->Command);
|
||||
cifs_dbg(FYI, "For smb_command %d\n", smb_buffer->Command);
|
||||
/* easier to use jiffies */
|
||||
/* when mid allocated can be before when sent */
|
||||
temp->when_alloc = jiffies;
|
||||
|
||||
/*
|
||||
* The default is for the mid to be synchronous, so the
|
||||
* default callback just wakes up the current task.
|
||||
*/
|
||||
get_task_struct(current);
|
||||
temp->creator = current;
|
||||
temp->callback = cifs_wake_up_task;
|
||||
temp->callback_data = current;
|
||||
|
||||
atomic_inc(&mid_count);
|
||||
temp->mid_state = MID_REQUEST_ALLOCATED;
|
||||
return temp;
|
||||
}
|
||||
|
||||
static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
|
||||
struct mid_q_entry **ppmidQ)
|
||||
{
|
||||
spin_lock(&ses->ses_lock);
|
||||
if (ses->ses_status == SES_NEW) {
|
||||
if ((in_buf->Command != SMB_COM_SESSION_SETUP_ANDX) &&
|
||||
(in_buf->Command != SMB_COM_NEGOTIATE)) {
|
||||
spin_unlock(&ses->ses_lock);
|
||||
return -EAGAIN;
|
||||
}
|
||||
/* else ok - we are setting up session */
|
||||
}
|
||||
|
||||
if (ses->ses_status == SES_EXITING) {
|
||||
/* check if SMB session is bad because we are setting it up */
|
||||
if (in_buf->Command != SMB_COM_LOGOFF_ANDX) {
|
||||
spin_unlock(&ses->ses_lock);
|
||||
return -EAGAIN;
|
||||
}
|
||||
/* else ok - we are shutting down session */
|
||||
}
|
||||
spin_unlock(&ses->ses_lock);
|
||||
|
||||
*ppmidQ = alloc_mid(in_buf, ses->server);
|
||||
if (*ppmidQ == NULL)
|
||||
return -ENOMEM;
|
||||
spin_lock(&ses->server->mid_queue_lock);
|
||||
list_add_tail(&(*ppmidQ)->qhead, &ses->server->pending_mid_q);
|
||||
spin_unlock(&ses->server->mid_queue_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct mid_q_entry *
|
||||
cifs_setup_async_request(struct TCP_Server_Info *server, struct smb_rqst *rqst)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *hdr = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
|
||||
struct mid_q_entry *mid;
|
||||
|
||||
/* enable signing if server requires it */
|
||||
if (server->sign)
|
||||
hdr->Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
|
||||
|
||||
mid = alloc_mid(hdr, server);
|
||||
if (mid == NULL)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
rc = cifs_sign_rqst(rqst, server, &mid->sequence_number);
|
||||
if (rc) {
|
||||
release_mid(server, mid);
|
||||
return ERR_PTR(rc);
|
||||
}
|
||||
|
||||
return mid;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Send an SMB Request. No response info (other than return code)
|
||||
* needs to be parsed.
|
||||
*
|
||||
* flags indicate the type of request buffer and how long to wait
|
||||
* and whether to log NT STATUS code (error) before mapping it to POSIX error
|
||||
*
|
||||
*/
|
||||
int
|
||||
SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
|
||||
char *in_buf, unsigned int in_len, int flags)
|
||||
{
|
||||
int rc;
|
||||
struct kvec iov[1];
|
||||
struct kvec rsp_iov;
|
||||
int resp_buf_type;
|
||||
|
||||
iov[0].iov_base = in_buf;
|
||||
iov[0].iov_len = in_len;
|
||||
flags |= CIFS_NO_RSP_BUF;
|
||||
rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags, &rsp_iov);
|
||||
cifs_dbg(NOISY, "SendRcvNoRsp flags %d rc %d\n", flags, rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int
|
||||
cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
|
||||
bool log_error)
|
||||
{
|
||||
unsigned int len = mid->response_pdu_len;
|
||||
|
||||
dump_smb(mid->resp_buf, min_t(u32, 92, len));
|
||||
|
||||
/* convert the length into a more usable form */
|
||||
if (server->sign) {
|
||||
struct kvec iov[1];
|
||||
int rc = 0;
|
||||
struct smb_rqst rqst = { .rq_iov = iov,
|
||||
.rq_nvec = ARRAY_SIZE(iov) };
|
||||
|
||||
iov[0].iov_base = mid->resp_buf;
|
||||
iov[0].iov_len = len;
|
||||
/* FIXME: add code to kill session */
|
||||
rc = cifs_verify_signature(&rqst, server,
|
||||
mid->sequence_number);
|
||||
if (rc)
|
||||
cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
|
||||
rc);
|
||||
}
|
||||
|
||||
/* BB special case reconnect tid and uid here? */
|
||||
return map_and_check_smb_error(server, mid, log_error);
|
||||
}
|
||||
|
||||
struct mid_q_entry *
|
||||
cifs_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst)
|
||||
{
|
||||
int rc;
|
||||
struct smb_hdr *hdr = (struct smb_hdr *)rqst->rq_iov[0].iov_base;
|
||||
struct mid_q_entry *mid;
|
||||
|
||||
rc = allocate_mid(ses, hdr, &mid);
|
||||
if (rc)
|
||||
return ERR_PTR(rc);
|
||||
rc = cifs_sign_rqst(rqst, server, &mid->sequence_number);
|
||||
if (rc) {
|
||||
delete_mid(server, mid);
|
||||
return ERR_PTR(rc);
|
||||
}
|
||||
return mid;
|
||||
}
|
||||
|
||||
int
|
||||
SendReceive2(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct kvec *iov, int n_vec, int *resp_buf_type /* ret */,
|
||||
const int flags, struct kvec *resp_iov)
|
||||
{
|
||||
struct smb_rqst rqst = {
|
||||
.rq_iov = iov,
|
||||
.rq_nvec = n_vec,
|
||||
};
|
||||
|
||||
return cifs_send_recv(xid, ses, ses->server,
|
||||
&rqst, resp_buf_type, flags, resp_iov);
|
||||
}
|
||||
|
||||
int
|
||||
SendReceive(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct smb_hdr *in_buf, unsigned int in_len,
|
||||
struct smb_hdr *out_buf, int *pbytes_returned, const int flags)
|
||||
{
|
||||
struct TCP_Server_Info *server;
|
||||
struct kvec resp_iov = {};
|
||||
struct kvec iov = { .iov_base = in_buf, .iov_len = in_len };
|
||||
struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
|
||||
int resp_buf_type;
|
||||
int rc = 0;
|
||||
|
||||
if (WARN_ON_ONCE(in_len > 0xffffff))
|
||||
return smb_EIO1(smb_eio_trace_tx_too_long, in_len);
|
||||
if (ses == NULL) {
|
||||
cifs_dbg(VFS, "Null smb session\n");
|
||||
return smb_EIO(smb_eio_trace_null_pointers);
|
||||
}
|
||||
server = ses->server;
|
||||
if (server == NULL) {
|
||||
cifs_dbg(VFS, "Null tcp session\n");
|
||||
return smb_EIO(smb_eio_trace_null_pointers);
|
||||
}
|
||||
|
||||
/* Ensure that we do not send more than 50 overlapping requests
|
||||
to the same server. We may make this configurable later or
|
||||
use ses->maxReq */
|
||||
|
||||
if (in_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
|
||||
cifs_server_dbg(VFS, "Invalid length, greater than maximum frame, %d\n",
|
||||
in_len);
|
||||
return smb_EIO1(smb_eio_trace_tx_too_long, in_len);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, ses->server,
|
||||
&rqst, &resp_buf_type, flags, &resp_iov);
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
|
||||
if (out_buf) {
|
||||
*pbytes_returned = resp_iov.iov_len;
|
||||
if (resp_iov.iov_len)
|
||||
memcpy(out_buf, resp_iov.iov_base, resp_iov.iov_len);
|
||||
}
|
||||
|
||||
out:
|
||||
free_rsp_buf(resp_buf_type, resp_iov.iov_base);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
return codes:
|
||||
0 not a transact2, or all data present
|
||||
>0 transact2 with that much data missing
|
||||
-EINVAL invalid transact2
|
||||
*/
|
||||
static int
|
||||
check2ndT2(char *buf)
|
||||
{
|
||||
struct smb_hdr *pSMB = (struct smb_hdr *)buf;
|
||||
struct smb_t2_rsp *pSMBt;
|
||||
int remaining;
|
||||
__u16 total_data_size, data_in_this_rsp;
|
||||
|
||||
if (pSMB->Command != SMB_COM_TRANSACTION2)
|
||||
return 0;
|
||||
|
||||
/* check for plausible wct, bcc and t2 data and parm sizes */
|
||||
/* check for parm and data offset going beyond end of smb */
|
||||
if (pSMB->WordCount != 10) { /* coalesce_t2 depends on this */
|
||||
cifs_dbg(FYI, "Invalid transact2 word count\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pSMBt = (struct smb_t2_rsp *)pSMB;
|
||||
|
||||
total_data_size = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
|
||||
data_in_this_rsp = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
|
||||
|
||||
if (total_data_size == data_in_this_rsp)
|
||||
return 0;
|
||||
else if (total_data_size < data_in_this_rsp) {
|
||||
cifs_dbg(FYI, "total data %d smaller than data in frame %d\n",
|
||||
total_data_size, data_in_this_rsp);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
remaining = total_data_size - data_in_this_rsp;
|
||||
|
||||
cifs_dbg(FYI, "missing %d bytes from transact2, check next response\n",
|
||||
remaining);
|
||||
if (total_data_size > CIFSMaxBufSize) {
|
||||
cifs_dbg(VFS, "TotalDataSize %d is over maximum buffer %d\n",
|
||||
total_data_size, CIFSMaxBufSize);
|
||||
return -EINVAL;
|
||||
}
|
||||
return remaining;
|
||||
}
|
||||
|
||||
static int
|
||||
coalesce_t2(char *second_buf, struct smb_hdr *target_hdr, unsigned int *pdu_len)
|
||||
{
|
||||
struct smb_t2_rsp *pSMBs = (struct smb_t2_rsp *)second_buf;
|
||||
struct smb_t2_rsp *pSMBt = (struct smb_t2_rsp *)target_hdr;
|
||||
char *data_area_of_tgt;
|
||||
char *data_area_of_src;
|
||||
int remaining;
|
||||
unsigned int byte_count, total_in_tgt;
|
||||
__u16 tgt_total_cnt, src_total_cnt, total_in_src;
|
||||
|
||||
src_total_cnt = get_unaligned_le16(&pSMBs->t2_rsp.TotalDataCount);
|
||||
tgt_total_cnt = get_unaligned_le16(&pSMBt->t2_rsp.TotalDataCount);
|
||||
|
||||
if (tgt_total_cnt != src_total_cnt)
|
||||
cifs_dbg(FYI, "total data count of primary and secondary t2 differ source=%hu target=%hu\n",
|
||||
src_total_cnt, tgt_total_cnt);
|
||||
|
||||
total_in_tgt = get_unaligned_le16(&pSMBt->t2_rsp.DataCount);
|
||||
|
||||
remaining = tgt_total_cnt - total_in_tgt;
|
||||
|
||||
if (remaining < 0) {
|
||||
cifs_dbg(FYI, "Server sent too much data. tgt_total_cnt=%hu total_in_tgt=%u\n",
|
||||
tgt_total_cnt, total_in_tgt);
|
||||
return -EPROTO;
|
||||
}
|
||||
|
||||
if (remaining == 0) {
|
||||
/* nothing to do, ignore */
|
||||
cifs_dbg(FYI, "no more data remains\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
total_in_src = get_unaligned_le16(&pSMBs->t2_rsp.DataCount);
|
||||
if (remaining < total_in_src)
|
||||
cifs_dbg(FYI, "transact2 2nd response contains too much data\n");
|
||||
|
||||
/* find end of first SMB data area */
|
||||
data_area_of_tgt = (char *)&pSMBt->hdr.Protocol +
|
||||
get_unaligned_le16(&pSMBt->t2_rsp.DataOffset);
|
||||
|
||||
/* validate target area */
|
||||
data_area_of_src = (char *)&pSMBs->hdr.Protocol +
|
||||
get_unaligned_le16(&pSMBs->t2_rsp.DataOffset);
|
||||
|
||||
data_area_of_tgt += total_in_tgt;
|
||||
|
||||
total_in_tgt += total_in_src;
|
||||
/* is the result too big for the field? */
|
||||
if (total_in_tgt > USHRT_MAX) {
|
||||
cifs_dbg(FYI, "coalesced DataCount too large (%u)\n",
|
||||
total_in_tgt);
|
||||
return -EPROTO;
|
||||
}
|
||||
put_unaligned_le16(total_in_tgt, &pSMBt->t2_rsp.DataCount);
|
||||
|
||||
/* fix up the BCC */
|
||||
byte_count = get_bcc(target_hdr);
|
||||
byte_count += total_in_src;
|
||||
/* is the result too big for the field? */
|
||||
if (byte_count > USHRT_MAX) {
|
||||
cifs_dbg(FYI, "coalesced BCC too large (%u)\n", byte_count);
|
||||
return -EPROTO;
|
||||
}
|
||||
put_bcc(byte_count, target_hdr);
|
||||
|
||||
byte_count = *pdu_len;
|
||||
byte_count += total_in_src;
|
||||
/* don't allow buffer to overflow */
|
||||
if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
|
||||
cifs_dbg(FYI, "coalesced BCC exceeds buffer size (%u)\n",
|
||||
byte_count);
|
||||
return -ENOBUFS;
|
||||
}
|
||||
*pdu_len = byte_count;
|
||||
|
||||
/* copy second buffer into end of first buffer */
|
||||
memcpy(data_area_of_tgt, data_area_of_src, total_in_src);
|
||||
|
||||
if (remaining != total_in_src) {
|
||||
/* more responses to go */
|
||||
cifs_dbg(FYI, "waiting for more secondary responses\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* we are done */
|
||||
cifs_dbg(FYI, "found the last secondary response\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
cifs_check_trans2(struct mid_q_entry *mid, struct TCP_Server_Info *server,
|
||||
char *buf, int malformed)
|
||||
{
|
||||
if (malformed)
|
||||
return false;
|
||||
if (check2ndT2(buf) <= 0)
|
||||
return false;
|
||||
mid->multiRsp = true;
|
||||
if (mid->resp_buf) {
|
||||
/* merge response - fix up 1st*/
|
||||
malformed = coalesce_t2(buf, mid->resp_buf, &mid->response_pdu_len);
|
||||
if (malformed > 0)
|
||||
return true;
|
||||
/* All parts received or packet is malformed. */
|
||||
mid->multiEnd = true;
|
||||
dequeue_mid(server, mid, malformed);
|
||||
return true;
|
||||
}
|
||||
if (!server->large_buf) {
|
||||
/*FIXME: switch to already allocated largebuf?*/
|
||||
cifs_dbg(VFS, "1st trans2 resp needs bigbuf\n");
|
||||
} else {
|
||||
/* Have first buffer */
|
||||
mid->resp_buf = buf;
|
||||
mid->large_buf = true;
|
||||
server->bigbuf = NULL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static int
|
||||
check_smb_hdr(struct smb_hdr *smb)
|
||||
{
|
||||
/* does it have the right SMB "signature" ? */
|
||||
if (*(__le32 *) smb->Protocol != SMB1_PROTO_NUMBER) {
|
||||
cifs_dbg(VFS, "Bad protocol string signature header 0x%x\n",
|
||||
*(unsigned int *)smb->Protocol);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* if it's a response then accept */
|
||||
if (smb->Flags & SMBFLG_RESPONSE)
|
||||
return 0;
|
||||
|
||||
/* only one valid case where server sends us request */
|
||||
if (smb->Command == SMB_COM_LOCKING_ANDX)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Windows NT server returns error resposne (e.g. STATUS_DELETE_PENDING
|
||||
* or STATUS_OBJECT_NAME_NOT_FOUND or ERRDOS/ERRbadfile or any other)
|
||||
* for some TRANS2 requests without the RESPONSE flag set in header.
|
||||
*/
|
||||
if (smb->Command == SMB_COM_TRANSACTION2 && smb->Status.CifsError != 0)
|
||||
return 0;
|
||||
|
||||
cifs_dbg(VFS, "Server sent request, not response. mid=%u\n",
|
||||
get_mid(smb));
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
checkSMB(char *buf, unsigned int pdu_len, unsigned int total_read,
|
||||
struct TCP_Server_Info *server)
|
||||
{
|
||||
struct smb_hdr *smb = (struct smb_hdr *)buf;
|
||||
__u32 rfclen = pdu_len;
|
||||
__u32 clc_len; /* calculated length */
|
||||
cifs_dbg(FYI, "checkSMB Length: 0x%x, smb_buf_length: 0x%x\n",
|
||||
total_read, rfclen);
|
||||
|
||||
/* is this frame too small to even get to a BCC? */
|
||||
if (total_read < 2 + sizeof(struct smb_hdr)) {
|
||||
if ((total_read >= sizeof(struct smb_hdr) - 1)
|
||||
&& (smb->Status.CifsError != 0)) {
|
||||
/* it's an error return */
|
||||
smb->WordCount = 0;
|
||||
/* some error cases do not return wct and bcc */
|
||||
return 0;
|
||||
} else if ((total_read == sizeof(struct smb_hdr) + 1) &&
|
||||
(smb->WordCount == 0)) {
|
||||
char *tmp = (char *)smb;
|
||||
/* Need to work around a bug in two servers here */
|
||||
/* First, check if the part of bcc they sent was zero */
|
||||
if (tmp[sizeof(struct smb_hdr)] == 0) {
|
||||
/* some servers return only half of bcc
|
||||
* on simple responses (wct, bcc both zero)
|
||||
* in particular have seen this on
|
||||
* ulogoffX and FindClose. This leaves
|
||||
* one byte of bcc potentially uninitialized
|
||||
*/
|
||||
/* zero rest of bcc */
|
||||
tmp[sizeof(struct smb_hdr)+1] = 0;
|
||||
return 0;
|
||||
}
|
||||
cifs_dbg(VFS, "rcvd invalid byte count (bcc)\n");
|
||||
return smb_EIO1(smb_eio_trace_rx_inv_bcc, tmp[sizeof(struct smb_hdr)]);
|
||||
} else {
|
||||
cifs_dbg(VFS, "Length less than smb header size\n");
|
||||
return smb_EIO2(smb_eio_trace_rx_too_short,
|
||||
total_read, smb->WordCount);
|
||||
}
|
||||
} else if (total_read < sizeof(*smb) + 2 * smb->WordCount) {
|
||||
cifs_dbg(VFS, "%s: can't read BCC due to invalid WordCount(%u)\n",
|
||||
__func__, smb->WordCount);
|
||||
return smb_EIO2(smb_eio_trace_rx_check_rsp,
|
||||
total_read, 2 + sizeof(struct smb_hdr));
|
||||
}
|
||||
|
||||
/* otherwise, there is enough to get to the BCC */
|
||||
if (check_smb_hdr(smb))
|
||||
return smb_EIO1(smb_eio_trace_rx_rfc1002_magic, *(u32 *)smb->Protocol);
|
||||
clc_len = smbCalcSize(smb);
|
||||
|
||||
if (rfclen != total_read) {
|
||||
cifs_dbg(VFS, "Length read does not match RFC1001 length %d/%d\n",
|
||||
rfclen, total_read);
|
||||
return smb_EIO2(smb_eio_trace_rx_check_rsp,
|
||||
total_read, rfclen);
|
||||
}
|
||||
|
||||
if (rfclen != clc_len) {
|
||||
__u16 mid = get_mid(smb);
|
||||
/* check if bcc wrapped around for large read responses */
|
||||
if ((rfclen > 64 * 1024) && (rfclen > clc_len)) {
|
||||
/* check if lengths match mod 64K */
|
||||
if (((rfclen) & 0xFFFF) == (clc_len & 0xFFFF))
|
||||
return 0; /* bcc wrapped */
|
||||
}
|
||||
cifs_dbg(FYI, "Calculated size %u vs length %u mismatch for mid=%u\n",
|
||||
clc_len, rfclen, mid);
|
||||
|
||||
if (rfclen < clc_len) {
|
||||
cifs_dbg(VFS, "RFC1001 size %u smaller than SMB for mid=%u\n",
|
||||
rfclen, mid);
|
||||
return smb_EIO2(smb_eio_trace_rx_calc_len_too_big,
|
||||
rfclen, clc_len);
|
||||
} else if (rfclen > clc_len + 512) {
|
||||
/*
|
||||
* Some servers (Windows XP in particular) send more
|
||||
* data than the lengths in the SMB packet would
|
||||
* indicate on certain calls (byte range locks and
|
||||
* trans2 find first calls in particular). While the
|
||||
* client can handle such a frame by ignoring the
|
||||
* trailing data, we choose limit the amount of extra
|
||||
* data to 512 bytes.
|
||||
*/
|
||||
cifs_dbg(VFS, "RFC1001 size %u more than 512 bytes larger than SMB for mid=%u\n",
|
||||
rfclen, mid);
|
||||
return smb_EIO2(smb_eio_trace_rx_overlong,
|
||||
rfclen, clc_len + 512);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -13,7 +13,6 @@
|
|||
#include <linux/pagemap.h>
|
||||
#include <asm/div64.h>
|
||||
#include "cifsfs.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_debug.h"
|
||||
|
|
@ -22,6 +21,7 @@
|
|||
#include "fscache.h"
|
||||
#include "smb2proto.h"
|
||||
#include "../common/smb2status.h"
|
||||
#include "../common/smbfsctl.h"
|
||||
|
||||
static struct smb2_symlink_err_rsp *symlink_data(const struct kvec *iov)
|
||||
{
|
||||
|
|
@ -179,6 +179,8 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
|
|||
&err_buftype);
|
||||
if (rc == -EACCES && retry_without_read_attributes) {
|
||||
free_rsp_buf(err_buftype, err_iov.iov_base);
|
||||
memset(&err_iov, 0, sizeof(err_iov));
|
||||
err_buftype = CIFS_NO_BUFFER;
|
||||
oparms->desired_access &= ~FILE_READ_ATTRIBUTES;
|
||||
rc = SMB2_open(xid, oparms, smb2_path, &smb2_oplock, smb2_data, NULL, &err_iov,
|
||||
&err_buftype);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
#include <linux/pagemap.h>
|
||||
#include <asm/div64.h>
|
||||
#include "cifsfs.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_debug.h"
|
||||
|
|
@ -24,6 +23,7 @@
|
|||
#include "smb2proto.h"
|
||||
#include "cached_dir.h"
|
||||
#include "../common/smb2status.h"
|
||||
#include "../common/smbfsctl.h"
|
||||
|
||||
static struct reparse_data_buffer *reparse_buf_ptr(struct kvec *iov)
|
||||
{
|
||||
|
|
@ -188,7 +188,7 @@ static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
struct reparse_data_buffer *rbuf;
|
||||
struct TCP_Server_Info *server;
|
||||
int resp_buftype[MAX_COMPOUND];
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
__u8 delete_pending[8] = {1,};
|
||||
struct kvec *rsp_iov, *iov;
|
||||
struct inode *inode = NULL;
|
||||
|
|
@ -638,18 +638,26 @@ replay_again:
|
|||
num_rqst++;
|
||||
|
||||
if (cfile) {
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
for (i = 1; i < num_rqst - 2; i++)
|
||||
smb2_set_replay(server, &rqst[i]);
|
||||
}
|
||||
|
||||
rc = compound_send_recv(xid, ses, server,
|
||||
flags, num_rqst - 2,
|
||||
&rqst[1], &resp_buftype[1],
|
||||
&rsp_iov[1]);
|
||||
} else {
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
for (i = 0; i < num_rqst; i++)
|
||||
smb2_set_replay(server, &rqst[i]);
|
||||
}
|
||||
|
||||
rc = compound_send_recv(xid, ses, server,
|
||||
flags, num_rqst,
|
||||
|
|
@ -1180,7 +1188,7 @@ smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
|
|||
{
|
||||
struct kvec open_iov[SMB2_CREATE_IOV_SIZE];
|
||||
__le16 *utf16_path __free(kfree) = NULL;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
struct TCP_Server_Info *server;
|
||||
struct cifs_open_parms oparms;
|
||||
struct smb2_create_req *creq;
|
||||
|
|
@ -1242,6 +1250,9 @@ again:
|
|||
goto err_free;
|
||||
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
for (int i = 0; i < ARRAY_SIZE(rqst); i++)
|
||||
smb2_set_replay(server, &rqst[i]);
|
||||
}
|
||||
|
|
@ -1262,7 +1273,7 @@ again:
|
|||
if (rc == -EINVAL && dentry) {
|
||||
dentry = NULL;
|
||||
retries = 0;
|
||||
cur_sleep = 1;
|
||||
cur_sleep = 0;
|
||||
goto again;
|
||||
}
|
||||
/*
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
45
fs/smb/client/smb2maperror_test.c
Normal file
45
fs/smb/client/smb2maperror_test.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// SPDX-License-Identifier: LGPL-2.1
|
||||
/*
|
||||
*
|
||||
* KUnit tests of SMB2 maperror
|
||||
*
|
||||
* Copyright (C) 2025 KylinSoft Co., Ltd. All rights reserved.
|
||||
* Author(s): ChenXiaoSong <chenxiaosong@kylinos.cn>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <kunit/test.h>
|
||||
|
||||
static void
|
||||
test_cmp_map(struct kunit *test, const struct status_to_posix_error *expect)
|
||||
{
|
||||
const struct status_to_posix_error *result;
|
||||
|
||||
result = smb2_get_err_map(expect->smb2_status);
|
||||
KUNIT_EXPECT_PTR_NE(test, NULL, result);
|
||||
KUNIT_EXPECT_EQ(test, expect->smb2_status, result->smb2_status);
|
||||
KUNIT_EXPECT_EQ(test, expect->posix_error, result->posix_error);
|
||||
KUNIT_EXPECT_STREQ(test, expect->status_string, result->status_string);
|
||||
}
|
||||
|
||||
static void maperror_test_check_search(struct kunit *test)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(smb2_error_map_table); i++)
|
||||
test_cmp_map(test, &smb2_error_map_table[i]);
|
||||
}
|
||||
|
||||
static struct kunit_case maperror_test_cases[] = {
|
||||
KUNIT_CASE(maperror_test_check_search),
|
||||
{}
|
||||
};
|
||||
|
||||
static struct kunit_suite maperror_suite = {
|
||||
.name = "smb2_maperror",
|
||||
.test_cases = maperror_test_cases,
|
||||
};
|
||||
|
||||
kunit_test_suite(maperror_suite);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
@ -820,14 +820,14 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
|
|||
int rc;
|
||||
|
||||
cifs_dbg(FYI, "%s: tc_count=%d\n", __func__, tcon->tc_count);
|
||||
spin_lock(&cifs_tcp_ses_lock);
|
||||
spin_lock(&tcon->tc_lock);
|
||||
if (tcon->tc_count <= 0) {
|
||||
struct TCP_Server_Info *server = NULL;
|
||||
|
||||
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
|
||||
netfs_trace_tcon_ref_see_cancelled_close);
|
||||
WARN_ONCE(tcon->tc_count < 0, "tcon refcount is negative");
|
||||
spin_unlock(&cifs_tcp_ses_lock);
|
||||
spin_unlock(&tcon->tc_lock);
|
||||
|
||||
if (tcon->ses) {
|
||||
server = tcon->ses->server;
|
||||
|
|
@ -841,7 +841,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
|
|||
tcon->tc_count++;
|
||||
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
|
||||
netfs_trace_tcon_ref_get_cancelled_close);
|
||||
spin_unlock(&cifs_tcp_ses_lock);
|
||||
spin_unlock(&tcon->tc_lock);
|
||||
|
||||
rc = __smb2_handle_cancelled_cmd(tcon, SMB2_CLOSE_HE, 0,
|
||||
persistent_fid, volatile_fid);
|
||||
|
|
|
|||
|
|
@ -637,13 +637,6 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
|
|||
p = buf;
|
||||
|
||||
spin_lock(&ses->iface_lock);
|
||||
/* do not query too frequently, this time with lock held */
|
||||
if (ses->iface_last_update &&
|
||||
time_before(jiffies, ses->iface_last_update +
|
||||
(SMB_INTERFACE_POLL_INTERVAL * HZ))) {
|
||||
spin_unlock(&ses->iface_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Go through iface_list and mark them as inactive
|
||||
|
|
@ -666,7 +659,6 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
|
|||
"Empty network interface list returned by server %s\n",
|
||||
ses->server->hostname);
|
||||
rc = -EOPNOTSUPP;
|
||||
ses->iface_last_update = jiffies;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
@ -795,8 +787,6 @@ next_iface:
|
|||
+ sizeof(p->Next) && p->Next))
|
||||
cifs_dbg(VFS, "%s: incomplete interface info\n", __func__);
|
||||
|
||||
ses->iface_last_update = jiffies;
|
||||
|
||||
out:
|
||||
/*
|
||||
* Go through the list again and put the inactive entries
|
||||
|
|
@ -825,10 +815,17 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_
|
|||
struct TCP_Server_Info *pserver;
|
||||
|
||||
/* do not query too frequently */
|
||||
spin_lock(&ses->iface_lock);
|
||||
if (ses->iface_last_update &&
|
||||
time_before(jiffies, ses->iface_last_update +
|
||||
(SMB_INTERFACE_POLL_INTERVAL * HZ)))
|
||||
(SMB_INTERFACE_POLL_INTERVAL * HZ))) {
|
||||
spin_unlock(&ses->iface_lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ses->iface_last_update = jiffies;
|
||||
|
||||
spin_unlock(&ses->iface_lock);
|
||||
|
||||
rc = SMB2_ioctl(xid, tcon, NO_FILE_ID, NO_FILE_ID,
|
||||
FSCTL_QUERY_NETWORK_INTERFACE_INFO,
|
||||
|
|
@ -1184,7 +1181,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
struct smb2_file_full_ea_info *ea;
|
||||
struct smb2_query_info_rsp *rsp;
|
||||
int rc, used_len = 0;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -1314,6 +1311,9 @@ replay_again:
|
|||
smb2_set_related(&rqst[2]);
|
||||
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst[0]);
|
||||
smb2_set_replay(server, &rqst[1]);
|
||||
smb2_set_replay(server, &rqst[2]);
|
||||
|
|
@ -1582,7 +1582,7 @@ smb2_ioctl_query_info(const unsigned int xid,
|
|||
void *data[2];
|
||||
int create_options = is_dir ? CREATE_NOT_FILE : CREATE_NOT_DIR;
|
||||
void (*free_req1_func)(struct smb_rqst *r);
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -1731,6 +1731,9 @@ replay_again:
|
|||
smb2_set_related(&rqst[2]);
|
||||
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst[0]);
|
||||
smb2_set_replay(server, &rqst[1]);
|
||||
smb2_set_replay(server, &rqst[2]);
|
||||
|
|
@ -2446,7 +2449,7 @@ smb2_query_dir_first(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
struct smb2_query_directory_rsp *qd_rsp = NULL;
|
||||
struct smb2_create_rsp *op_rsp = NULL;
|
||||
struct TCP_Server_Info *server;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -2504,6 +2507,9 @@ replay_again:
|
|||
smb2_set_related(&rqst[1]);
|
||||
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst[0]);
|
||||
smb2_set_replay(server, &rqst[1]);
|
||||
}
|
||||
|
|
@ -2780,10 +2786,14 @@ bool smb2_should_replay(struct cifs_tcon *tcon,
|
|||
return false;
|
||||
|
||||
if (tcon->retry || (*pretries)++ < tcon->ses->server->retrans) {
|
||||
msleep(*pcur_sleep);
|
||||
(*pcur_sleep) = ((*pcur_sleep) << 1);
|
||||
if ((*pcur_sleep) > CIFS_MAX_SLEEP)
|
||||
(*pcur_sleep) = CIFS_MAX_SLEEP;
|
||||
/* Update sleep time for exponential backoff */
|
||||
if (!(*pcur_sleep))
|
||||
(*pcur_sleep) = 1;
|
||||
else {
|
||||
(*pcur_sleep) = ((*pcur_sleep) << 1);
|
||||
if ((*pcur_sleep) > CIFS_MAX_SLEEP)
|
||||
(*pcur_sleep) = CIFS_MAX_SLEEP;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2814,7 +2824,7 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
int rc;
|
||||
__le16 *utf16_path;
|
||||
struct cached_fid *cfid;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -2904,6 +2914,9 @@ replay_again:
|
|||
smb2_set_related(&rqst[2]);
|
||||
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
if (!cfid) {
|
||||
smb2_set_replay(server, &rqst[0]);
|
||||
smb2_set_replay(server, &rqst[2]);
|
||||
|
|
@ -3091,7 +3104,9 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
|
|||
struct cifs_tcon,
|
||||
tcon_list);
|
||||
if (tcon) {
|
||||
spin_lock(&tcon->tc_lock);
|
||||
tcon->tc_count++;
|
||||
spin_unlock(&tcon->tc_lock);
|
||||
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
|
||||
netfs_trace_tcon_ref_get_dfs_refer);
|
||||
}
|
||||
|
|
@ -3160,13 +3175,9 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses,
|
|||
out:
|
||||
if (tcon && !tcon->ipc) {
|
||||
/* ipc tcons are not refcounted */
|
||||
spin_lock(&cifs_tcp_ses_lock);
|
||||
tcon->tc_count--;
|
||||
cifs_put_tcon(tcon, netfs_trace_tcon_ref_put_dfs_refer);
|
||||
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
|
||||
netfs_trace_tcon_ref_dec_dfs_refer);
|
||||
/* tc_count can never go negative */
|
||||
WARN_ON(tcon->tc_count < 0);
|
||||
spin_unlock(&cifs_tcp_ses_lock);
|
||||
}
|
||||
kfree(utf16_path);
|
||||
kfree(dfs_req);
|
||||
|
|
|
|||
|
|
@ -32,9 +32,9 @@
|
|||
#include "cifs_unicode.h"
|
||||
#include "cifs_debug.h"
|
||||
#include "ntlmssp.h"
|
||||
#include "../common/smbfsctl.h"
|
||||
#include "../common/smb2status.h"
|
||||
#include "smb2glob.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifs_spnego.h"
|
||||
#include "../common/smbdirect/smbdirect.h"
|
||||
#include "smbdirect.h"
|
||||
|
|
@ -2904,7 +2904,7 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
|
|||
unsigned int total_len;
|
||||
__le16 *utf16_path = NULL;
|
||||
struct TCP_Server_Info *server;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -3016,8 +3016,12 @@ replay_again:
|
|||
trace_smb3_posix_mkdir_enter(xid, tcon->tid, ses->Suid, full_path, CREATE_NOT_FILE,
|
||||
FILE_WRITE_ATTRIBUTES);
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
/* resource #4: response buffer */
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
|
|
@ -3265,7 +3269,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path,
|
|||
int resp_buftype = CIFS_NO_BUFFER;
|
||||
int rc = 0;
|
||||
int flags = 0;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -3293,8 +3297,12 @@ replay_again:
|
|||
trace_smb3_open_enter(xid, tcon->tid, tcon->ses->Suid, oparms->path,
|
||||
oparms->create_options, oparms->desired_access);
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
&rqst, &resp_buftype, flags,
|
||||
|
|
@ -3478,7 +3486,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
|
|||
int resp_buftype = CIFS_NO_BUFFER;
|
||||
int rc = 0;
|
||||
int flags = 0;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
if (!tcon)
|
||||
return smb_EIO(smb_eio_trace_null_pointers);
|
||||
|
|
@ -3518,8 +3526,12 @@ replay_again:
|
|||
if (rc)
|
||||
goto ioctl_exit;
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
&rqst, &resp_buftype, flags,
|
||||
|
|
@ -3675,7 +3687,7 @@ __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
int rc = 0;
|
||||
int flags = 0;
|
||||
bool query_attrs = false;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -3707,8 +3719,12 @@ replay_again:
|
|||
if (rc)
|
||||
goto close_exit;
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
&rqst, &resp_buftype, flags, &rsp_iov);
|
||||
|
|
@ -3878,7 +3894,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
struct TCP_Server_Info *server;
|
||||
int flags = 0;
|
||||
bool allocated = false;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
cifs_dbg(FYI, "Query Info\n");
|
||||
|
||||
|
|
@ -3912,8 +3928,12 @@ replay_again:
|
|||
trace_smb3_query_info_enter(xid, persistent_fid, tcon->tid,
|
||||
ses->Suid, info_class, (__u32)info_type);
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
&rqst, &resp_buftype, flags, &rsp_iov);
|
||||
|
|
@ -4069,7 +4089,7 @@ SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
int resp_buftype = CIFS_NO_BUFFER;
|
||||
int flags = 0;
|
||||
int rc = 0;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -4100,8 +4120,12 @@ replay_again:
|
|||
trace_smb3_notify_enter(xid, persistent_fid, tcon->tid, ses->Suid,
|
||||
(u8)watch_tree, completion_filter);
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
&rqst, &resp_buftype, flags, &rsp_iov);
|
||||
|
|
@ -4239,7 +4263,9 @@ void smb2_reconnect_server(struct work_struct *work)
|
|||
|
||||
list_for_each_entry(tcon, &ses->tcon_list, tcon_list) {
|
||||
if (tcon->need_reconnect || tcon->need_reopen_files) {
|
||||
spin_lock(&tcon->tc_lock);
|
||||
tcon->tc_count++;
|
||||
spin_unlock(&tcon->tc_lock);
|
||||
trace_smb3_tcon_ref(tcon->debug_id, tcon->tc_count,
|
||||
netfs_trace_tcon_ref_get_reconnect_server);
|
||||
list_add_tail(&tcon->rlist, &tmp_list);
|
||||
|
|
@ -4405,7 +4431,7 @@ SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
|
|||
int resp_buftype = CIFS_NO_BUFFER;
|
||||
int flags = 0;
|
||||
int rc = 0;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -4431,8 +4457,12 @@ replay_again:
|
|||
|
||||
trace_smb3_flush_enter(xid, persistent_fid, tcon->tid, ses->Suid);
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
&rqst, &resp_buftype, flags, &rsp_iov);
|
||||
|
|
@ -4622,9 +4652,19 @@ smb2_readv_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid)
|
|||
|
||||
iov_iter_truncate(&rqst.rq_iter, rdata->got_bytes);
|
||||
rc = smb2_verify_signature(&rqst, server);
|
||||
if (rc)
|
||||
if (rc) {
|
||||
cifs_tcon_dbg(VFS, "SMB signature verification returned error = %d\n",
|
||||
rc);
|
||||
rc);
|
||||
rdata->subreq.error = rc;
|
||||
rdata->result = rc;
|
||||
|
||||
if (is_replayable_error(rc)) {
|
||||
trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_retry_needed);
|
||||
__set_bit(NETFS_SREQ_NEED_RETRY, &rdata->subreq.flags);
|
||||
} else
|
||||
trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_bad);
|
||||
} else
|
||||
trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_progress);
|
||||
}
|
||||
/* FIXME: should this be counted toward the initiating task? */
|
||||
task_io_account_read(rdata->got_bytes);
|
||||
|
|
@ -4700,6 +4740,14 @@ do_retry:
|
|||
if (rdata->got_bytes)
|
||||
__set_bit(NETFS_SREQ_MADE_PROGRESS, &rdata->subreq.flags);
|
||||
}
|
||||
|
||||
/* see if we need to retry */
|
||||
if (is_replayable_error(rdata->result) &&
|
||||
smb2_should_replay(tcon,
|
||||
&rdata->retries,
|
||||
&rdata->cur_sleep))
|
||||
rdata->replay = true;
|
||||
|
||||
trace_smb3_rw_credits(rreq_debug_id, subreq_debug_index, rdata->credits.value,
|
||||
server->credits, server->in_flight,
|
||||
0, cifs_trace_rw_credits_read_response_clear);
|
||||
|
|
@ -4748,7 +4796,7 @@ smb2_async_readv(struct cifs_io_subrequest *rdata)
|
|||
rc = smb2_new_read_req(
|
||||
(void **) &buf, &total_len, &io_parms, rdata, 0, 0);
|
||||
if (rc)
|
||||
return rc;
|
||||
goto out;
|
||||
|
||||
if (smb3_encryption_required(io_parms.tcon))
|
||||
flags |= CIFS_TRANSFORM_REQ;
|
||||
|
|
@ -4760,6 +4808,13 @@ smb2_async_readv(struct cifs_io_subrequest *rdata)
|
|||
|
||||
shdr = (struct smb2_hdr *)buf;
|
||||
|
||||
if (rdata->replay) {
|
||||
/* Back-off before retry */
|
||||
if (rdata->cur_sleep)
|
||||
msleep(rdata->cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
if (rdata->credits.value > 0) {
|
||||
shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(io_parms.length,
|
||||
SMB2_MAX_BUFFER_SIZE));
|
||||
|
|
@ -4795,6 +4850,17 @@ smb2_async_readv(struct cifs_io_subrequest *rdata)
|
|||
|
||||
async_readv_out:
|
||||
cifs_small_buf_release(buf);
|
||||
|
||||
out:
|
||||
/* if the send error is retryable, let netfs know about it */
|
||||
if (is_replayable_error(rc) &&
|
||||
smb2_should_replay(tcon,
|
||||
&rdata->retries,
|
||||
&rdata->cur_sleep)) {
|
||||
trace_netfs_sreq(&rdata->subreq, netfs_sreq_trace_io_retry_needed);
|
||||
__set_bit(NETFS_SREQ_NEED_RETRY, &rdata->subreq.flags);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -4908,14 +4974,20 @@ smb2_writev_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid)
|
|||
|
||||
switch (mid->mid_state) {
|
||||
case MID_RESPONSE_RECEIVED:
|
||||
trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_progress);
|
||||
credits.value = le16_to_cpu(rsp->hdr.CreditRequest);
|
||||
credits.instance = server->reconnect_instance;
|
||||
result = smb2_check_receive(mid, server, 0);
|
||||
if (result != 0) {
|
||||
trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_bad);
|
||||
if (is_replayable_error(result)) {
|
||||
trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_retry_needed);
|
||||
__set_bit(NETFS_SREQ_NEED_RETRY, &wdata->subreq.flags);
|
||||
} else {
|
||||
wdata->subreq.error = result;
|
||||
trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_bad);
|
||||
}
|
||||
break;
|
||||
}
|
||||
trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_progress);
|
||||
|
||||
written = le32_to_cpu(rsp->DataLength);
|
||||
/*
|
||||
|
|
@ -4930,7 +5002,7 @@ smb2_writev_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid)
|
|||
cifs_stats_bytes_written(tcon, written);
|
||||
|
||||
if (written < wdata->subreq.len) {
|
||||
wdata->result = -ENOSPC;
|
||||
result = -ENOSPC;
|
||||
} else if (written > 0) {
|
||||
wdata->subreq.len = written;
|
||||
__set_bit(NETFS_SREQ_MADE_PROGRESS, &wdata->subreq.flags);
|
||||
|
|
@ -4972,6 +5044,7 @@ smb2_writev_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid)
|
|||
}
|
||||
#endif
|
||||
if (result) {
|
||||
wdata->result = result;
|
||||
cifs_stats_fail_inc(tcon, SMB2_WRITE_HE);
|
||||
trace_smb3_write_err(wdata->rreq->debug_id,
|
||||
wdata->subreq.debug_index,
|
||||
|
|
@ -4994,6 +5067,14 @@ smb2_writev_callback(struct TCP_Server_Info *server, struct mid_q_entry *mid)
|
|||
server->credits, server->in_flight,
|
||||
0, cifs_trace_rw_credits_write_response_clear);
|
||||
wdata->credits.value = 0;
|
||||
|
||||
/* see if we need to retry */
|
||||
if (is_replayable_error(wdata->result) &&
|
||||
smb2_should_replay(tcon,
|
||||
&wdata->retries,
|
||||
&wdata->cur_sleep))
|
||||
wdata->replay = true;
|
||||
|
||||
cifs_write_subrequest_terminated(wdata, result ?: written);
|
||||
release_mid(server, mid);
|
||||
trace_smb3_rw_credits(rreq_debug_id, subreq_debug_index, 0,
|
||||
|
|
@ -5112,8 +5193,12 @@ smb2_async_writev(struct cifs_io_subrequest *wdata)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (wdata->subreq.retry_count > 0)
|
||||
if (wdata->replay) {
|
||||
/* Back-off before retry */
|
||||
if (wdata->cur_sleep)
|
||||
msleep(wdata->cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
cifs_dbg(FYI, "async write at %llu %u bytes iter=%zx\n",
|
||||
io_parms->offset, io_parms->length, iov_iter_count(&wdata->subreq.io_iter));
|
||||
|
|
@ -5159,6 +5244,16 @@ smb2_async_writev(struct cifs_io_subrequest *wdata)
|
|||
async_writev_out:
|
||||
cifs_small_buf_release(req);
|
||||
out:
|
||||
/* if the send error is retryable, let netfs know about it */
|
||||
if (is_replayable_error(rc) &&
|
||||
smb2_should_replay(tcon,
|
||||
&wdata->retries,
|
||||
&wdata->cur_sleep)) {
|
||||
wdata->replay = true;
|
||||
trace_netfs_sreq(&wdata->subreq, netfs_sreq_trace_io_retry_needed);
|
||||
__set_bit(NETFS_SREQ_NEED_RETRY, &wdata->subreq.flags);
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
trace_smb3_rw_credits(wdata->rreq->debug_id,
|
||||
wdata->subreq.debug_index,
|
||||
|
|
@ -5190,7 +5285,7 @@ SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
|
|||
int flags = 0;
|
||||
unsigned int total_len;
|
||||
struct TCP_Server_Info *server;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -5238,8 +5333,12 @@ replay_again:
|
|||
rqst.rq_iov = iov;
|
||||
rqst.rq_nvec = n_vec + 1;
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, io_parms->tcon->ses, server,
|
||||
&rqst,
|
||||
|
|
@ -5590,7 +5689,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
struct cifs_ses *ses = tcon->ses;
|
||||
struct TCP_Server_Info *server;
|
||||
int flags = 0;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -5615,8 +5714,12 @@ replay_again:
|
|||
if (rc)
|
||||
goto qdir_exit;
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
&rqst, &resp_buftype, flags, &rsp_iov);
|
||||
|
|
@ -5725,7 +5828,7 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
struct cifs_ses *ses = tcon->ses;
|
||||
struct TCP_Server_Info *server;
|
||||
int flags = 0;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -5758,8 +5861,12 @@ replay_again:
|
|||
return rc;
|
||||
}
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
&rqst, &resp_buftype, flags,
|
||||
|
|
@ -5838,7 +5945,7 @@ SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
struct kvec iov[1];
|
||||
struct kvec rsp_iov;
|
||||
int resp_buf_type;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -5868,8 +5975,12 @@ replay_again:
|
|||
rqst.rq_iov = iov;
|
||||
rqst.rq_nvec = 1;
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
&rqst, &resp_buf_type, flags, &rsp_iov);
|
||||
|
|
@ -5971,7 +6082,7 @@ SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
struct TCP_Server_Info *server;
|
||||
FILE_SYSTEM_POSIX_INFO *info = NULL;
|
||||
int flags = 0;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -5992,8 +6103,12 @@ replay_again:
|
|||
rqst.rq_iov = &iov;
|
||||
rqst.rq_nvec = 1;
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
&rqst, &resp_buftype, flags, &rsp_iov);
|
||||
|
|
@ -6036,7 +6151,7 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
struct TCP_Server_Info *server;
|
||||
unsigned int rsp_len, offset;
|
||||
int flags = 0;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -6073,8 +6188,12 @@ replay_again:
|
|||
rqst.rq_iov = &iov;
|
||||
rqst.rq_nvec = 1;
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, ses, server,
|
||||
&rqst, &resp_buftype, flags, &rsp_iov);
|
||||
|
|
@ -6136,7 +6255,7 @@ smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
|
|||
int flags = CIFS_NO_RSP_BUF;
|
||||
unsigned int total_len;
|
||||
struct TCP_Server_Info *server;
|
||||
int retries = 0, cur_sleep = 1;
|
||||
int retries = 0, cur_sleep = 0;
|
||||
|
||||
replay_again:
|
||||
/* reinitialize for possible replay */
|
||||
|
|
@ -6172,8 +6291,12 @@ replay_again:
|
|||
rqst.rq_iov = iov;
|
||||
rqst.rq_nvec = 2;
|
||||
|
||||
if (retries)
|
||||
if (retries) {
|
||||
/* Back-off before retry */
|
||||
if (cur_sleep)
|
||||
msleep(cur_sleep);
|
||||
smb2_set_replay(server, &rqst);
|
||||
}
|
||||
|
||||
rc = cifs_send_recv(xid, tcon->ses, server,
|
||||
&rqst, &resp_buf_type, flags,
|
||||
|
|
|
|||
|
|
@ -22,287 +22,252 @@ struct smb_rqst;
|
|||
* All Prototypes
|
||||
*****************************************************************
|
||||
*/
|
||||
extern int map_smb2_to_linux_error(char *buf, bool log_err);
|
||||
extern int smb2_check_message(char *buf, unsigned int pdu_len, unsigned int length,
|
||||
struct TCP_Server_Info *server);
|
||||
extern unsigned int smb2_calc_size(void *buf);
|
||||
extern char *smb2_get_data_area_len(int *off, int *len,
|
||||
struct smb2_hdr *shdr);
|
||||
extern __le16 *cifs_convert_path_to_utf16(const char *from,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
int map_smb2_to_linux_error(char *buf, bool log_err);
|
||||
int smb2_init_maperror(void);
|
||||
int smb2_check_message(char *buf, unsigned int pdu_len, unsigned int len,
|
||||
struct TCP_Server_Info *server);
|
||||
unsigned int smb2_calc_size(void *buf);
|
||||
char *smb2_get_data_area_len(int *off, int *len, struct smb2_hdr *shdr);
|
||||
__le16 *cifs_convert_path_to_utf16(const char *from,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
|
||||
extern int smb2_verify_signature(struct smb_rqst *, struct TCP_Server_Info *);
|
||||
extern int smb2_check_receive(struct mid_q_entry *mid,
|
||||
struct TCP_Server_Info *server, bool log_error);
|
||||
extern struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *,
|
||||
struct smb_rqst *rqst);
|
||||
extern struct mid_q_entry *smb2_setup_async_request(
|
||||
struct TCP_Server_Info *server, struct smb_rqst *rqst);
|
||||
extern struct cifs_tcon *smb2_find_smb_tcon(struct TCP_Server_Info *server,
|
||||
__u64 ses_id, __u32 tid);
|
||||
extern __le32 smb2_get_lease_state(struct cifsInodeInfo *cinode);
|
||||
extern bool smb2_is_valid_oplock_break(char *buffer,
|
||||
struct TCP_Server_Info *srv);
|
||||
extern int smb3_handle_read_data(struct TCP_Server_Info *server,
|
||||
struct mid_q_entry *mid);
|
||||
int smb2_verify_signature(struct smb_rqst *rqst,
|
||||
struct TCP_Server_Info *server);
|
||||
int smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
|
||||
bool log_error);
|
||||
struct mid_q_entry *smb2_setup_request(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst);
|
||||
struct mid_q_entry *smb2_setup_async_request(struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst);
|
||||
struct cifs_tcon *smb2_find_smb_tcon(struct TCP_Server_Info *server,
|
||||
__u64 ses_id, __u32 tid);
|
||||
__le32 smb2_get_lease_state(struct cifsInodeInfo *cinode);
|
||||
bool smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server);
|
||||
int smb3_handle_read_data(struct TCP_Server_Info *server,
|
||||
struct mid_q_entry *mid);
|
||||
struct inode *smb2_create_reparse_inode(struct cifs_open_info_data *data,
|
||||
struct super_block *sb,
|
||||
const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
const char *full_path,
|
||||
bool directory,
|
||||
struct kvec *reparse_iov,
|
||||
struct kvec *xattr_iov);
|
||||
int smb2_query_reparse_point(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
struct super_block *sb,
|
||||
const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
const char *full_path, bool directory,
|
||||
struct kvec *reparse_iov,
|
||||
struct kvec *xattr_iov);
|
||||
int smb2_query_reparse_point(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
const char *full_path,
|
||||
u32 *tag, struct kvec *rsp,
|
||||
const char *full_path, u32 *tag, struct kvec *rsp,
|
||||
int *rsp_buftype);
|
||||
int smb2_query_path_info(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
const char *full_path,
|
||||
int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb, const char *full_path,
|
||||
struct cifs_open_info_data *data);
|
||||
extern int smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *full_path, __u64 size,
|
||||
struct cifs_sb_info *cifs_sb, bool set_alloc,
|
||||
struct dentry *dentry);
|
||||
extern int smb2_set_file_info(struct inode *inode, const char *full_path,
|
||||
FILE_BASIC_INFO *buf, const unsigned int xid);
|
||||
extern int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
|
||||
umode_t mode, struct cifs_tcon *tcon,
|
||||
const char *full_path,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
extern int smb2_mkdir(const unsigned int xid, struct inode *inode,
|
||||
umode_t mode, struct cifs_tcon *tcon,
|
||||
const char *name, struct cifs_sb_info *cifs_sb);
|
||||
extern void smb2_mkdir_setinfo(struct inode *inode, const char *full_path,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
struct cifs_tcon *tcon, const unsigned int xid);
|
||||
extern int smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *name, struct cifs_sb_info *cifs_sb);
|
||||
extern int smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *name, struct cifs_sb_info *cifs_sb,
|
||||
struct dentry *dentry);
|
||||
int smb2_rename_path(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
struct dentry *source_dentry,
|
||||
const char *from_name, const char *to_name,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
int smb2_create_hardlink(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
struct dentry *source_dentry,
|
||||
const char *from_name, const char *to_name,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
extern int smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb, const unsigned char *path,
|
||||
char *pbuf, unsigned int *pbytes_written);
|
||||
extern int smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
|
||||
int smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *full_path, __u64 size,
|
||||
struct cifs_sb_info *cifs_sb, bool set_alloc,
|
||||
struct dentry *dentry);
|
||||
int smb2_set_file_info(struct inode *inode, const char *full_path,
|
||||
FILE_BASIC_INFO *buf, const unsigned int xid);
|
||||
int smb311_posix_mkdir(const unsigned int xid, struct inode *inode,
|
||||
umode_t mode, struct cifs_tcon *tcon,
|
||||
const char *full_path, struct cifs_sb_info *cifs_sb);
|
||||
int smb2_mkdir(const unsigned int xid, struct inode *parent_inode,
|
||||
umode_t mode, struct cifs_tcon *tcon, const char *name,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
void smb2_mkdir_setinfo(struct inode *inode, const char *name,
|
||||
struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
|
||||
const unsigned int xid);
|
||||
int smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *name, struct cifs_sb_info *cifs_sb);
|
||||
int smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *name, struct cifs_sb_info *cifs_sb,
|
||||
struct dentry *dentry);
|
||||
int smb2_rename_path(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct dentry *source_dentry, const char *from_name,
|
||||
const char *to_name, struct cifs_sb_info *cifs_sb);
|
||||
int smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct dentry *source_dentry, const char *from_name,
|
||||
const char *to_name, struct cifs_sb_info *cifs_sb);
|
||||
int smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
const unsigned char *path, char *pbuf,
|
||||
unsigned int *pbytes_written);
|
||||
int smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct cifs_sb_info *cifs_sb,
|
||||
const unsigned char *path, char *pbuf,
|
||||
unsigned int *pbytes_read);
|
||||
int smb2_fix_symlink_target_type(char **target, bool directory, struct cifs_sb_info *cifs_sb);
|
||||
int smb2_fix_symlink_target_type(char **target, bool directory,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
int smb2_parse_native_symlink(char **target, const char *buf, unsigned int len,
|
||||
bool relative,
|
||||
const char *full_path,
|
||||
bool relative, const char *full_path,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
int smb2_parse_symlink_response(struct cifs_sb_info *cifs_sb,
|
||||
const struct kvec *iov,
|
||||
const char *full_path,
|
||||
const struct kvec *iov, const char *full_path,
|
||||
char **path);
|
||||
int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32 *oplock,
|
||||
void *buf);
|
||||
extern int smb2_unlock_range(struct cifsFileInfo *cfile,
|
||||
struct file_lock *flock, const unsigned int xid);
|
||||
extern int smb2_push_mandatory_locks(struct cifsFileInfo *cfile);
|
||||
extern void smb2_reconnect_server(struct work_struct *work);
|
||||
extern int smb3_crypto_aead_allocate(struct TCP_Server_Info *server);
|
||||
extern unsigned long smb_rqst_len(struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst);
|
||||
extern void smb2_set_next_command(struct cifs_tcon *tcon,
|
||||
struct smb_rqst *rqst);
|
||||
extern void smb2_set_related(struct smb_rqst *rqst);
|
||||
extern void smb2_set_replay(struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst);
|
||||
extern bool smb2_should_replay(struct cifs_tcon *tcon,
|
||||
int *pretries,
|
||||
int *pcur_sleep);
|
||||
int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
|
||||
__u32 *oplock, void *buf);
|
||||
int smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
|
||||
const unsigned int xid);
|
||||
int smb2_push_mandatory_locks(struct cifsFileInfo *cfile);
|
||||
void smb2_reconnect_server(struct work_struct *work);
|
||||
int smb3_crypto_aead_allocate(struct TCP_Server_Info *server);
|
||||
unsigned long smb_rqst_len(struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst);
|
||||
void smb2_set_next_command(struct cifs_tcon *tcon, struct smb_rqst *rqst);
|
||||
void smb2_set_related(struct smb_rqst *rqst);
|
||||
void smb2_set_replay(struct TCP_Server_Info *server, struct smb_rqst *rqst);
|
||||
bool smb2_should_replay(struct cifs_tcon *tcon, int *pretries,
|
||||
int *pcur_sleep);
|
||||
|
||||
/*
|
||||
* SMB2 Worker functions - most of protocol specific implementation details
|
||||
* are contained within these calls.
|
||||
*/
|
||||
extern int SMB2_negotiate(const unsigned int xid,
|
||||
struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
extern int SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const struct nls_table *nls_cp);
|
||||
extern int SMB2_logoff(const unsigned int xid, struct cifs_ses *ses);
|
||||
extern int SMB2_tcon(const unsigned int xid, struct cifs_ses *ses,
|
||||
const char *tree, struct cifs_tcon *tcon,
|
||||
const struct nls_table *);
|
||||
extern int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon);
|
||||
extern int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms,
|
||||
__le16 *path, __u8 *oplock,
|
||||
struct smb2_file_all_info *buf,
|
||||
struct create_posix_rsp *posix,
|
||||
struct kvec *err_iov, int *resp_buftype);
|
||||
extern int SMB2_open_init(struct cifs_tcon *tcon,
|
||||
struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst,
|
||||
__u8 *oplock, struct cifs_open_parms *oparms,
|
||||
__le16 *path);
|
||||
extern void SMB2_open_free(struct smb_rqst *rqst);
|
||||
extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, u32 opcode,
|
||||
char *in_data, u32 indatalen, u32 maxoutlen,
|
||||
char **out_data, u32 *plen /* returned data len */);
|
||||
extern int SMB2_ioctl_init(struct cifs_tcon *tcon,
|
||||
struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst,
|
||||
u64 persistent_fid, u64 volatile_fid, u32 opcode,
|
||||
char *in_data, u32 indatalen,
|
||||
__u32 max_response_size);
|
||||
extern void SMB2_ioctl_free(struct smb_rqst *rqst);
|
||||
extern int SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, bool watch_tree,
|
||||
u32 completion_filter, u32 max_out_data_len,
|
||||
char **out_data, u32 *plen /* returned data len */);
|
||||
int SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server);
|
||||
int SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
const struct nls_table *nls_cp);
|
||||
int SMB2_logoff(const unsigned int xid, struct cifs_ses *ses);
|
||||
int SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
|
||||
struct cifs_tcon *tcon, const struct nls_table *cp);
|
||||
int SMB2_tdis(const unsigned int xid, struct cifs_tcon *tcon);
|
||||
int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms,
|
||||
__le16 *path, __u8 *oplock, struct smb2_file_all_info *buf,
|
||||
struct create_posix_rsp *posix, struct kvec *err_iov,
|
||||
int *buftype);
|
||||
int SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst, __u8 *oplock,
|
||||
struct cifs_open_parms *oparms, __le16 *path);
|
||||
void SMB2_open_free(struct smb_rqst *rqst);
|
||||
int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, u32 opcode, char *in_data,
|
||||
u32 indatalen, u32 max_out_data_len, char **out_data,
|
||||
u32 *plen /* returned data len */);
|
||||
int SMB2_ioctl_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst, u64 persistent_fid,
|
||||
u64 volatile_fid, u32 opcode, char *in_data, u32 indatalen,
|
||||
__u32 max_response_size);
|
||||
void SMB2_ioctl_free(struct smb_rqst *rqst);
|
||||
int SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, bool watch_tree,
|
||||
u32 completion_filter, u32 max_out_data_len,
|
||||
char **out_data, u32 *plen /* returned data len */);
|
||||
|
||||
extern int __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid,
|
||||
struct smb2_file_network_open_info *pbuf);
|
||||
extern int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_file_id, u64 volatile_file_id);
|
||||
extern int SMB2_close_init(struct cifs_tcon *tcon,
|
||||
struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst,
|
||||
u64 persistent_fid, u64 volatile_fid,
|
||||
bool query_attrs);
|
||||
extern void SMB2_close_free(struct smb_rqst *rqst);
|
||||
extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_file_id, u64 volatile_file_id);
|
||||
extern int SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst,
|
||||
struct cifs_tcon *tcon,
|
||||
struct TCP_Server_Info *server,
|
||||
u64 persistent_file_id, u64 volatile_file_id);
|
||||
extern void SMB2_flush_free(struct smb_rqst *rqst);
|
||||
extern int SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, struct smb311_posix_qinfo *data, u32 *plen);
|
||||
extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_file_id, u64 volatile_file_id,
|
||||
struct smb2_file_all_info *data);
|
||||
extern int SMB2_query_info_init(struct cifs_tcon *tcon,
|
||||
struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst,
|
||||
u64 persistent_fid, u64 volatile_fid,
|
||||
u8 info_class, u8 info_type,
|
||||
u32 additional_info, size_t output_len,
|
||||
size_t input_len, void *input);
|
||||
extern void SMB2_query_info_free(struct smb_rqst *rqst);
|
||||
extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_file_id, u64 volatile_file_id,
|
||||
void **data, unsigned int *plen, u32 info);
|
||||
extern int SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
int __SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid,
|
||||
struct smb2_file_network_open_info *pbuf);
|
||||
int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid);
|
||||
int SMB2_close_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst, u64 persistent_fid,
|
||||
u64 volatile_fid, bool query_attrs);
|
||||
void SMB2_close_free(struct smb_rqst *rqst);
|
||||
int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid);
|
||||
int SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst,
|
||||
struct cifs_tcon *tcon, struct TCP_Server_Info *server,
|
||||
u64 persistent_fid, u64 volatile_fid);
|
||||
void SMB2_flush_free(struct smb_rqst *rqst);
|
||||
int SMB311_posix_query_info(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid,
|
||||
__le64 *uniqueid);
|
||||
extern int smb2_async_readv(struct cifs_io_subrequest *rdata);
|
||||
extern int SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
|
||||
unsigned int *nbytes, char **buf, int *buf_type);
|
||||
extern void smb2_async_writev(struct cifs_io_subrequest *wdata);
|
||||
extern int SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
|
||||
unsigned int *nbytes, struct kvec *iov, int n_vec);
|
||||
extern int SMB2_echo(struct TCP_Server_Info *server);
|
||||
extern int SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, int index,
|
||||
struct cifs_search_info *srch_inf);
|
||||
extern int SMB2_query_directory_init(unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst,
|
||||
u64 persistent_fid, u64 volatile_fid,
|
||||
int index, int info_level);
|
||||
extern void SMB2_query_directory_free(struct smb_rqst *rqst);
|
||||
extern int SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, u32 pid,
|
||||
loff_t new_eof);
|
||||
extern int SMB2_set_info_init(struct cifs_tcon *tcon,
|
||||
struct smb311_posix_qinfo *data, u32 *plen);
|
||||
int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid,
|
||||
struct smb2_file_all_info *data);
|
||||
int SMB2_query_info_init(struct cifs_tcon *tcon,
|
||||
struct TCP_Server_Info *server, struct smb_rqst *rqst,
|
||||
u64 persistent_fid, u64 volatile_fid, u8 info_class,
|
||||
u8 info_type, u32 additional_info, size_t output_len,
|
||||
size_t input_len, void *input);
|
||||
void SMB2_query_info_free(struct smb_rqst *rqst);
|
||||
int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, void **data,
|
||||
u32 *plen, u32 extra_info);
|
||||
int SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, __le64 *uniqueid);
|
||||
int smb2_async_readv(struct cifs_io_subrequest *rdata);
|
||||
int SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms,
|
||||
unsigned int *nbytes, char **buf, int *buf_type);
|
||||
void smb2_async_writev(struct cifs_io_subrequest *wdata);
|
||||
int SMB2_write(const unsigned int xid, struct cifs_io_parms *io_parms,
|
||||
unsigned int *nbytes, struct kvec *iov, int n_vec);
|
||||
int SMB2_echo(struct TCP_Server_Info *server);
|
||||
int SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, int index,
|
||||
struct cifs_search_info *srch_inf);
|
||||
int SMB2_query_directory_init(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst,
|
||||
u64 persistent_fid, u64 volatile_fid, u32 pid,
|
||||
u8 info_class, u8 info_type, u32 additional_info,
|
||||
void **data, unsigned int *size);
|
||||
extern void SMB2_set_info_free(struct smb_rqst *rqst);
|
||||
extern int SMB2_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid,
|
||||
struct smb_ntsd *pnntsd, int pacllen, int aclflag);
|
||||
extern int SMB2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid,
|
||||
struct smb2_file_full_ea_info *buf, int len);
|
||||
extern int SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid);
|
||||
extern int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const u64 persistent_fid, const u64 volatile_fid,
|
||||
const __u8 oplock_level);
|
||||
extern int smb2_handle_cancelled_close(struct cifs_tcon *tcon,
|
||||
__u64 persistent_fid,
|
||||
__u64 volatile_fid);
|
||||
extern int smb2_handle_cancelled_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server);
|
||||
struct smb_rqst *rqst, u64 persistent_fid,
|
||||
u64 volatile_fid, int index, int info_level);
|
||||
void SMB2_query_directory_free(struct smb_rqst *rqst);
|
||||
int SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, u32 pid,
|
||||
loff_t new_eof);
|
||||
int SMB2_set_info_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server,
|
||||
struct smb_rqst *rqst, u64 persistent_fid,
|
||||
u64 volatile_fid, u32 pid, u8 info_class, u8 info_type,
|
||||
u32 additional_info, void **data, unsigned int *size);
|
||||
void SMB2_set_info_free(struct smb_rqst *rqst);
|
||||
int SMB2_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, struct smb_ntsd *pnntsd,
|
||||
int pacllen, int aclflag);
|
||||
int SMB2_set_ea(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid,
|
||||
struct smb2_file_full_ea_info *buf, int len);
|
||||
int SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid);
|
||||
int SMB2_oplock_break(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const u64 persistent_fid, const u64 volatile_fid,
|
||||
__u8 oplock_level);
|
||||
int smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,
|
||||
__u64 volatile_fid);
|
||||
int smb2_handle_cancelled_mid(struct mid_q_entry *mid,
|
||||
struct TCP_Server_Info *server);
|
||||
void smb2_cancelled_close_fid(struct work_struct *work);
|
||||
extern int SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_file_id, u64 volatile_file_id,
|
||||
struct kstatfs *FSData);
|
||||
extern int SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_file_id, u64 volatile_file_id, int lvl);
|
||||
extern int SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u64 persist_fid, const __u64 volatile_fid,
|
||||
const __u32 pid, const __u64 length, const __u64 offset,
|
||||
const __u32 lockFlags, const bool wait);
|
||||
extern int smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u64 persist_fid, const __u64 volatile_fid,
|
||||
const __u32 pid, const __u32 num_lock,
|
||||
struct smb2_lock_element *buf);
|
||||
extern int SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
__u8 *lease_key, const __le32 lease_state);
|
||||
extern int smb3_validate_negotiate(const unsigned int, struct cifs_tcon *);
|
||||
int SMB311_posix_qfs_info(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid,
|
||||
struct kstatfs *fsdata);
|
||||
int SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
u64 persistent_fid, u64 volatile_fid, int level);
|
||||
int SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u64 persist_fid, const __u64 volatile_fid,
|
||||
const __u32 pid, const __u64 length, const __u64 offset,
|
||||
const __u32 lock_flags, const bool wait);
|
||||
int smb2_lockv(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const __u64 persist_fid, const __u64 volatile_fid,
|
||||
const __u32 pid, const __u32 num_lock,
|
||||
struct smb2_lock_element *buf);
|
||||
int SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
__u8 *lease_key, const __le32 lease_state);
|
||||
int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon);
|
||||
|
||||
extern enum securityEnum smb2_select_sectype(struct TCP_Server_Info *,
|
||||
enum securityEnum);
|
||||
int smb2_parse_contexts(struct TCP_Server_Info *server,
|
||||
struct kvec *rsp_iov,
|
||||
__u16 *epoch,
|
||||
char *lease_key, __u8 *oplock,
|
||||
enum securityEnum smb2_select_sectype(struct TCP_Server_Info *server,
|
||||
enum securityEnum requested);
|
||||
int smb2_parse_contexts(struct TCP_Server_Info *server, struct kvec *rsp_iov,
|
||||
__u16 *epoch, char *lease_key, __u8 *oplock,
|
||||
struct smb2_file_all_info *buf,
|
||||
struct create_posix_rsp *posix);
|
||||
|
||||
extern int smb3_encryption_required(const struct cifs_tcon *tcon);
|
||||
extern int smb2_validate_iov(unsigned int offset, unsigned int buffer_length,
|
||||
struct kvec *iov, unsigned int min_buf_size);
|
||||
extern int smb2_validate_and_copy_iov(unsigned int offset,
|
||||
unsigned int buffer_length,
|
||||
struct kvec *iov,
|
||||
unsigned int minbufsize, char *data);
|
||||
extern void smb2_copy_fs_info_to_kstatfs(
|
||||
struct smb2_fs_full_size_info *pfs_inf,
|
||||
struct kstatfs *kst);
|
||||
extern int smb3_crypto_shash_allocate(struct TCP_Server_Info *server);
|
||||
extern void smb311_update_preauth_hash(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
struct kvec *iov, int nvec);
|
||||
extern int smb2_query_info_compound(const unsigned int xid,
|
||||
struct cifs_tcon *tcon,
|
||||
const char *path, u32 desired_access,
|
||||
u32 class, u32 type, u32 output_len,
|
||||
struct kvec *rsp, int *buftype,
|
||||
struct cifs_sb_info *cifs_sb);
|
||||
int smb3_encryption_required(const struct cifs_tcon *tcon);
|
||||
int smb2_validate_iov(unsigned int offset, unsigned int buffer_length,
|
||||
struct kvec *iov, unsigned int min_buf_size);
|
||||
int smb2_validate_and_copy_iov(unsigned int offset, unsigned int buffer_length,
|
||||
struct kvec *iov, unsigned int minbufsize,
|
||||
char *data);
|
||||
void smb2_copy_fs_info_to_kstatfs(struct smb2_fs_full_size_info *pfs_inf,
|
||||
struct kstatfs *kst);
|
||||
int smb3_crypto_shash_allocate(struct TCP_Server_Info *server);
|
||||
void smb311_update_preauth_hash(struct cifs_ses *ses,
|
||||
struct TCP_Server_Info *server,
|
||||
struct kvec *iov, int nvec);
|
||||
int smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
|
||||
const char *path, u32 desired_access, u32 class,
|
||||
u32 type, u32 output_len, struct kvec *rsp,
|
||||
int *buftype, struct cifs_sb_info *cifs_sb);
|
||||
/* query path info from the server using SMB311 POSIX extensions*/
|
||||
int posix_info_parse(const void *beg, const void *end,
|
||||
struct smb2_posix_info_parsed *out);
|
||||
int posix_info_sid_size(const void *beg, const void *end);
|
||||
int smb2_rename_pending_delete(const char *full_path,
|
||||
struct dentry *dentry,
|
||||
int smb2_rename_pending_delete(const char *full_path, struct dentry *dentry,
|
||||
const unsigned int xid);
|
||||
|
||||
#endif /* _SMB2PROTO_H */
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#include <linux/random.h>
|
||||
#include "cifs_fs_sb.h"
|
||||
#include "cifs_unicode.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifs_debug.h"
|
||||
#include "cifsproto.h"
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@
|
|||
#define ERRinvparm 87
|
||||
#define ERRdiskfull 112
|
||||
#define ERRinvname 123
|
||||
#define ERRinvlevel 124
|
||||
#define ERRunknownlevel 124
|
||||
#define ERRdirnotempty 145
|
||||
#define ERRnotlocked 158
|
||||
#define ERRcancelviolation 173
|
||||
|
|
|
|||
|
|
@ -189,6 +189,7 @@
|
|||
EM(netfs_trace_tcon_ref_put_cancelled_close_fid, "PUT Cn-Fid") \
|
||||
EM(netfs_trace_tcon_ref_put_cancelled_mid, "PUT Cn-Mid") \
|
||||
EM(netfs_trace_tcon_ref_put_mnt_ctx, "PUT MntCtx") \
|
||||
EM(netfs_trace_tcon_ref_put_dfs_refer, "PUT DfsRfr") \
|
||||
EM(netfs_trace_tcon_ref_put_reconnect_server, "PUT Reconn") \
|
||||
EM(netfs_trace_tcon_ref_put_tlink, "PUT Tlink ") \
|
||||
EM(netfs_trace_tcon_ref_see_cancelled_close, "SEE Cn-Cls") \
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@
|
|||
#include <linux/sched/signal.h>
|
||||
#include <linux/task_io_accounting_ops.h>
|
||||
#include <linux/task_work.h>
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_debug.h"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#include <linux/slab.h>
|
||||
#include <linux/xattr.h>
|
||||
#include "cifsfs.h"
|
||||
#include "cifspdu.h"
|
||||
#include "cifsglob.h"
|
||||
#include "cifsproto.h"
|
||||
#include "cifs_debug.h"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@
|
|||
#ifndef _COMMON_SMB2PDU_H
|
||||
#define _COMMON_SMB2PDU_H
|
||||
|
||||
#include <linux/types.h>
|
||||
#include <linux/build_bug.h>
|
||||
|
||||
/*
|
||||
* Note that, due to trying to use names similar to the protocol specifications,
|
||||
* there are many mixed case field names in the structures below. Although
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue