Commit fb157ed2 authored by Steve French's avatar Steve French

cifs: when insecure legacy is disabled shrink amount of SMB1 code

Currently much of the smb1 code is built even when
CONFIG_CIFS_ALLOW_INSECURE_LEGACY is disabled.

Move cifssmb.c to only be compiled when insecure legacy is disabled,
and move various SMB1/CIFS helper functions to that ifdef.  Some
functions that were not SMB1/CIFS specific needed to be moved out of
cifssmb.c

This shrinks cifs.ko by more than 10% which is good - but also will
help with the eventual movement of the legacy code to a distinct
module.  Follow on patches can shrink the number of ifdefs by
code restructuring where smb1 code is wedged in functions that
should be calling dialect specific helper functions instead,
and also by moving some functions from file.c/dir.c/inode.c into
smb1 specific c files.
Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@cjr.nz>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 97b82c07
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
ccflags-y += -I$(src) # needed for trace events ccflags-y += -I$(src) # needed for trace events
obj-$(CONFIG_CIFS) += cifs.o obj-$(CONFIG_CIFS) += cifs.o
cifs-y := trace.o cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o \ cifs-y := trace.o cifsfs.o cifs_debug.o connect.o dir.o file.o \
inode.o link.o misc.o netmisc.o smbencrypt.o transport.o \ inode.o link.o misc.o netmisc.o smbencrypt.o transport.o \
cifs_unicode.o nterr.o cifsencrypt.o \ cifs_unicode.o nterr.o cifsencrypt.o \
readdir.o ioctl.o sess.o export.o unc.o winucase.o \ readdir.o ioctl.o sess.o export.o unc.o winucase.o \
...@@ -31,4 +31,4 @@ cifs-$(CONFIG_CIFS_SMB_DIRECT) += smbdirect.o ...@@ -31,4 +31,4 @@ cifs-$(CONFIG_CIFS_SMB_DIRECT) += smbdirect.o
cifs-$(CONFIG_CIFS_ROOT) += cifsroot.o cifs-$(CONFIG_CIFS_ROOT) += cifsroot.o
cifs-$(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) += smb1ops.o cifs-$(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) += smb1ops.o cifssmb.o
...@@ -1379,6 +1379,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, ...@@ -1379,6 +1379,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
return rc; return rc;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
const struct cifs_fid *cifsfid, u32 *pacllen, const struct cifs_fid *cifsfid, u32 *pacllen,
u32 __maybe_unused unused) u32 __maybe_unused unused)
...@@ -1512,6 +1513,7 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, ...@@ -1512,6 +1513,7 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
cifs_put_tlink(tlink); cifs_put_tlink(tlink);
return rc; return rc;
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
/* Translate the CIFS ACL (similar to NTFS ACL) for a file into mode bits */ /* Translate the CIFS ACL (similar to NTFS ACL) for a file into mode bits */
int int
......
...@@ -521,6 +521,7 @@ extern int generate_smb30signingkey(struct cifs_ses *ses, ...@@ -521,6 +521,7 @@ extern int generate_smb30signingkey(struct cifs_ses *ses,
extern int generate_smb311signingkey(struct cifs_ses *ses, extern int generate_smb311signingkey(struct cifs_ses *ses,
struct TCP_Server_Info *server); struct TCP_Server_Info *server);
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
extern int CIFSSMBCopy(unsigned int xid, extern int CIFSSMBCopy(unsigned int xid,
struct cifs_tcon *source_tcon, struct cifs_tcon *source_tcon,
const char *fromName, const char *fromName,
...@@ -551,6 +552,7 @@ extern int CIFSSMBSetPosixACL(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -551,6 +552,7 @@ extern int CIFSSMBSetPosixACL(const unsigned int xid, struct cifs_tcon *tcon,
const struct nls_table *nls_codepage, int remap_special_chars); const struct nls_table *nls_codepage, int remap_special_chars);
extern int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon, extern int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon,
const int netfid, __u64 *pExtAttrBits, __u64 *pMask); const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
#endif /* CIFS_ALLOW_INSECURE_LEGACY */
extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb); extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb);
extern bool couldbe_mf_symlink(const struct cifs_fattr *fattr); extern bool couldbe_mf_symlink(const struct cifs_fattr *fattr);
extern int check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, extern int check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
......
This diff is collapsed.
...@@ -898,6 +898,53 @@ handle_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server, ...@@ -898,6 +898,53 @@ handle_mid(struct mid_q_entry *mid, struct TCP_Server_Info *server,
dequeue_mid(mid, malformed); dequeue_mid(mid, malformed);
} }
int
cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required)
{
bool srv_sign_required = server->sec_mode & server->vals->signing_required;
bool srv_sign_enabled = server->sec_mode & server->vals->signing_enabled;
bool mnt_sign_enabled;
/*
* Is signing required by mnt options? If not then check
* global_secflags to see if it is there.
*/
if (!mnt_sign_required)
mnt_sign_required = ((global_secflags & CIFSSEC_MUST_SIGN) ==
CIFSSEC_MUST_SIGN);
/*
* If signing is required then it's automatically enabled too,
* otherwise, check to see if the secflags allow it.
*/
mnt_sign_enabled = mnt_sign_required ? mnt_sign_required :
(global_secflags & CIFSSEC_MAY_SIGN);
/* If server requires signing, does client allow it? */
if (srv_sign_required) {
if (!mnt_sign_enabled) {
cifs_dbg(VFS, "Server requires signing, but it's disabled in SecurityFlags!\n");
return -EOPNOTSUPP;
}
server->sign = true;
}
/* If client requires signing, does server allow it? */
if (mnt_sign_required) {
if (!srv_sign_enabled) {
cifs_dbg(VFS, "Server does not support signing!\n");
return -EOPNOTSUPP;
}
server->sign = true;
}
if (cifs_rdma_enabled(server) && server->sign)
cifs_dbg(VFS, "Signing is enabled, and RDMA read/write will be disabled\n");
return 0;
}
static void clean_demultiplex_info(struct TCP_Server_Info *server) static void clean_demultiplex_info(struct TCP_Server_Info *server)
{ {
int length; int length;
...@@ -2976,6 +3023,7 @@ ip_connect(struct TCP_Server_Info *server) ...@@ -2976,6 +3023,7 @@ ip_connect(struct TCP_Server_Info *server)
return generic_ip_connect(server); return generic_ip_connect(server);
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon, void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx) struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
{ {
...@@ -3081,6 +3129,7 @@ void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon, ...@@ -3081,6 +3129,7 @@ void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
} }
} }
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb) int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb)
{ {
...@@ -3197,6 +3246,7 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx) ...@@ -3197,6 +3246,7 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx)
if (tcon->posix_extensions) if (tcon->posix_extensions)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_POSIX_PATHS; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_POSIX_PATHS;
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
/* tell server which Unix caps we support */ /* tell server which Unix caps we support */
if (cap_unix(tcon->ses)) { if (cap_unix(tcon->ses)) {
/* /*
...@@ -3214,6 +3264,7 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx) ...@@ -3214,6 +3264,7 @@ static int mount_get_conns(struct mount_ctx *mnt_ctx)
} }
spin_unlock(&tcon->ses->server->srv_lock); spin_unlock(&tcon->ses->server->srv_lock);
} else } else
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
tcon->unix_ext = 0; /* server does not support them */ tcon->unix_ext = 0; /* server does not support them */
/* do not care if a following call succeed - informational */ /* do not care if a following call succeed - informational */
...@@ -4189,8 +4240,10 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid) ...@@ -4189,8 +4240,10 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
goto out; goto out;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
if (cap_unix(ses)) if (cap_unix(ses))
reset_cifs_unix_caps(0, tcon, NULL, ctx); reset_cifs_unix_caps(0, tcon, NULL, ctx);
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
out: out:
kfree(ctx->username); kfree(ctx->username);
......
...@@ -193,6 +193,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, ...@@ -193,6 +193,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
return PTR_ERR(full_path); return PTR_ERR(full_path);
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
if (tcon->unix_ext && cap_unix(tcon->ses) && !tcon->broken_posix_open && if (tcon->unix_ext && cap_unix(tcon->ses) && !tcon->broken_posix_open &&
(CIFS_UNIX_POSIX_PATH_OPS_CAP & (CIFS_UNIX_POSIX_PATH_OPS_CAP &
le64_to_cpu(tcon->fsUnixInfo.Capability))) { le64_to_cpu(tcon->fsUnixInfo.Capability))) {
...@@ -261,6 +262,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, ...@@ -261,6 +262,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
* rare for path not covered on files) * rare for path not covered on files)
*/ */
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
desired_access = 0; desired_access = 0;
if (OPEN_FMODE(oflags) & FMODE_READ) if (OPEN_FMODE(oflags) & FMODE_READ)
...@@ -316,6 +318,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, ...@@ -316,6 +318,7 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
goto out; goto out;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
/* /*
* If Open reported that we actually created a file then we now have to * If Open reported that we actually created a file then we now have to
* set the mode if possible. * set the mode if possible.
...@@ -357,6 +360,9 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, ...@@ -357,6 +360,9 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
rc = cifs_get_inode_info_unix(&newinode, full_path, inode->i_sb, rc = cifs_get_inode_info_unix(&newinode, full_path, inode->i_sb,
xid); xid);
else { else {
#else
{
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
/* TODO: Add support for calling POSIX query info here, but passing in fid */ /* TODO: Add support for calling POSIX query info here, but passing in fid */
rc = cifs_get_inode_info(&newinode, full_path, buf, inode->i_sb, rc = cifs_get_inode_info(&newinode, full_path, buf, inode->i_sb,
xid, fid); xid, fid);
...@@ -377,7 +383,9 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid, ...@@ -377,7 +383,9 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
} }
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
cifs_create_set_dentry: cifs_create_set_dentry:
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
if (rc != 0) { if (rc != 0) {
cifs_dbg(FYI, "Create worked, get_inode_info failed rc = %d\n", cifs_dbg(FYI, "Create worked, get_inode_info failed rc = %d\n",
rc); rc);
......
This diff is collapsed.
...@@ -339,6 +339,7 @@ cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct super_block *sb) ...@@ -339,6 +339,7 @@ cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct super_block *sb)
fattr->cf_flags = CIFS_FATTR_DFS_REFERRAL; fattr->cf_flags = CIFS_FATTR_DFS_REFERRAL;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
static int static int
cifs_get_file_info_unix(struct file *filp) cifs_get_file_info_unix(struct file *filp)
{ {
...@@ -432,6 +433,14 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -432,6 +433,14 @@ int cifs_get_inode_info_unix(struct inode **pinode,
cgiiu_exit: cgiiu_exit:
return rc; return rc;
} }
#else
int cifs_get_inode_info_unix(struct inode **pinode,
const unsigned char *full_path,
struct super_block *sb, unsigned int xid)
{
return -EOPNOTSUPP;
}
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
static int static int
cifs_sfu_type(struct cifs_fattr *fattr, const char *path, cifs_sfu_type(struct cifs_fattr *fattr, const char *path,
...@@ -795,6 +804,7 @@ static __u64 simple_hashstr(const char *str) ...@@ -795,6 +804,7 @@ static __u64 simple_hashstr(const char *str)
return hash; return hash;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
/** /**
* cifs_backup_query_path_info - SMB1 fallback code to get ino * cifs_backup_query_path_info - SMB1 fallback code to get ino
* *
...@@ -847,6 +857,7 @@ cifs_backup_query_path_info(int xid, ...@@ -847,6 +857,7 @@ cifs_backup_query_path_info(int xid,
*data = (FILE_ALL_INFO *)info.srch_entries_start; *data = (FILE_ALL_INFO *)info.srch_entries_start;
return 0; return 0;
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
static void static void
cifs_set_fattr_ino(int xid, cifs_set_fattr_ino(int xid,
...@@ -991,6 +1002,7 @@ cifs_get_inode_info(struct inode **inode, ...@@ -991,6 +1002,7 @@ cifs_get_inode_info(struct inode **inode,
rc = 0; rc = 0;
break; break;
case -EACCES: case -EACCES:
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
/* /*
* perm errors, try again with backup flags if possible * perm errors, try again with backup flags if possible
* *
...@@ -1022,6 +1034,9 @@ cifs_get_inode_info(struct inode **inode, ...@@ -1022,6 +1034,9 @@ cifs_get_inode_info(struct inode **inode,
/* nothing we can do, bail out */ /* nothing we can do, bail out */
goto out; goto out;
} }
#else
goto out;
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
break; break;
default: default:
cifs_dbg(FYI, "%s: unhandled err rc %d\n", __func__, rc); cifs_dbg(FYI, "%s: unhandled err rc %d\n", __func__, rc);
...@@ -1037,8 +1052,9 @@ cifs_get_inode_info(struct inode **inode, ...@@ -1037,8 +1052,9 @@ cifs_get_inode_info(struct inode **inode,
/* /*
* 4. Tweak fattr based on mount options * 4. Tweak fattr based on mount options
*/ */
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
handle_mnt_opt: handle_mnt_opt:
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
/* query for SFU type info if supported and needed */ /* query for SFU type info if supported and needed */
if (fattr.cf_cifsattrs & ATTR_SYSTEM && if (fattr.cf_cifsattrs & ATTR_SYSTEM &&
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
...@@ -1435,6 +1451,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid, ...@@ -1435,6 +1451,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
return server->ops->set_file_info(inode, full_path, &info_buf, xid); return server->ops->set_file_info(inode, full_path, &info_buf, xid);
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
/* /*
* Open the given file (if it isn't already), set the DELETE_ON_CLOSE bit * Open the given file (if it isn't already), set the DELETE_ON_CLOSE bit
* and rename it to a random name that hopefully won't conflict with * and rename it to a random name that hopefully won't conflict with
...@@ -1565,6 +1582,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, ...@@ -1565,6 +1582,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry,
goto out_close; goto out_close;
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
/* copied from fs/nfs/dir.c with small changes */ /* copied from fs/nfs/dir.c with small changes */
static void static void
...@@ -1627,6 +1645,7 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -1627,6 +1645,7 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
} }
cifs_close_deferred_file_under_dentry(tcon, full_path); cifs_close_deferred_file_under_dentry(tcon, full_path);
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
if (cap_unix(tcon->ses) && (CIFS_UNIX_POSIX_PATH_OPS_CAP & if (cap_unix(tcon->ses) && (CIFS_UNIX_POSIX_PATH_OPS_CAP &
le64_to_cpu(tcon->fsUnixInfo.Capability))) { le64_to_cpu(tcon->fsUnixInfo.Capability))) {
rc = CIFSPOSIXDelFile(xid, tcon, full_path, rc = CIFSPOSIXDelFile(xid, tcon, full_path,
...@@ -1636,6 +1655,7 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -1636,6 +1655,7 @@ int cifs_unlink(struct inode *dir, struct dentry *dentry)
if ((rc == 0) || (rc == -ENOENT)) if ((rc == 0) || (rc == -ENOENT))
goto psx_del_no_retry; goto psx_del_no_retry;
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
retry_std_delete: retry_std_delete:
if (!server->ops->unlink) { if (!server->ops->unlink) {
...@@ -1714,9 +1734,11 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode, ...@@ -1714,9 +1734,11 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode,
if (tcon->posix_extensions) if (tcon->posix_extensions)
rc = smb311_posix_get_inode_info(&inode, full_path, parent->i_sb, xid); rc = smb311_posix_get_inode_info(&inode, full_path, parent->i_sb, xid);
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
else if (tcon->unix_ext) else if (tcon->unix_ext)
rc = cifs_get_inode_info_unix(&inode, full_path, parent->i_sb, rc = cifs_get_inode_info_unix(&inode, full_path, parent->i_sb,
xid); xid);
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
else else
rc = cifs_get_inode_info(&inode, full_path, NULL, parent->i_sb, rc = cifs_get_inode_info(&inode, full_path, NULL, parent->i_sb,
xid, NULL); xid, NULL);
...@@ -1746,6 +1768,7 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode, ...@@ -1746,6 +1768,7 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode,
if (parent->i_mode & S_ISGID) if (parent->i_mode & S_ISGID)
mode |= S_ISGID; mode |= S_ISGID;
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
if (tcon->unix_ext) { if (tcon->unix_ext) {
struct cifs_unix_set_info_args args = { struct cifs_unix_set_info_args args = {
.mode = mode, .mode = mode,
...@@ -1768,6 +1791,9 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode, ...@@ -1768,6 +1791,9 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_remap(cifs_sb)); cifs_remap(cifs_sb));
} else { } else {
#else
{
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
struct TCP_Server_Info *server = tcon->ses->server; struct TCP_Server_Info *server = tcon->ses->server;
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) && if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) &&
(mode & S_IWUGO) == 0 && server->ops->mkdir_setinfo) (mode & S_IWUGO) == 0 && server->ops->mkdir_setinfo)
...@@ -1788,6 +1814,7 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode, ...@@ -1788,6 +1814,7 @@ cifs_mkdir_qinfo(struct inode *parent, struct dentry *dentry, umode_t mode,
return 0; return 0;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
static int static int
cifs_posix_mkdir(struct inode *inode, struct dentry *dentry, umode_t mode, cifs_posix_mkdir(struct inode *inode, struct dentry *dentry, umode_t mode,
const char *full_path, struct cifs_sb_info *cifs_sb, const char *full_path, struct cifs_sb_info *cifs_sb,
...@@ -1850,6 +1877,7 @@ cifs_posix_mkdir(struct inode *inode, struct dentry *dentry, umode_t mode, ...@@ -1850,6 +1877,7 @@ cifs_posix_mkdir(struct inode *inode, struct dentry *dentry, umode_t mode,
xid); xid);
goto posix_mkdir_out; goto posix_mkdir_out;
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
int cifs_mkdir(struct user_namespace *mnt_userns, struct inode *inode, int cifs_mkdir(struct user_namespace *mnt_userns, struct inode *inode,
struct dentry *direntry, umode_t mode) struct dentry *direntry, umode_t mode)
...@@ -1892,6 +1920,7 @@ int cifs_mkdir(struct user_namespace *mnt_userns, struct inode *inode, ...@@ -1892,6 +1920,7 @@ int cifs_mkdir(struct user_namespace *mnt_userns, struct inode *inode,
goto mkdir_out; goto mkdir_out;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
if (cap_unix(tcon->ses) && (CIFS_UNIX_POSIX_PATH_OPS_CAP & if (cap_unix(tcon->ses) && (CIFS_UNIX_POSIX_PATH_OPS_CAP &
le64_to_cpu(tcon->fsUnixInfo.Capability))) { le64_to_cpu(tcon->fsUnixInfo.Capability))) {
rc = cifs_posix_mkdir(inode, direntry, mode, full_path, cifs_sb, rc = cifs_posix_mkdir(inode, direntry, mode, full_path, cifs_sb,
...@@ -1899,6 +1928,7 @@ int cifs_mkdir(struct user_namespace *mnt_userns, struct inode *inode, ...@@ -1899,6 +1928,7 @@ int cifs_mkdir(struct user_namespace *mnt_userns, struct inode *inode,
if (rc != -EOPNOTSUPP) if (rc != -EOPNOTSUPP)
goto mkdir_out; goto mkdir_out;
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
if (!server->ops->mkdir) { if (!server->ops->mkdir) {
rc = -ENOSYS; rc = -ENOSYS;
...@@ -2015,9 +2045,12 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry, ...@@ -2015,9 +2045,12 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
struct tcon_link *tlink; struct tcon_link *tlink;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
struct TCP_Server_Info *server; struct TCP_Server_Info *server;
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
struct cifs_fid fid; struct cifs_fid fid;
struct cifs_open_parms oparms; struct cifs_open_parms oparms;
int oplock, rc; int oplock;
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
int rc;
tlink = cifs_sb_tlink(cifs_sb); tlink = cifs_sb_tlink(cifs_sb);
if (IS_ERR(tlink)) if (IS_ERR(tlink))
...@@ -2043,6 +2076,7 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry, ...@@ -2043,6 +2076,7 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
if (server->vals->protocol_id != 0) if (server->vals->protocol_id != 0)
goto do_rename_exit; goto do_rename_exit;
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
/* open-file renames don't work across directories */ /* open-file renames don't work across directories */
if (to_dentry->d_parent != from_dentry->d_parent) if (to_dentry->d_parent != from_dentry->d_parent)
goto do_rename_exit; goto do_rename_exit;
...@@ -2064,6 +2098,7 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry, ...@@ -2064,6 +2098,7 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
cifs_sb->local_nls, cifs_remap(cifs_sb)); cifs_sb->local_nls, cifs_remap(cifs_sb));
CIFSSMBClose(xid, tcon, fid.netfid); CIFSSMBClose(xid, tcon, fid.netfid);
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
do_rename_exit: do_rename_exit:
if (rc == 0) if (rc == 0)
d_move(from_dentry, to_dentry); d_move(from_dentry, to_dentry);
...@@ -2081,11 +2116,13 @@ cifs_rename2(struct user_namespace *mnt_userns, struct inode *source_dir, ...@@ -2081,11 +2116,13 @@ cifs_rename2(struct user_namespace *mnt_userns, struct inode *source_dir,
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb;
struct tcon_link *tlink; struct tcon_link *tlink;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
FILE_UNIX_BASIC_INFO *info_buf_source = NULL;
FILE_UNIX_BASIC_INFO *info_buf_target;
unsigned int xid; unsigned int xid;
int rc, tmprc; int rc, tmprc;
int retry_count = 0; int retry_count = 0;
FILE_UNIX_BASIC_INFO *info_buf_source = NULL;
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
FILE_UNIX_BASIC_INFO *info_buf_target;
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
if (flags & ~RENAME_NOREPLACE) if (flags & ~RENAME_NOREPLACE)
return -EINVAL; return -EINVAL;
...@@ -2139,6 +2176,7 @@ cifs_rename2(struct user_namespace *mnt_userns, struct inode *source_dir, ...@@ -2139,6 +2176,7 @@ cifs_rename2(struct user_namespace *mnt_userns, struct inode *source_dir,
if (flags & RENAME_NOREPLACE) if (flags & RENAME_NOREPLACE)
goto cifs_rename_exit; goto cifs_rename_exit;
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
if (rc == -EEXIST && tcon->unix_ext) { if (rc == -EEXIST && tcon->unix_ext) {
/* /*
* Are src and dst hardlinks of same inode? We can only tell * Are src and dst hardlinks of same inode? We can only tell
...@@ -2178,6 +2216,8 @@ cifs_rename2(struct user_namespace *mnt_userns, struct inode *source_dir, ...@@ -2178,6 +2216,8 @@ cifs_rename2(struct user_namespace *mnt_userns, struct inode *source_dir,
*/ */
unlink_target: unlink_target:
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
/* Try unlinking the target dentry if it's not negative */ /* Try unlinking the target dentry if it's not negative */
if (d_really_is_positive(target_dentry) && (rc == -EACCES || rc == -EEXIST)) { if (d_really_is_positive(target_dentry) && (rc == -EACCES || rc == -EEXIST)) {
if (d_is_dir(target_dentry)) if (d_is_dir(target_dentry))
...@@ -2337,14 +2377,18 @@ int cifs_revalidate_file_attr(struct file *filp) ...@@ -2337,14 +2377,18 @@ int cifs_revalidate_file_attr(struct file *filp)
{ {
int rc = 0; int rc = 0;
struct dentry *dentry = file_dentry(filp); struct dentry *dentry = file_dentry(filp);
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data; struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data;
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
if (!cifs_dentry_needs_reval(dentry)) if (!cifs_dentry_needs_reval(dentry))
return rc; return rc;
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
if (tlink_tcon(cfile->tlink)->unix_ext) if (tlink_tcon(cfile->tlink)->unix_ext)
rc = cifs_get_file_info_unix(filp); rc = cifs_get_file_info_unix(filp);
else else
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
rc = cifs_get_file_info(filp); rc = cifs_get_file_info(filp);
return rc; return rc;
...@@ -2653,6 +2697,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs, ...@@ -2653,6 +2697,7 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs,
return rc; return rc;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
static int static int
cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
{ {
...@@ -2800,6 +2845,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) ...@@ -2800,6 +2845,7 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
free_xid(xid); free_xid(xid);
return rc; return rc;
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
static int static int
cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
...@@ -2995,16 +3041,20 @@ cifs_setattr(struct user_namespace *mnt_userns, struct dentry *direntry, ...@@ -2995,16 +3041,20 @@ cifs_setattr(struct user_namespace *mnt_userns, struct dentry *direntry,
struct iattr *attrs) struct iattr *attrs)
{ {
struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
struct cifs_tcon *pTcon = cifs_sb_master_tcon(cifs_sb);
int rc, retries = 0; int rc, retries = 0;
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
struct cifs_tcon *pTcon = cifs_sb_master_tcon(cifs_sb);
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
if (unlikely(cifs_forced_shutdown(cifs_sb))) if (unlikely(cifs_forced_shutdown(cifs_sb)))
return -EIO; return -EIO;
do { do {
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
if (pTcon->unix_ext) if (pTcon->unix_ext)
rc = cifs_setattr_unix(direntry, attrs); rc = cifs_setattr_unix(direntry, attrs);
else else
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
rc = cifs_setattr_nounix(direntry, attrs); rc = cifs_setattr_nounix(direntry, attrs);
retries++; retries++;
} while (is_retryable_error(rc) && retries < 2); } while (is_retryable_error(rc) && retries < 2);
......
...@@ -333,6 +333,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) ...@@ -333,6 +333,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
tcon = tlink_tcon(pSMBFile->tlink); tcon = tlink_tcon(pSMBFile->tlink);
caps = le64_to_cpu(tcon->fsUnixInfo.Capability); caps = le64_to_cpu(tcon->fsUnixInfo.Capability);
#ifdef CONFIG_CIFS_POSIX #ifdef CONFIG_CIFS_POSIX
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
if (CIFS_UNIX_EXTATTR_CAP & caps) { if (CIFS_UNIX_EXTATTR_CAP & caps) {
__u64 ExtAttrMask = 0; __u64 ExtAttrMask = 0;
rc = CIFSGetExtAttr(xid, tcon, rc = CIFSGetExtAttr(xid, tcon,
...@@ -345,6 +346,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) ...@@ -345,6 +346,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
if (rc != EOPNOTSUPP) if (rc != EOPNOTSUPP)
break; break;
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
#endif /* CONFIG_CIFS_POSIX */ #endif /* CONFIG_CIFS_POSIX */
rc = 0; rc = 0;
if (CIFS_I(inode)->cifsAttrs & ATTR_COMPRESSED) { if (CIFS_I(inode)->cifsAttrs & ATTR_COMPRESSED) {
......
...@@ -286,6 +286,7 @@ check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, ...@@ -286,6 +286,7 @@ check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
return rc; return rc;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
/* /*
* SMB 1.0 Protocol specific functions * SMB 1.0 Protocol specific functions
*/ */
...@@ -368,6 +369,7 @@ cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, ...@@ -368,6 +369,7 @@ cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
CIFSSMBClose(xid, tcon, fid.netfid); CIFSSMBClose(xid, tcon, fid.netfid);
return rc; return rc;
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
/* /*
* SMB 2.1/SMB3 Protocol specific functions * SMB 2.1/SMB3 Protocol specific functions
...@@ -532,11 +534,15 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode, ...@@ -532,11 +534,15 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
goto cifs_hl_exit; goto cifs_hl_exit;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
if (tcon->unix_ext) if (tcon->unix_ext)
rc = CIFSUnixCreateHardLink(xid, tcon, from_name, to_name, rc = CIFSUnixCreateHardLink(xid, tcon, from_name, to_name,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_remap(cifs_sb)); cifs_remap(cifs_sb));
else { else {
#else
{
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
server = tcon->ses->server; server = tcon->ses->server;
if (!server->ops->create_hardlink) { if (!server->ops->create_hardlink) {
rc = -ENOSYS; rc = -ENOSYS;
...@@ -704,10 +710,12 @@ cifs_symlink(struct user_namespace *mnt_userns, struct inode *inode, ...@@ -704,10 +710,12 @@ cifs_symlink(struct user_namespace *mnt_userns, struct inode *inode,
/* BB what if DFS and this volume is on different share? BB */ /* BB what if DFS and this volume is on different share? BB */
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
rc = create_mf_symlink(xid, pTcon, cifs_sb, full_path, symname); rc = create_mf_symlink(xid, pTcon, cifs_sb, full_path, symname);
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
else if (pTcon->unix_ext) else if (pTcon->unix_ext)
rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname, rc = CIFSUnixCreateSymLink(xid, pTcon, full_path, symname,
cifs_sb->local_nls, cifs_sb->local_nls,
cifs_remap(cifs_sb)); cifs_remap(cifs_sb));
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
/* else /* else
rc = CIFSCreateReparseSymLink(xid, pTcon, fromName, toName, rc = CIFSCreateReparseSymLink(xid, pTcon, fromName, toName,
cifs_sb_target->local_nls); */ cifs_sb_target->local_nls); */
......
...@@ -499,6 +499,7 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses, ...@@ -499,6 +499,7 @@ cifs_ses_add_channel(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
return rc; return rc;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
static __u32 cifs_ssetup_hdr(struct cifs_ses *ses, static __u32 cifs_ssetup_hdr(struct cifs_ses *ses,
struct TCP_Server_Info *server, struct TCP_Server_Info *server,
SESSION_SETUP_ANDX *pSMB) SESSION_SETUP_ANDX *pSMB)
...@@ -591,7 +592,6 @@ static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses, ...@@ -591,7 +592,6 @@ static void unicode_domain_string(char **pbcc_area, struct cifs_ses *ses,
*pbcc_area = bcc_ptr; *pbcc_area = bcc_ptr;
} }
static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses, static void unicode_ssetup_strings(char **pbcc_area, struct cifs_ses *ses,
const struct nls_table *nls_cp) const struct nls_table *nls_cp)
{ {
...@@ -753,6 +753,7 @@ static void decode_ascii_ssetup(char **pbcc_area, __u16 bleft, ...@@ -753,6 +753,7 @@ static void decode_ascii_ssetup(char **pbcc_area, __u16 bleft,
for it later, but it is not very important */ for it later, but it is not very important */
cifs_dbg(FYI, "ascii: bytes left %d\n", bleft); 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, int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
struct cifs_ses *ses) struct cifs_ses *ses)
...@@ -1170,6 +1171,7 @@ struct sess_data { ...@@ -1170,6 +1171,7 @@ struct sess_data {
struct kvec iov[3]; struct kvec iov[3];
}; };
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
static int static int
sess_alloc_buffer(struct sess_data *sess_data, int wct) sess_alloc_buffer(struct sess_data *sess_data, int wct)
{ {
...@@ -1846,3 +1848,4 @@ int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, ...@@ -1846,3 +1848,4 @@ int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
kfree(sess_data); kfree(sess_data);
return rc; return rc;
} }
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <asm/processor.h> #include <asm/processor.h>
#include <linux/mempool.h> #include <linux/mempool.h>
#include <linux/sched/signal.h> #include <linux/sched/signal.h>
#include <linux/task_io_accounting_ops.h>
#include "cifspdu.h" #include "cifspdu.h"
#include "cifsglob.h" #include "cifsglob.h"
#include "cifsproto.h" #include "cifsproto.h"
...@@ -1638,3 +1639,181 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -1638,3 +1639,181 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon,
return -ERESTARTSYS; return -ERESTARTSYS;
return rc; return rc;
} }
/*
* Discard any remaining data in the current SMB. To do this, we borrow the
* current bigbuf.
*/
int
cifs_discard_remaining_data(struct TCP_Server_Info *server)
{
unsigned int rfclen = server->pdu_size;
int remaining = rfclen + server->vals->header_preamble_size -
server->total_read;
while (remaining > 0) {
int length;
length = cifs_discard_from_socket(server,
min_t(size_t, remaining,
CIFSMaxBufSize + MAX_HEADER_SIZE(server)));
if (length < 0)
return length;
server->total_read += length;
remaining -= length;
}
return 0;
}
static int
__cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid,
bool malformed)
{
int length;
length = cifs_discard_remaining_data(server);
dequeue_mid(mid, malformed);
mid->resp_buf = server->smallbuf;
server->smallbuf = NULL;
return length;
}
static int
cifs_readv_discard(struct TCP_Server_Info *server, struct mid_q_entry *mid)
{
struct cifs_readdata *rdata = mid->callback_data;
return __cifs_readv_discard(server, mid, rdata->result);
}
int
cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid)
{
int length, len;
unsigned int data_offset, data_len;
struct cifs_readdata *rdata = mid->callback_data;
char *buf = server->smallbuf;
unsigned int buflen = server->pdu_size +
server->vals->header_preamble_size;
bool use_rdma_mr = false;
cifs_dbg(FYI, "%s: mid=%llu offset=%llu bytes=%u\n",
__func__, mid->mid, rdata->offset, rdata->bytes);
/*
* read the rest of READ_RSP header (sans Data array), or whatever we
* can if there's not enough data. At this point, we've read down to
* the Mid.
*/
len = min_t(unsigned int, buflen, server->vals->read_rsp_size) -
HEADER_SIZE(server) + 1;
length = cifs_read_from_socket(server,
buf + HEADER_SIZE(server) - 1, len);
if (length < 0)
return length;
server->total_read += length;
if (server->ops->is_session_expired &&
server->ops->is_session_expired(buf)) {
cifs_reconnect(server, true);
return -1;
}
if (server->ops->is_status_pending &&
server->ops->is_status_pending(buf, server)) {
cifs_discard_remaining_data(server);
return -1;
}
/* set up first two iov for signature check and to get credits */
rdata->iov[0].iov_base = buf;
rdata->iov[0].iov_len = server->vals->header_preamble_size;
rdata->iov[1].iov_base = buf + server->vals->header_preamble_size;
rdata->iov[1].iov_len =
server->total_read - server->vals->header_preamble_size;
cifs_dbg(FYI, "0: iov_base=%p iov_len=%zu\n",
rdata->iov[0].iov_base, rdata->iov[0].iov_len);
cifs_dbg(FYI, "1: iov_base=%p iov_len=%zu\n",
rdata->iov[1].iov_base, rdata->iov[1].iov_len);
/* Was the SMB read successful? */
rdata->result = server->ops->map_error(buf, false);
if (rdata->result != 0) {
cifs_dbg(FYI, "%s: server returned error %d\n",
__func__, rdata->result);
/* normal error on read response */
return __cifs_readv_discard(server, mid, false);
}
/* Is there enough to get to the rest of the READ_RSP header? */
if (server->total_read < server->vals->read_rsp_size) {
cifs_dbg(FYI, "%s: server returned short header. got=%u expected=%zu\n",
__func__, server->total_read,
server->vals->read_rsp_size);
rdata->result = -EIO;
return cifs_readv_discard(server, mid);
}
data_offset = server->ops->read_data_offset(buf) +
server->vals->header_preamble_size;
if (data_offset < server->total_read) {
/*
* win2k8 sometimes sends an offset of 0 when the read
* is beyond the EOF. Treat it as if the data starts just after
* the header.
*/
cifs_dbg(FYI, "%s: data offset (%u) inside read response header\n",
__func__, data_offset);
data_offset = server->total_read;
} else if (data_offset > MAX_CIFS_SMALL_BUFFER_SIZE) {
/* data_offset is beyond the end of smallbuf */
cifs_dbg(FYI, "%s: data offset (%u) beyond end of smallbuf\n",
__func__, data_offset);
rdata->result = -EIO;
return cifs_readv_discard(server, mid);
}
cifs_dbg(FYI, "%s: total_read=%u data_offset=%u\n",
__func__, server->total_read, data_offset);
len = data_offset - server->total_read;
if (len > 0) {
/* read any junk before data into the rest of smallbuf */
length = cifs_read_from_socket(server,
buf + server->total_read, len);
if (length < 0)
return length;
server->total_read += length;
}
/* how much data is in the response? */
#ifdef CONFIG_CIFS_SMB_DIRECT
use_rdma_mr = rdata->mr;
#endif
data_len = server->ops->read_data_length(buf, use_rdma_mr);
if (!use_rdma_mr && (data_offset + data_len > buflen)) {
/* data_len is corrupt -- discard frame */
rdata->result = -EIO;
return cifs_readv_discard(server, mid);
}
length = rdata->read_into_pages(server, rdata, data_len);
if (length < 0)
return length;
server->total_read += length;
cifs_dbg(FYI, "total_read=%u buflen=%u remaining=%u\n",
server->total_read, buflen, data_len);
/* discard anything left over */
if (server->total_read < buflen)
return cifs_readv_discard(server, mid);
dequeue_mid(mid, false);
mid->resp_buf = server->smallbuf;
server->smallbuf = NULL;
return length;
}
...@@ -201,6 +201,7 @@ static int cifs_xattr_set(const struct xattr_handler *handler, ...@@ -201,6 +201,7 @@ static int cifs_xattr_set(const struct xattr_handler *handler,
break; break;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
case XATTR_ACL_ACCESS: case XATTR_ACL_ACCESS:
#ifdef CONFIG_CIFS_POSIX #ifdef CONFIG_CIFS_POSIX
if (!value) if (!value)
...@@ -224,6 +225,7 @@ static int cifs_xattr_set(const struct xattr_handler *handler, ...@@ -224,6 +225,7 @@ static int cifs_xattr_set(const struct xattr_handler *handler,
cifs_remap(cifs_sb)); cifs_remap(cifs_sb));
#endif /* CONFIG_CIFS_POSIX */ #endif /* CONFIG_CIFS_POSIX */
break; break;
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
} }
out: out:
...@@ -364,7 +366,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler, ...@@ -364,7 +366,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
} }
break; break;
} }
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
case XATTR_ACL_ACCESS: case XATTR_ACL_ACCESS:
#ifdef CONFIG_CIFS_POSIX #ifdef CONFIG_CIFS_POSIX
if (sb->s_flags & SB_POSIXACL) if (sb->s_flags & SB_POSIXACL)
...@@ -384,6 +386,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler, ...@@ -384,6 +386,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
cifs_remap(cifs_sb)); cifs_remap(cifs_sb));
#endif /* CONFIG_CIFS_POSIX */ #endif /* CONFIG_CIFS_POSIX */
break; break;
#endif /* ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
} }
/* We could add an additional check for streams ie /* We could add an additional check for streams ie
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment