Commit 3bb37da5 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag '4.19-smb3' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs updates from Steve French:
 "smb3/cifs fixes (including 8 for stable).

  Other improvements include:

   - improved tracing, improved stats

   - snapshots (previous version mounts work now over SMB3)

   - performance (compounding enabled for statfs, ~40% faster).

   - security (make it possible to build cifs.ko with insecure vers=1.0
     disabled in Kconfig)"

* tag '4.19-smb3' of git://git.samba.org/sfrench/cifs-2.6: (43 commits)
  smb3: create smb3 equivalent alias for cifs pseudo-xattrs
  smb3: allow previous versions to be mounted with snapshot= mount parm
  cifs: don't show domain= in mount output when domain is empty
  cifs: add missing support for ACLs in SMB 3.11
  smb3: enumerating snapshots was leaving part of the data off end
  cifs: update smb2_queryfs() to use compounding
  cifs: update receive_encrypted_standard to handle compounded responses
  cifs: create SMB2_open_init()/SMB2_open_free() helpers.
  cifs: add SMB2_query_info_[init|free]()
  cifs: add SMB2_close_init()/SMB2_close_free()
  smb3: display stats counters for number of slow commands
  CIFS: fix uninitialized ptr deref in smb2 signing
  smb3: Do not send SMB3 SET_INFO if nothing changed
  smb3: fix minor debug output for CONFIG_CIFS_STATS
  smb3: add tracepoint for slow responses
  cifs: add compound_send_recv()
  cifs: make smb_send_rqst take an array of requests
  cifs: update init_sg, crypt_message to take an array of rqst
  smb3: update readme to correct information about /proc/fs/cifs/Stats
  smb3: fix reset of bytes read and written stats
  ...
parents 161fa27f c4f7173a
This diff is collapsed.
...@@ -603,8 +603,7 @@ DebugData Displays information about active CIFS sessions and ...@@ -603,8 +603,7 @@ DebugData Displays information about active CIFS sessions and
shares, features enabled as well as the cifs.ko shares, features enabled as well as the cifs.ko
version. version.
Stats Lists summary resource usage information as well as per Stats Lists summary resource usage information as well as per
share statistics, if CONFIG_CIFS_STATS in enabled share statistics.
in the kernel configuration.
Configuration pseudo-files: Configuration pseudo-files:
SecurityFlags Flags which control security negotiation and SecurityFlags Flags which control security negotiation and
...@@ -687,23 +686,22 @@ cifsFYI functions as a bit mask. Setting it to 1 enables additional kernel ...@@ -687,23 +686,22 @@ cifsFYI functions as a bit mask. Setting it to 1 enables additional kernel
logging of various informational messages. 2 enables logging of non-zero logging of various informational messages. 2 enables logging of non-zero
SMB return codes while 4 enables logging of requests that take longer SMB return codes while 4 enables logging of requests that take longer
than one second to complete (except for byte range lock requests). than one second to complete (except for byte range lock requests).
Setting it to 4 requires defining CONFIG_CIFS_STATS2 manually in the Setting it to 4 requires CONFIG_CIFS_STATS2 to be set in kernel configuration
source code (typically by setting it in the beginning of cifsglob.h), (.config). Setting it to seven enables all three. Finally, tracing
and setting it to seven enables all three. Finally, tracing
the start of smb requests and responses can be enabled via: the start of smb requests and responses can be enabled via:
echo 1 > /proc/fs/cifs/traceSMB echo 1 > /proc/fs/cifs/traceSMB
Per share (per client mount) statistics are available in /proc/fs/cifs/Stats Per share (per client mount) statistics are available in /proc/fs/cifs/Stats.
if the kernel was configured with cifs statistics enabled. The statistics Additional information is available if CONFIG_CIFS_STATS2 is enabled in the
represent the number of successful (ie non-zero return code from the server) kernel configuration (.config). The statistics returned include counters which
SMB responses to some of the more common commands (open, delete, mkdir etc.). represent the number of attempted and failed (ie non-zero return code from the
server) SMB3 (or cifs) requests grouped by request type (read, write, close etc.).
Also recorded is the total bytes read and bytes written to the server for Also recorded is the total bytes read and bytes written to the server for
that share. Note that due to client caching effects this can be less than the that share. Note that due to client caching effects this can be less than the
number of bytes read and written by the application running on the client. number of bytes read and written by the application running on the client.
The statistics for the number of total SMBs and oplock breaks are different in Statistics can be reset to zero by "echo 0 > /proc/fs/cifs/Stats" which may be
that they represent all for that share, not just those for which the server useful if comparing performance of two different scenarios.
returned success.
Also note that "cat /proc/fs/cifs/DebugData" will display information about Also note that "cat /proc/fs/cifs/DebugData" will display information about
the active sessions and the shares that are mounted. the active sessions and the shares that are mounted.
......
...@@ -16,24 +16,28 @@ config CIFS ...@@ -16,24 +16,28 @@ config CIFS
select CRYPTO_DES select CRYPTO_DES
help help
This is the client VFS module for the SMB3 family of NAS protocols, This is the client VFS module for the SMB3 family of NAS protocols,
as well as for earlier dialects such as SMB2.1, SMB2 and the (including support for the most recent, most secure dialect SMB3.1.1)
as well as for earlier dialects such as SMB2.1, SMB2 and the older
Common Internet File System (CIFS) protocol. CIFS was the successor Common Internet File System (CIFS) protocol. CIFS was the successor
to the original dialect, the Server Message Block (SMB) protocol, the to the original dialect, the Server Message Block (SMB) protocol, the
native file sharing mechanism for most early PC operating systems. native file sharing mechanism for most early PC operating systems.
The SMB3 protocol is supported by most modern operating systems and The SMB3 protocol is supported by most modern operating systems
NAS appliances (e.g. Samba, Windows 8, Windows 2012, MacOS). and NAS appliances (e.g. Samba, Windows 10, Windows Server 2016,
MacOS) and even in the cloud (e.g. Microsoft Azure).
The older CIFS protocol was included in Windows NT4, 2000 and XP (and The older CIFS protocol was included in Windows NT4, 2000 and XP (and
later) as well by Samba (which provides excellent CIFS and SMB3 later) as well by Samba (which provides excellent CIFS and SMB3
server support for Linux and many other operating systems). Limited server support for Linux and many other operating systems). Use of
support for OS/2 and Windows ME and similar very old servers is dialects older than SMB2.1 is often discouraged on public networks.
provided as well. This module also provides limited support for OS/2 and Windows ME
and similar very old servers.
The cifs module provides an advanced network file system client This module provides an advanced network file system client
for mounting to SMB3 (and CIFS) compliant servers. It includes for mounting to SMB3 (and CIFS) compliant servers. It includes
support for DFS (hierarchical name space), secure per-user support for DFS (hierarchical name space), secure per-user
session establishment via Kerberos or NTLM or NTLMv2, session establishment via Kerberos or NTLM or NTLMv2, RDMA
safe distributed caching (oplock), optional packet (smbdirect), advanced security features, per-share encryption,
directory leases, safe distributed caching (oplock), optional packet
signing, Unicode and other internationalization improvements. signing, Unicode and other internationalization improvements.
In general, the default dialects, SMB3 and later, enable better In general, the default dialects, SMB3 and later, enable better
...@@ -43,18 +47,11 @@ config CIFS ...@@ -43,18 +47,11 @@ config CIFS
than SMB3 mounts. SMB2/SMB3 mount options are also than SMB3 mounts. SMB2/SMB3 mount options are also
slightly simpler (compared to CIFS) due to protocol improvements. slightly simpler (compared to CIFS) due to protocol improvements.
If you need to mount to Samba, Macs or Windows from this machine, say Y. If you need to mount to Samba, Azure, Macs or Windows from this machine, say Y.
config CIFS_STATS
bool "CIFS statistics"
depends on CIFS
help
Enabling this option will cause statistics for each server share
mounted by the cifs client to be displayed in /proc/fs/cifs/Stats
config CIFS_STATS2 config CIFS_STATS2
bool "Extended statistics" bool "Extended statistics"
depends on CIFS_STATS depends on CIFS
help help
Enabling this option will allow more detailed statistics on SMB Enabling this option will allow more detailed statistics on SMB
request timing to be displayed in /proc/fs/cifs/DebugData and also request timing to be displayed in /proc/fs/cifs/DebugData and also
...@@ -66,9 +63,24 @@ config CIFS_STATS2 ...@@ -66,9 +63,24 @@ config CIFS_STATS2
Unless you are a developer or are doing network performance analysis Unless you are a developer or are doing network performance analysis
or tuning, say N. or tuning, say N.
config CIFS_ALLOW_INSECURE_LEGACY
bool "Support legacy servers which use less secure dialects"
depends on CIFS
default y
help
Modern dialects, SMB2.1 and later (including SMB3 and 3.1.1), have
additional security features, including protection against
man-in-the-middle attacks and stronger crypto hashes, so the use
of legacy dialects (SMB1/CIFS and SMB2.0) is discouraged.
Disabling this option prevents users from using vers=1.0 or vers=2.0
on mounts with cifs.ko
If unsure, say Y.
config CIFS_WEAK_PW_HASH config CIFS_WEAK_PW_HASH
bool "Support legacy servers which use weaker LANMAN security" bool "Support legacy servers which use weaker LANMAN security"
depends on CIFS depends on CIFS && CIFS_ALLOW_INSECURE_LEGACY
help help
Modern CIFS servers including Samba and most Windows versions Modern CIFS servers including Samba and most Windows versions
(since 1997) support stronger NTLM (and even NTLMv2 and Kerberos) (since 1997) support stronger NTLM (and even NTLMv2 and Kerberos)
...@@ -186,15 +198,6 @@ config CIFS_NFSD_EXPORT ...@@ -186,15 +198,6 @@ config CIFS_NFSD_EXPORT
help help
Allows NFS server to export a CIFS mounted share (nfsd over cifs) Allows NFS server to export a CIFS mounted share (nfsd over cifs)
config CIFS_SMB311
bool "SMB3.1.1 network file system support"
depends on CIFS
select CRYPTO_SHA512
help
This enables support for the newest, and most secure dialect, SMB3.11.
If unsure, say Y
config CIFS_SMB_DIRECT config CIFS_SMB_DIRECT
bool "SMB Direct support (Experimental)" bool "SMB Direct support (Experimental)"
depends on CIFS=m && INFINIBAND && INFINIBAND_ADDR_TRANS || CIFS=y && INFINIBAND=y && INFINIBAND_ADDR_TRANS=y depends on CIFS=m && INFINIBAND && INFINIBAND_ADDR_TRANS || CIFS=y && INFINIBAND=y && INFINIBAND_ADDR_TRANS=y
......
...@@ -128,8 +128,10 @@ fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data, ...@@ -128,8 +128,10 @@ fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
memset(&auxdata, 0, sizeof(auxdata)); memset(&auxdata, 0, sizeof(auxdata));
auxdata.eof = cifsi->server_eof; auxdata.eof = cifsi->server_eof;
auxdata.last_write_time = timespec64_to_timespec(cifsi->vfs_inode.i_mtime); auxdata.last_write_time_sec = cifsi->vfs_inode.i_mtime.tv_sec;
auxdata.last_change_time = timespec64_to_timespec(cifsi->vfs_inode.i_ctime); auxdata.last_change_time_sec = cifsi->vfs_inode.i_ctime.tv_sec;
auxdata.last_write_time_nsec = cifsi->vfs_inode.i_mtime.tv_nsec;
auxdata.last_change_time_nsec = cifsi->vfs_inode.i_ctime.tv_nsec;
if (memcmp(data, &auxdata, datalen) != 0) if (memcmp(data, &auxdata, datalen) != 0)
return FSCACHE_CHECKAUX_OBSOLETE; return FSCACHE_CHECKAUX_OBSOLETE;
......
...@@ -160,25 +160,41 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) ...@@ -160,25 +160,41 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
seq_printf(m, "CIFS Version %s\n", CIFS_VERSION); seq_printf(m, "CIFS Version %s\n", CIFS_VERSION);
seq_printf(m, "Features:"); seq_printf(m, "Features:");
#ifdef CONFIG_CIFS_DFS_UPCALL #ifdef CONFIG_CIFS_DFS_UPCALL
seq_printf(m, " dfs"); seq_printf(m, " DFS");
#endif #endif
#ifdef CONFIG_CIFS_FSCACHE #ifdef CONFIG_CIFS_FSCACHE
seq_printf(m, " fscache"); seq_printf(m, ",FSCACHE");
#endif
#ifdef CONFIG_CIFS_SMB_DIRECT
seq_printf(m, ",SMB_DIRECT");
#endif
#ifdef CONFIG_CIFS_STATS2
seq_printf(m, ",STATS2");
#else
seq_printf(m, ",STATS");
#endif
#ifdef CONFIG_CIFS_DEBUG2
seq_printf(m, ",DEBUG2");
#elif defined(CONFIG_CIFS_DEBUG)
seq_printf(m, ",DEBUG");
#endif
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
seq_printf(m, ",ALLOW_INSECURE_LEGACY");
#endif #endif
#ifdef CONFIG_CIFS_WEAK_PW_HASH #ifdef CONFIG_CIFS_WEAK_PW_HASH
seq_printf(m, " lanman"); seq_printf(m, ",WEAK_PW_HASH");
#endif #endif
#ifdef CONFIG_CIFS_POSIX #ifdef CONFIG_CIFS_POSIX
seq_printf(m, " posix"); seq_printf(m, ",CIFS_POSIX");
#endif #endif
#ifdef CONFIG_CIFS_UPCALL #ifdef CONFIG_CIFS_UPCALL
seq_printf(m, " spnego"); seq_printf(m, ",UPCALL(SPNEGO)");
#endif #endif
#ifdef CONFIG_CIFS_XATTR #ifdef CONFIG_CIFS_XATTR
seq_printf(m, " xattr"); seq_printf(m, ",XATTR");
#endif #endif
#ifdef CONFIG_CIFS_ACL #ifdef CONFIG_CIFS_ACL
seq_printf(m, " acl"); seq_printf(m, ",ACL");
#endif #endif
seq_putc(m, '\n'); seq_putc(m, '\n');
seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid); seq_printf(m, "Active VFS Requests: %d\n", GlobalTotalActiveXid);
...@@ -259,10 +275,9 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) ...@@ -259,10 +275,9 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
server->credits, server->dialect); server->credits, server->dialect);
if (server->sign) if (server->sign)
seq_printf(m, " signed"); seq_printf(m, " signed");
#ifdef CONFIG_CIFS_SMB311
if (server->posix_ext_supported) if (server->posix_ext_supported)
seq_printf(m, " posix"); seq_printf(m, " posix");
#endif /* 3.1.1 */
i++; i++;
list_for_each(tmp2, &server->smb_ses_list) { list_for_each(tmp2, &server->smb_ses_list) {
ses = list_entry(tmp2, struct cifs_ses, ses = list_entry(tmp2, struct cifs_ses,
...@@ -350,7 +365,6 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) ...@@ -350,7 +365,6 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v)
return 0; return 0;
} }
#ifdef CONFIG_CIFS_STATS
static ssize_t cifs_stats_proc_write(struct file *file, static ssize_t cifs_stats_proc_write(struct file *file,
const char __user *buffer, size_t count, loff_t *ppos) const char __user *buffer, size_t count, loff_t *ppos)
{ {
...@@ -364,13 +378,23 @@ static ssize_t cifs_stats_proc_write(struct file *file, ...@@ -364,13 +378,23 @@ static ssize_t cifs_stats_proc_write(struct file *file,
rc = kstrtobool_from_user(buffer, count, &bv); rc = kstrtobool_from_user(buffer, count, &bv);
if (rc == 0) { if (rc == 0) {
#ifdef CONFIG_CIFS_STATS2 #ifdef CONFIG_CIFS_STATS2
int i;
atomic_set(&totBufAllocCount, 0); atomic_set(&totBufAllocCount, 0);
atomic_set(&totSmBufAllocCount, 0); atomic_set(&totSmBufAllocCount, 0);
#endif /* CONFIG_CIFS_STATS2 */ #endif /* CONFIG_CIFS_STATS2 */
spin_lock(&GlobalMid_Lock);
GlobalMaxActiveXid = 0;
GlobalCurrentXid = 0;
spin_unlock(&GlobalMid_Lock);
spin_lock(&cifs_tcp_ses_lock); spin_lock(&cifs_tcp_ses_lock);
list_for_each(tmp1, &cifs_tcp_ses_list) { list_for_each(tmp1, &cifs_tcp_ses_list) {
server = list_entry(tmp1, struct TCP_Server_Info, server = list_entry(tmp1, struct TCP_Server_Info,
tcp_ses_list); tcp_ses_list);
#ifdef CONFIG_CIFS_STATS2
for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++)
atomic_set(&server->smb2slowcmd[i], 0);
#endif /* CONFIG_CIFS_STATS2 */
list_for_each(tmp2, &server->smb_ses_list) { list_for_each(tmp2, &server->smb_ses_list) {
ses = list_entry(tmp2, struct cifs_ses, ses = list_entry(tmp2, struct cifs_ses,
smb_ses_list); smb_ses_list);
...@@ -379,6 +403,10 @@ static ssize_t cifs_stats_proc_write(struct file *file, ...@@ -379,6 +403,10 @@ static ssize_t cifs_stats_proc_write(struct file *file,
struct cifs_tcon, struct cifs_tcon,
tcon_list); tcon_list);
atomic_set(&tcon->num_smbs_sent, 0); atomic_set(&tcon->num_smbs_sent, 0);
spin_lock(&tcon->stat_lock);
tcon->bytes_read = 0;
tcon->bytes_written = 0;
spin_unlock(&tcon->stat_lock);
if (server->ops->clear_stats) if (server->ops->clear_stats)
server->ops->clear_stats(tcon); server->ops->clear_stats(tcon);
} }
...@@ -395,13 +423,15 @@ static ssize_t cifs_stats_proc_write(struct file *file, ...@@ -395,13 +423,15 @@ static ssize_t cifs_stats_proc_write(struct file *file,
static int cifs_stats_proc_show(struct seq_file *m, void *v) static int cifs_stats_proc_show(struct seq_file *m, void *v)
{ {
int i; int i;
#ifdef CONFIG_CIFS_STATS2
int j;
#endif /* STATS2 */
struct list_head *tmp1, *tmp2, *tmp3; struct list_head *tmp1, *tmp2, *tmp3;
struct TCP_Server_Info *server; struct TCP_Server_Info *server;
struct cifs_ses *ses; struct cifs_ses *ses;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
seq_printf(m, seq_printf(m, "Resources in use\nCIFS Session: %d\n",
"Resources in use\nCIFS Session: %d\n",
sesInfoAllocCount.counter); sesInfoAllocCount.counter);
seq_printf(m, "Share (unique mount targets): %d\n", seq_printf(m, "Share (unique mount targets): %d\n",
tconInfoAllocCount.counter); tconInfoAllocCount.counter);
...@@ -430,6 +460,13 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v) ...@@ -430,6 +460,13 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
list_for_each(tmp1, &cifs_tcp_ses_list) { list_for_each(tmp1, &cifs_tcp_ses_list) {
server = list_entry(tmp1, struct TCP_Server_Info, server = list_entry(tmp1, struct TCP_Server_Info,
tcp_ses_list); tcp_ses_list);
#ifdef CONFIG_CIFS_STATS2
for (j = 0; j < NUMBER_OF_SMB2_COMMANDS; j++)
if (atomic_read(&server->smb2slowcmd[j]))
seq_printf(m, "%d slow responses from %s for command %d\n",
atomic_read(&server->smb2slowcmd[j]),
server->hostname, j);
#endif /* STATS2 */
list_for_each(tmp2, &server->smb_ses_list) { list_for_each(tmp2, &server->smb_ses_list) {
ses = list_entry(tmp2, struct cifs_ses, ses = list_entry(tmp2, struct cifs_ses,
smb_ses_list); smb_ses_list);
...@@ -466,7 +503,6 @@ static const struct file_operations cifs_stats_proc_fops = { ...@@ -466,7 +503,6 @@ static const struct file_operations cifs_stats_proc_fops = {
.release = single_release, .release = single_release,
.write = cifs_stats_proc_write, .write = cifs_stats_proc_write,
}; };
#endif /* STATS */
#ifdef CONFIG_CIFS_SMB_DIRECT #ifdef CONFIG_CIFS_SMB_DIRECT
#define PROC_FILE_DEFINE(name) \ #define PROC_FILE_DEFINE(name) \
...@@ -524,9 +560,7 @@ cifs_proc_init(void) ...@@ -524,9 +560,7 @@ cifs_proc_init(void)
proc_create_single("DebugData", 0, proc_fs_cifs, proc_create_single("DebugData", 0, proc_fs_cifs,
cifs_debug_data_proc_show); cifs_debug_data_proc_show);
#ifdef CONFIG_CIFS_STATS
proc_create("Stats", 0644, proc_fs_cifs, &cifs_stats_proc_fops); proc_create("Stats", 0644, proc_fs_cifs, &cifs_stats_proc_fops);
#endif /* STATS */
proc_create("cifsFYI", 0644, proc_fs_cifs, &cifsFYI_proc_fops); proc_create("cifsFYI", 0644, proc_fs_cifs, &cifsFYI_proc_fops);
proc_create("traceSMB", 0644, proc_fs_cifs, &traceSMB_proc_fops); proc_create("traceSMB", 0644, proc_fs_cifs, &traceSMB_proc_fops);
proc_create("LinuxExtensionsEnabled", 0644, proc_fs_cifs, proc_create("LinuxExtensionsEnabled", 0644, proc_fs_cifs,
...@@ -564,9 +598,7 @@ cifs_proc_clean(void) ...@@ -564,9 +598,7 @@ cifs_proc_clean(void)
remove_proc_entry("DebugData", proc_fs_cifs); remove_proc_entry("DebugData", proc_fs_cifs);
remove_proc_entry("cifsFYI", proc_fs_cifs); remove_proc_entry("cifsFYI", proc_fs_cifs);
remove_proc_entry("traceSMB", proc_fs_cifs); remove_proc_entry("traceSMB", proc_fs_cifs);
#ifdef CONFIG_CIFS_STATS
remove_proc_entry("Stats", proc_fs_cifs); remove_proc_entry("Stats", proc_fs_cifs);
#endif
remove_proc_entry("SecurityFlags", proc_fs_cifs); remove_proc_entry("SecurityFlags", proc_fs_cifs);
remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs); remove_proc_entry("LinuxExtensionsEnabled", proc_fs_cifs);
remove_proc_entry("LookupCacheEnabled", proc_fs_cifs); remove_proc_entry("LookupCacheEnabled", proc_fs_cifs);
......
...@@ -83,7 +83,13 @@ int __cifs_calc_signature(struct smb_rqst *rqst, ...@@ -83,7 +83,13 @@ int __cifs_calc_signature(struct smb_rqst *rqst,
kaddr = (char *) kmap(rqst->rq_pages[i]) + offset; kaddr = (char *) kmap(rqst->rq_pages[i]) + offset;
crypto_shash_update(shash, kaddr, len); rc = crypto_shash_update(shash, kaddr, len);
if (rc) {
cifs_dbg(VFS, "%s: Could not update with payload\n",
__func__);
kunmap(rqst->rq_pages[i]);
return rc;
}
kunmap(rqst->rq_pages[i]); kunmap(rqst->rq_pages[i]);
} }
...@@ -452,7 +458,7 @@ find_timestamp(struct cifs_ses *ses) ...@@ -452,7 +458,7 @@ find_timestamp(struct cifs_ses *ses)
unsigned char *blobptr; unsigned char *blobptr;
unsigned char *blobend; unsigned char *blobend;
struct ntlmssp2_name *attrptr; struct ntlmssp2_name *attrptr;
struct timespec ts; struct timespec64 ts;
if (!ses->auth_key.len || !ses->auth_key.response) if (!ses->auth_key.len || !ses->auth_key.response)
return 0; return 0;
...@@ -477,7 +483,7 @@ find_timestamp(struct cifs_ses *ses) ...@@ -477,7 +483,7 @@ find_timestamp(struct cifs_ses *ses)
blobptr += attrsize; /* advance attr value */ blobptr += attrsize; /* advance attr value */
} }
ktime_get_real_ts(&ts); ktime_get_real_ts64(&ts);
return cpu_to_le64(cifs_UnixTimeToNT(ts)); return cpu_to_le64(cifs_UnixTimeToNT(ts));
} }
......
...@@ -139,6 +139,9 @@ cifs_read_super(struct super_block *sb) ...@@ -139,6 +139,9 @@ cifs_read_super(struct super_block *sb)
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL)
sb->s_flags |= SB_POSIXACL; sb->s_flags |= SB_POSIXACL;
if (tcon->snapshot_time)
sb->s_flags |= SB_RDONLY;
if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files) if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files)
sb->s_maxbytes = MAX_LFS_FILESIZE; sb->s_maxbytes = MAX_LFS_FILESIZE;
else else
...@@ -209,14 +212,16 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -209,14 +212,16 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
xid = get_xid(); xid = get_xid();
/* if (le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength) > 0)
* PATH_MAX may be too long - it would presumably be total path, buf->f_namelen =
* but note that some servers (includinng Samba 3) have a shorter le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength);
* maximum path. else
*
* Instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO.
*/
buf->f_namelen = PATH_MAX; buf->f_namelen = PATH_MAX;
buf->f_fsid.val[0] = tcon->vol_serial_number;
/* are using part of create time for more randomness, see man statfs */
buf->f_fsid.val[1] = (int)le64_to_cpu(tcon->vol_create_time);
buf->f_files = 0; /* undefined */ buf->f_files = 0; /* undefined */
buf->f_ffree = 0; /* unlimited */ buf->f_ffree = 0; /* unlimited */
...@@ -427,7 +432,7 @@ cifs_show_options(struct seq_file *s, struct dentry *root) ...@@ -427,7 +432,7 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
else if (tcon->ses->user_name) else if (tcon->ses->user_name)
seq_show_option(s, "username", tcon->ses->user_name); seq_show_option(s, "username", tcon->ses->user_name);
if (tcon->ses->domainName) if (tcon->ses->domainName && tcon->ses->domainName[0] != 0)
seq_show_option(s, "domain", tcon->ses->domainName); seq_show_option(s, "domain", tcon->ses->domainName);
if (srcaddr->sa_family != AF_UNSPEC) { if (srcaddr->sa_family != AF_UNSPEC) {
...@@ -481,20 +486,12 @@ cifs_show_options(struct seq_file *s, struct dentry *root) ...@@ -481,20 +486,12 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
seq_puts(s, ",persistenthandles"); seq_puts(s, ",persistenthandles");
else if (tcon->use_resilient) else if (tcon->use_resilient)
seq_puts(s, ",resilienthandles"); seq_puts(s, ",resilienthandles");
#ifdef CONFIG_CIFS_SMB311
if (tcon->posix_extensions) if (tcon->posix_extensions)
seq_puts(s, ",posix"); seq_puts(s, ",posix");
else if (tcon->unix_ext) else if (tcon->unix_ext)
seq_puts(s, ",unix"); seq_puts(s, ",unix");
else else
seq_puts(s, ",nounix"); seq_puts(s, ",nounix");
#else
if (tcon->unix_ext)
seq_puts(s, ",unix");
else
seq_puts(s, ",nounix");
#endif /* SMB311 */
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
seq_puts(s, ",posixpaths"); seq_puts(s, ",posixpaths");
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
...@@ -546,6 +543,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root) ...@@ -546,6 +543,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
seq_printf(s, ",wsize=%u", cifs_sb->wsize); seq_printf(s, ",wsize=%u", cifs_sb->wsize);
seq_printf(s, ",echo_interval=%lu", seq_printf(s, ",echo_interval=%lu",
tcon->ses->server->echo_interval / HZ); tcon->ses->server->echo_interval / HZ);
if (tcon->snapshot_time)
seq_printf(s, ",snapshot=%llu", tcon->snapshot_time);
/* convert actimeo and display it in seconds */ /* convert actimeo and display it in seconds */
seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ); seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
......
...@@ -76,6 +76,9 @@ ...@@ -76,6 +76,9 @@
#define SMB_ECHO_INTERVAL_MAX 600 #define SMB_ECHO_INTERVAL_MAX 600
#define SMB_ECHO_INTERVAL_DEFAULT 60 #define SMB_ECHO_INTERVAL_DEFAULT 60
/* maximum number of PDUs in one compound */
#define MAX_COMPOUND 5
/* /*
* Default number of credits to keep available for SMB3. * Default number of credits to keep available for SMB3.
* This value is chosen somewhat arbitrarily. The Windows client * This value is chosen somewhat arbitrarily. The Windows client
...@@ -191,9 +194,7 @@ enum smb_version { ...@@ -191,9 +194,7 @@ enum smb_version {
Smb_21, Smb_21,
Smb_30, Smb_30,
Smb_302, Smb_302,
#ifdef CONFIG_CIFS_SMB311
Smb_311, Smb_311,
#endif /* SMB311 */
Smb_3any, Smb_3any,
Smb_default, Smb_default,
Smb_version_err Smb_version_err
...@@ -456,13 +457,11 @@ struct smb_version_operations { ...@@ -456,13 +457,11 @@ struct smb_version_operations {
long (*fallocate)(struct file *, struct cifs_tcon *, int, loff_t, long (*fallocate)(struct file *, struct cifs_tcon *, int, loff_t,
loff_t); loff_t);
/* init transform request - used for encryption for now */ /* init transform request - used for encryption for now */
int (*init_transform_rq)(struct TCP_Server_Info *, struct smb_rqst *, int (*init_transform_rq)(struct TCP_Server_Info *, int num_rqst,
struct smb_rqst *); struct smb_rqst *, struct smb_rqst *);
/* free transform request */
void (*free_transform_rq)(struct smb_rqst *);
int (*is_transform_hdr)(void *buf); int (*is_transform_hdr)(void *buf);
int (*receive_transform)(struct TCP_Server_Info *, int (*receive_transform)(struct TCP_Server_Info *,
struct mid_q_entry **); struct mid_q_entry **, char **, int *);
enum securityEnum (*select_sectype)(struct TCP_Server_Info *, enum securityEnum (*select_sectype)(struct TCP_Server_Info *,
enum securityEnum); enum securityEnum);
int (*next_header)(char *); int (*next_header)(char *);
...@@ -684,15 +683,14 @@ struct TCP_Server_Info { ...@@ -684,15 +683,14 @@ struct TCP_Server_Info {
#ifdef CONFIG_CIFS_STATS2 #ifdef CONFIG_CIFS_STATS2
atomic_t in_send; /* requests trying to send */ atomic_t in_send; /* requests trying to send */
atomic_t num_waiters; /* blocked waiting to get in sendrecv */ atomic_t num_waiters; /* blocked waiting to get in sendrecv */
#endif atomic_t smb2slowcmd[NUMBER_OF_SMB2_COMMANDS]; /* count resps > 1 sec */
#endif /* STATS2 */
unsigned int max_read; unsigned int max_read;
unsigned int max_write; unsigned int max_write;
#ifdef CONFIG_CIFS_SMB311
__le16 cipher_type; __le16 cipher_type;
/* save initital negprot hash */ /* save initital negprot hash */
__u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE]; __u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
bool posix_ext_supported; bool posix_ext_supported;
#endif /* 3.1.1 */
struct delayed_work reconnect; /* reconnect workqueue job */ struct delayed_work reconnect; /* reconnect workqueue job */
struct mutex reconnect_mutex; /* prevent simultaneous reconnects */ struct mutex reconnect_mutex; /* prevent simultaneous reconnects */
unsigned long echo_interval; unsigned long echo_interval;
...@@ -886,9 +884,7 @@ struct cifs_ses { ...@@ -886,9 +884,7 @@ struct cifs_ses {
__u8 smb3signingkey[SMB3_SIGN_KEY_SIZE]; __u8 smb3signingkey[SMB3_SIGN_KEY_SIZE];
__u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE]; __u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE];
__u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE]; __u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE];
#ifdef CONFIG_CIFS_SMB311
__u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE]; __u8 preauth_sha_hash[SMB2_PREAUTH_HASH_SIZE];
#endif /* 3.1.1 */
/* /*
* Network interfaces available on the server this session is * Network interfaces available on the server this session is
...@@ -913,6 +909,7 @@ cap_unix(struct cifs_ses *ses) ...@@ -913,6 +909,7 @@ cap_unix(struct cifs_ses *ses)
struct cached_fid { struct cached_fid {
bool is_valid:1; /* Do we have a useable root fid */ bool is_valid:1; /* Do we have a useable root fid */
struct kref refcount;
struct cifs_fid *fid; struct cifs_fid *fid;
struct mutex fid_mutex; struct mutex fid_mutex;
struct cifs_tcon *tcon; struct cifs_tcon *tcon;
...@@ -936,7 +933,6 @@ struct cifs_tcon { ...@@ -936,7 +933,6 @@ struct cifs_tcon {
__u32 tid; /* The 4 byte tree id */ __u32 tid; /* The 4 byte tree id */
__u16 Flags; /* optional support bits */ __u16 Flags; /* optional support bits */
enum statusEnum tidStatus; enum statusEnum tidStatus;
#ifdef CONFIG_CIFS_STATS
atomic_t num_smbs_sent; atomic_t num_smbs_sent;
union { union {
struct { struct {
...@@ -967,24 +963,9 @@ struct cifs_tcon { ...@@ -967,24 +963,9 @@ struct cifs_tcon {
atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS]; atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
} smb2_stats; } smb2_stats;
} stats; } stats;
#ifdef CONFIG_CIFS_STATS2
unsigned long long time_writes;
unsigned long long time_reads;
unsigned long long time_opens;
unsigned long long time_deletes;
unsigned long long time_closes;
unsigned long long time_mkdirs;
unsigned long long time_rmdirs;
unsigned long long time_renames;
unsigned long long time_t2renames;
unsigned long long time_ffirst;
unsigned long long time_fnext;
unsigned long long time_fclose;
#endif /* CONFIG_CIFS_STATS2 */
__u64 bytes_read; __u64 bytes_read;
__u64 bytes_written; __u64 bytes_written;
spinlock_t stat_lock; /* protects the two fields above */ spinlock_t stat_lock; /* protects the two fields above */
#endif /* CONFIG_CIFS_STATS */
FILE_SYSTEM_DEVICE_INFO fsDevInfo; FILE_SYSTEM_DEVICE_INFO fsDevInfo;
FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */ FILE_SYSTEM_ATTRIBUTE_INFO fsAttrInfo; /* ok if fs name truncated */
FILE_SYSTEM_UNIX_INFO fsUnixInfo; FILE_SYSTEM_UNIX_INFO fsUnixInfo;
...@@ -997,9 +978,7 @@ struct cifs_tcon { ...@@ -997,9 +978,7 @@ struct cifs_tcon {
bool seal:1; /* transport encryption for this mounted share */ bool seal:1; /* transport encryption for this mounted share */
bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol bool unix_ext:1; /* if false disable Linux extensions to CIFS protocol
for this mount even if server would support */ for this mount even if server would support */
#ifdef CONFIG_CIFS_SMB311
bool posix_extensions; /* if true SMB3.11 posix extensions enabled */ bool posix_extensions; /* if true SMB3.11 posix extensions enabled */
#endif /* CIFS_311 */
bool local_lease:1; /* check leases (only) on local system not remote */ bool local_lease:1; /* check leases (only) on local system not remote */
bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */ bool broken_posix_open; /* e.g. Samba server versions < 3.3.2, 3.2.9 */
bool broken_sparse_sup; /* if server or share does not support sparse */ bool broken_sparse_sup; /* if server or share does not support sparse */
...@@ -1046,6 +1025,7 @@ struct tcon_link { ...@@ -1046,6 +1025,7 @@ struct tcon_link {
}; };
extern struct tcon_link *cifs_sb_tlink(struct cifs_sb_info *cifs_sb); 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);
static inline struct cifs_tcon * static inline struct cifs_tcon *
tlink_tcon(struct tcon_link *tlink) tlink_tcon(struct tcon_link *tlink)
...@@ -1352,7 +1332,6 @@ convert_delimiter(char *path, char delim) ...@@ -1352,7 +1332,6 @@ convert_delimiter(char *path, char delim)
*pos = delim; *pos = delim;
} }
#ifdef CONFIG_CIFS_STATS
#define cifs_stats_inc atomic_inc #define cifs_stats_inc atomic_inc
static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon, static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
...@@ -1372,13 +1351,6 @@ static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon, ...@@ -1372,13 +1351,6 @@ static inline void cifs_stats_bytes_read(struct cifs_tcon *tcon,
tcon->bytes_read += bytes; tcon->bytes_read += bytes;
spin_unlock(&tcon->stat_lock); spin_unlock(&tcon->stat_lock);
} }
#else
#define cifs_stats_inc(field) do {} while (0)
#define cifs_stats_bytes_written(tcon, bytes) do {} while (0)
#define cifs_stats_bytes_read(tcon, bytes) do {} while (0)
#endif
/* /*
...@@ -1544,9 +1516,9 @@ struct cifs_fattr { ...@@ -1544,9 +1516,9 @@ struct cifs_fattr {
dev_t cf_rdev; dev_t cf_rdev;
unsigned int cf_nlink; unsigned int cf_nlink;
unsigned int cf_dtype; unsigned int cf_dtype;
struct timespec cf_atime; struct timespec64 cf_atime;
struct timespec cf_mtime; struct timespec64 cf_mtime;
struct timespec cf_ctime; struct timespec64 cf_ctime;
}; };
static inline void free_dfs_info_param(struct dfs_info3_param *param) static inline void free_dfs_info_param(struct dfs_info3_param *param)
......
...@@ -94,6 +94,10 @@ extern int cifs_call_async(struct TCP_Server_Info *server, ...@@ -94,6 +94,10 @@ extern int cifs_call_async(struct TCP_Server_Info *server,
extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
struct smb_rqst *rqst, int *resp_buf_type, struct smb_rqst *rqst, int *resp_buf_type,
const int flags, struct kvec *resp_iov); const int flags, struct kvec *resp_iov);
extern int compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
const int flags, const int num_rqst,
struct smb_rqst *rqst, int *resp_buf_type,
struct kvec *resp_iov);
extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *, extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *,
struct smb_hdr * /* input */ , struct smb_hdr * /* input */ ,
struct smb_hdr * /* out */ , struct smb_hdr * /* out */ ,
...@@ -143,9 +147,9 @@ extern enum securityEnum select_sectype(struct TCP_Server_Info *server, ...@@ -143,9 +147,9 @@ extern enum securityEnum select_sectype(struct TCP_Server_Info *server,
enum securityEnum requested); enum securityEnum requested);
extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
const struct nls_table *nls_cp); const struct nls_table *nls_cp);
extern struct timespec cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601); extern struct timespec64 cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
extern u64 cifs_UnixTimeToNT(struct timespec); extern u64 cifs_UnixTimeToNT(struct timespec64);
extern struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, extern struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
int offset); int offset);
extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock); extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
extern int cifs_get_writer(struct cifsInodeInfo *cinode); extern int cifs_get_writer(struct cifsInodeInfo *cinode);
......
...@@ -508,13 +508,13 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, NEGOTIATE_RSP *pSMBr) ...@@ -508,13 +508,13 @@ decode_lanman_negprot_rsp(struct TCP_Server_Info *server, NEGOTIATE_RSP *pSMBr)
* this requirement. * this requirement.
*/ */
int val, seconds, remain, result; int val, seconds, remain, result;
struct timespec ts; struct timespec64 ts;
unsigned long utc = ktime_get_real_seconds(); time64_t utc = ktime_get_real_seconds();
ts = cnvrtDosUnixTm(rsp->SrvTime.Date, ts = cnvrtDosUnixTm(rsp->SrvTime.Date,
rsp->SrvTime.Time, 0); rsp->SrvTime.Time, 0);
cifs_dbg(FYI, "SrvTime %d sec since 1970 (utc: %d) diff: %d\n", cifs_dbg(FYI, "SrvTime %lld sec since 1970 (utc: %lld) diff: %lld\n",
(int)ts.tv_sec, (int)utc, ts.tv_sec, utc,
(int)(utc - ts.tv_sec)); utc - ts.tv_sec);
val = (int)(utc - ts.tv_sec); val = (int)(utc - ts.tv_sec);
seconds = abs(val); seconds = abs(val);
result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ; result = (seconds / MIN_TZ_ADJ) * MIN_TZ_ADJ;
...@@ -4082,7 +4082,7 @@ SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -4082,7 +4082,7 @@ SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
if (rc) { if (rc) {
cifs_dbg(FYI, "Send error in QueryInfo = %d\n", rc); cifs_dbg(FYI, "Send error in QueryInfo = %d\n", rc);
} else if (data) { } else if (data) {
struct timespec ts; struct timespec64 ts;
__u32 time = le32_to_cpu(pSMBr->last_write_time); __u32 time = le32_to_cpu(pSMBr->last_write_time);
/* decode response */ /* decode response */
......
...@@ -303,10 +303,8 @@ static const match_table_t cifs_smb_version_tokens = { ...@@ -303,10 +303,8 @@ static const match_table_t cifs_smb_version_tokens = {
{ Smb_21, SMB21_VERSION_STRING }, { Smb_21, SMB21_VERSION_STRING },
{ Smb_30, SMB30_VERSION_STRING }, { Smb_30, SMB30_VERSION_STRING },
{ Smb_302, SMB302_VERSION_STRING }, { Smb_302, SMB302_VERSION_STRING },
#ifdef CONFIG_CIFS_SMB311
{ Smb_311, SMB311_VERSION_STRING }, { Smb_311, SMB311_VERSION_STRING },
{ Smb_311, ALT_SMB311_VERSION_STRING }, { Smb_311, ALT_SMB311_VERSION_STRING },
#endif /* SMB311 */
{ Smb_3any, SMB3ANY_VERSION_STRING }, { Smb_3any, SMB3ANY_VERSION_STRING },
{ Smb_default, SMBDEFAULT_VERSION_STRING }, { Smb_default, SMBDEFAULT_VERSION_STRING },
{ Smb_version_err, NULL } { Smb_version_err, NULL }
...@@ -350,6 +348,7 @@ cifs_reconnect(struct TCP_Server_Info *server) ...@@ -350,6 +348,7 @@ cifs_reconnect(struct TCP_Server_Info *server)
server->max_read = 0; server->max_read = 0;
cifs_dbg(FYI, "Reconnecting tcp session\n"); cifs_dbg(FYI, "Reconnecting tcp session\n");
trace_smb3_reconnect(server->CurrentMid, server->hostname);
/* before reconnecting the tcp session, mark the smb session (uid) /* before reconnecting the tcp session, mark the smb session (uid)
and the tid bad so they are not used until reconnected */ and the tid bad so they are not used until reconnected */
...@@ -851,13 +850,14 @@ cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid) ...@@ -851,13 +850,14 @@ cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid)
static int static int
cifs_demultiplex_thread(void *p) cifs_demultiplex_thread(void *p)
{ {
int length; int i, num_mids, length;
struct TCP_Server_Info *server = p; struct TCP_Server_Info *server = p;
unsigned int pdu_length; unsigned int pdu_length;
unsigned int next_offset; unsigned int next_offset;
char *buf = NULL; char *buf = NULL;
struct task_struct *task_to_wake = NULL; struct task_struct *task_to_wake = NULL;
struct mid_q_entry *mid_entry; struct mid_q_entry *mids[MAX_COMPOUND];
char *bufs[MAX_COMPOUND];
current->flags |= PF_MEMALLOC; current->flags |= PF_MEMALLOC;
cifs_dbg(FYI, "Demultiplex PID: %d\n", task_pid_nr(current)); cifs_dbg(FYI, "Demultiplex PID: %d\n", task_pid_nr(current));
...@@ -924,58 +924,75 @@ cifs_demultiplex_thread(void *p) ...@@ -924,58 +924,75 @@ cifs_demultiplex_thread(void *p)
server->pdu_size = next_offset; server->pdu_size = next_offset;
} }
mid_entry = NULL; memset(mids, 0, sizeof(mids));
memset(bufs, 0, sizeof(bufs));
num_mids = 0;
if (server->ops->is_transform_hdr && if (server->ops->is_transform_hdr &&
server->ops->receive_transform && server->ops->receive_transform &&
server->ops->is_transform_hdr(buf)) { server->ops->is_transform_hdr(buf)) {
length = server->ops->receive_transform(server, length = server->ops->receive_transform(server,
&mid_entry); mids,
bufs,
&num_mids);
} else { } else {
mid_entry = server->ops->find_mid(server, buf); mids[0] = server->ops->find_mid(server, buf);
bufs[0] = buf;
if (mids[0])
num_mids = 1;
if (!mid_entry || !mid_entry->receive) if (!mids[0] || !mids[0]->receive)
length = standard_receive3(server, mid_entry); length = standard_receive3(server, mids[0]);
else else
length = mid_entry->receive(server, mid_entry); length = mids[0]->receive(server, mids[0]);
} }
if (length < 0) { if (length < 0) {
if (mid_entry) for (i = 0; i < num_mids; i++)
cifs_mid_q_entry_release(mid_entry); if (mids[i])
cifs_mid_q_entry_release(mids[i]);
continue; continue;
} }
if (server->large_buf) if (server->large_buf)
buf = server->bigbuf; buf = server->bigbuf;
server->lstrp = jiffies; server->lstrp = jiffies;
if (mid_entry != NULL) {
mid_entry->resp_buf_size = server->pdu_size; for (i = 0; i < num_mids; i++) {
if ((mid_entry->mid_flags & MID_WAIT_CANCELLED) && if (mids[i] != NULL) {
mid_entry->mid_state == MID_RESPONSE_RECEIVED && mids[i]->resp_buf_size = server->pdu_size;
if ((mids[i]->mid_flags & MID_WAIT_CANCELLED) &&
mids[i]->mid_state == MID_RESPONSE_RECEIVED &&
server->ops->handle_cancelled_mid) server->ops->handle_cancelled_mid)
server->ops->handle_cancelled_mid( server->ops->handle_cancelled_mid(
mid_entry->resp_buf, mids[i]->resp_buf,
server); server);
if (!mid_entry->multiRsp || mid_entry->multiEnd) if (!mids[i]->multiRsp || mids[i]->multiEnd)
mid_entry->callback(mid_entry); mids[i]->callback(mids[i]);
cifs_mid_q_entry_release(mid_entry); cifs_mid_q_entry_release(mids[i]);
} else if (server->ops->is_oplock_break && } else if (server->ops->is_oplock_break &&
server->ops->is_oplock_break(buf, server)) { server->ops->is_oplock_break(bufs[i],
server)) {
cifs_dbg(FYI, "Received oplock break\n"); cifs_dbg(FYI, "Received oplock break\n");
} else { } else {
cifs_dbg(VFS, "No task to wake, unknown frame received! NumMids %d\n", cifs_dbg(VFS, "No task to wake, unknown frame "
"received! NumMids %d\n",
atomic_read(&midCount)); atomic_read(&midCount));
cifs_dump_mem("Received Data is: ", buf, cifs_dump_mem("Received Data is: ", bufs[i],
HEADER_SIZE(server)); HEADER_SIZE(server));
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
if (server->ops->dump_detail) if (server->ops->dump_detail)
server->ops->dump_detail(buf, server); server->ops->dump_detail(bufs[i],
server);
cifs_dump_mids(server); cifs_dump_mids(server);
#endif /* CIFS_DEBUG2 */ #endif /* CIFS_DEBUG2 */
} }
}
if (pdu_length > server->pdu_size) { if (pdu_length > server->pdu_size) {
if (!allocate_buffers(server)) if (!allocate_buffers(server))
continue; continue;
...@@ -1174,6 +1191,7 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3) ...@@ -1174,6 +1191,7 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3)
substring_t args[MAX_OPT_ARGS]; substring_t args[MAX_OPT_ARGS];
switch (match_token(value, cifs_smb_version_tokens, args)) { switch (match_token(value, cifs_smb_version_tokens, args)) {
#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
case Smb_1: case Smb_1:
if (disable_legacy_dialects) { if (disable_legacy_dialects) {
cifs_dbg(VFS, "mount with legacy dialect disabled\n"); cifs_dbg(VFS, "mount with legacy dialect disabled\n");
...@@ -1198,6 +1216,14 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3) ...@@ -1198,6 +1216,14 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3)
vol->ops = &smb20_operations; vol->ops = &smb20_operations;
vol->vals = &smb20_values; vol->vals = &smb20_values;
break; break;
#else
case Smb_1:
cifs_dbg(VFS, "vers=1.0 (cifs) mount not permitted when legacy dialects disabled\n");
return 1;
case Smb_20:
cifs_dbg(VFS, "vers=2.0 mount not permitted when legacy dialects disabled\n");
return 1;
#endif /* CIFS_ALLOW_INSECURE_LEGACY */
case Smb_21: case Smb_21:
vol->ops = &smb21_operations; vol->ops = &smb21_operations;
vol->vals = &smb21_values; vol->vals = &smb21_values;
...@@ -1210,12 +1236,10 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3) ...@@ -1210,12 +1236,10 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3)
vol->ops = &smb30_operations; /* currently identical with 3.0 */ vol->ops = &smb30_operations; /* currently identical with 3.0 */
vol->vals = &smb302_values; vol->vals = &smb302_values;
break; break;
#ifdef CONFIG_CIFS_SMB311
case Smb_311: case Smb_311:
vol->ops = &smb311_operations; vol->ops = &smb311_operations;
vol->vals = &smb311_values; vol->vals = &smb311_values;
break; break;
#endif /* SMB311 */
case Smb_3any: case Smb_3any:
vol->ops = &smb30_operations; /* currently identical with 3.0 */ vol->ops = &smb30_operations; /* currently identical with 3.0 */
vol->vals = &smb3any_values; vol->vals = &smb3any_values;
...@@ -3030,15 +3054,17 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info) ...@@ -3030,15 +3054,17 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info)
} }
} }
#ifdef CONFIG_CIFS_SMB311 if (volume_info->linux_ext) {
if ((volume_info->linux_ext) && (ses->server->posix_ext_supported)) { if (ses->server->posix_ext_supported) {
if (ses->server->vals->protocol_id == SMB311_PROT_ID) {
tcon->posix_extensions = true; tcon->posix_extensions = true;
printk_once(KERN_WARNING printk_once(KERN_WARNING
"SMB3.11 POSIX Extensions are experimental\n"); "SMB3.11 POSIX Extensions are experimental\n");
} else {
cifs_dbg(VFS, "Server does not support mounting with posix SMB3.11 extensions.\n");
rc = -EOPNOTSUPP;
goto out_fail;
} }
} }
#endif /* 311 */
/* /*
* BB Do we need to wrap session_mutex around this TCon call and Unix * BB Do we need to wrap session_mutex around this TCon call and Unix
...@@ -3992,11 +4018,9 @@ cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info) ...@@ -3992,11 +4018,9 @@ cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *volume_info)
goto remote_path_check; goto remote_path_check;
} }
#ifdef CONFIG_CIFS_SMB311
/* if new SMB3.11 POSIX extensions are supported do not remap / and \ */ /* if new SMB3.11 POSIX extensions are supported do not remap / and \ */
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;
#endif /* SMB3.11 */
/* tell server which Unix caps we support */ /* tell server which Unix caps we support */
if (cap_unix(tcon->ses)) { if (cap_unix(tcon->ses)) {
...@@ -4459,11 +4483,10 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid) ...@@ -4459,11 +4483,10 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
goto out; goto out;
} }
#ifdef CONFIG_CIFS_SMB311
/* if new SMB3.11 POSIX extensions are supported do not remap / and \ */ /* if new SMB3.11 POSIX extensions are supported do not remap / and \ */
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;
#endif /* SMB3.11 */
if (cap_unix(ses)) if (cap_unix(ses))
reset_cifs_unix_caps(0, tcon, NULL, vol_info); reset_cifs_unix_caps(0, tcon, NULL, vol_info);
......
...@@ -129,8 +129,10 @@ static void cifs_fscache_acquire_inode_cookie(struct cifsInodeInfo *cifsi, ...@@ -129,8 +129,10 @@ static void cifs_fscache_acquire_inode_cookie(struct cifsInodeInfo *cifsi,
memset(&auxdata, 0, sizeof(auxdata)); memset(&auxdata, 0, sizeof(auxdata));
auxdata.eof = cifsi->server_eof; auxdata.eof = cifsi->server_eof;
auxdata.last_write_time = timespec64_to_timespec(cifsi->vfs_inode.i_mtime); auxdata.last_write_time_sec = cifsi->vfs_inode.i_mtime.tv_sec;
auxdata.last_change_time = timespec64_to_timespec(cifsi->vfs_inode.i_ctime); auxdata.last_change_time_sec = cifsi->vfs_inode.i_ctime.tv_sec;
auxdata.last_write_time_nsec = cifsi->vfs_inode.i_mtime.tv_nsec;
auxdata.last_change_time_nsec = cifsi->vfs_inode.i_ctime.tv_nsec;
cifsi->fscache = cifsi->fscache =
fscache_acquire_cookie(tcon->fscache, fscache_acquire_cookie(tcon->fscache,
...@@ -166,8 +168,10 @@ void cifs_fscache_release_inode_cookie(struct inode *inode) ...@@ -166,8 +168,10 @@ void cifs_fscache_release_inode_cookie(struct inode *inode)
if (cifsi->fscache) { if (cifsi->fscache) {
memset(&auxdata, 0, sizeof(auxdata)); memset(&auxdata, 0, sizeof(auxdata));
auxdata.eof = cifsi->server_eof; auxdata.eof = cifsi->server_eof;
auxdata.last_write_time = timespec64_to_timespec(cifsi->vfs_inode.i_mtime); auxdata.last_write_time_sec = cifsi->vfs_inode.i_mtime.tv_sec;
auxdata.last_change_time = timespec64_to_timespec(cifsi->vfs_inode.i_ctime); auxdata.last_change_time_sec = cifsi->vfs_inode.i_ctime.tv_sec;
auxdata.last_write_time_nsec = cifsi->vfs_inode.i_mtime.tv_nsec;
auxdata.last_change_time_nsec = cifsi->vfs_inode.i_ctime.tv_nsec;
cifs_dbg(FYI, "%s: (0x%p)\n", __func__, cifsi->fscache); cifs_dbg(FYI, "%s: (0x%p)\n", __func__, cifsi->fscache);
fscache_relinquish_cookie(cifsi->fscache, &auxdata, false); fscache_relinquish_cookie(cifsi->fscache, &auxdata, false);
......
...@@ -31,8 +31,10 @@ ...@@ -31,8 +31,10 @@
* Auxiliary data attached to CIFS inode within the cache * Auxiliary data attached to CIFS inode within the cache
*/ */
struct cifs_fscache_inode_auxdata { struct cifs_fscache_inode_auxdata {
struct timespec last_write_time; u64 last_write_time_sec;
struct timespec last_change_time; u64 last_change_time_sec;
u32 last_write_time_nsec;
u32 last_change_time_nsec;
u64 eof; u64 eof;
}; };
......
...@@ -95,7 +95,6 @@ static void ...@@ -95,7 +95,6 @@ static void
cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr) cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
{ {
struct cifsInodeInfo *cifs_i = CIFS_I(inode); struct cifsInodeInfo *cifs_i = CIFS_I(inode);
struct timespec ts;
cifs_dbg(FYI, "%s: revalidating inode %llu\n", cifs_dbg(FYI, "%s: revalidating inode %llu\n",
__func__, cifs_i->uniqueid); __func__, cifs_i->uniqueid);
...@@ -114,8 +113,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr) ...@@ -114,8 +113,7 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
} }
/* revalidate if mtime or size have changed */ /* revalidate if mtime or size have changed */
ts = timespec64_to_timespec(inode->i_mtime); if (timespec64_equal(&inode->i_mtime, &fattr->cf_mtime) &&
if (timespec_equal(&ts, &fattr->cf_mtime) &&
cifs_i->server_eof == fattr->cf_eof) { cifs_i->server_eof == fattr->cf_eof) {
cifs_dbg(FYI, "%s: inode %llu is unchanged\n", cifs_dbg(FYI, "%s: inode %llu is unchanged\n",
__func__, cifs_i->uniqueid); __func__, cifs_i->uniqueid);
...@@ -164,9 +162,9 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr) ...@@ -164,9 +162,9 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
cifs_revalidate_cache(inode, fattr); cifs_revalidate_cache(inode, fattr);
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
inode->i_atime = timespec_to_timespec64(fattr->cf_atime); inode->i_atime = fattr->cf_atime;
inode->i_mtime = timespec_to_timespec64(fattr->cf_mtime); inode->i_mtime = fattr->cf_mtime;
inode->i_ctime = timespec_to_timespec64(fattr->cf_ctime); inode->i_ctime = fattr->cf_ctime;
inode->i_rdev = fattr->cf_rdev; inode->i_rdev = fattr->cf_rdev;
cifs_nlink_fattr_to_inode(inode, fattr); cifs_nlink_fattr_to_inode(inode, fattr);
inode->i_uid = fattr->cf_uid; inode->i_uid = fattr->cf_uid;
...@@ -327,8 +325,8 @@ cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct super_block *sb) ...@@ -327,8 +325,8 @@ cifs_create_dfs_fattr(struct cifs_fattr *fattr, struct super_block *sb)
fattr->cf_mode = S_IFDIR | S_IXUGO | S_IRWXU; fattr->cf_mode = S_IFDIR | S_IXUGO | S_IRWXU;
fattr->cf_uid = cifs_sb->mnt_uid; fattr->cf_uid = cifs_sb->mnt_uid;
fattr->cf_gid = cifs_sb->mnt_gid; fattr->cf_gid = cifs_sb->mnt_gid;
ktime_get_real_ts(&fattr->cf_mtime); ktime_get_real_ts64(&fattr->cf_mtime);
fattr->cf_mtime = timespec_trunc(fattr->cf_mtime, sb->s_time_gran); fattr->cf_mtime = timespec64_trunc(fattr->cf_mtime, sb->s_time_gran);
fattr->cf_atime = fattr->cf_ctime = fattr->cf_mtime; fattr->cf_atime = fattr->cf_ctime = fattr->cf_mtime;
fattr->cf_nlink = 2; fattr->cf_nlink = 2;
fattr->cf_flags |= CIFS_FATTR_DFS_REFERRAL; fattr->cf_flags |= CIFS_FATTR_DFS_REFERRAL;
...@@ -604,8 +602,8 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info, ...@@ -604,8 +602,8 @@ cifs_all_info_to_fattr(struct cifs_fattr *fattr, FILE_ALL_INFO *info,
if (info->LastAccessTime) if (info->LastAccessTime)
fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime); fattr->cf_atime = cifs_NTtimeToUnix(info->LastAccessTime);
else { else {
ktime_get_real_ts(&fattr->cf_atime); ktime_get_real_ts64(&fattr->cf_atime);
fattr->cf_atime = timespec_trunc(fattr->cf_atime, sb->s_time_gran); fattr->cf_atime = timespec64_trunc(fattr->cf_atime, sb->s_time_gran);
} }
fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime); fattr->cf_ctime = cifs_NTtimeToUnix(info->ChangeTime);
...@@ -1122,17 +1120,19 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid, ...@@ -1122,17 +1120,19 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
if (!server->ops->set_file_info) if (!server->ops->set_file_info)
return -ENOSYS; return -ENOSYS;
info_buf.Pad = 0;
if (attrs->ia_valid & ATTR_ATIME) { if (attrs->ia_valid & ATTR_ATIME) {
set_time = true; set_time = true;
info_buf.LastAccessTime = info_buf.LastAccessTime =
cpu_to_le64(cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_atime))); cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_atime));
} else } else
info_buf.LastAccessTime = 0; info_buf.LastAccessTime = 0;
if (attrs->ia_valid & ATTR_MTIME) { if (attrs->ia_valid & ATTR_MTIME) {
set_time = true; set_time = true;
info_buf.LastWriteTime = info_buf.LastWriteTime =
cpu_to_le64(cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_mtime))); cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_mtime));
} else } else
info_buf.LastWriteTime = 0; info_buf.LastWriteTime = 0;
...@@ -1145,7 +1145,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid, ...@@ -1145,7 +1145,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
if (set_time && (attrs->ia_valid & ATTR_CTIME)) { if (set_time && (attrs->ia_valid & ATTR_CTIME)) {
cifs_dbg(FYI, "CIFS - CTIME changed\n"); cifs_dbg(FYI, "CIFS - CTIME changed\n");
info_buf.ChangeTime = info_buf.ChangeTime =
cpu_to_le64(cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_ctime))); cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_ctime));
} else } else
info_buf.ChangeTime = 0; info_buf.ChangeTime = 0;
...@@ -1577,14 +1577,12 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, umode_t mode) ...@@ -1577,14 +1577,12 @@ int cifs_mkdir(struct inode *inode, struct dentry *direntry, umode_t mode)
server = tcon->ses->server; server = tcon->ses->server;
#ifdef CONFIG_CIFS_SMB311
if ((server->ops->posix_mkdir) && (tcon->posix_extensions)) { if ((server->ops->posix_mkdir) && (tcon->posix_extensions)) {
rc = server->ops->posix_mkdir(xid, inode, mode, tcon, full_path, rc = server->ops->posix_mkdir(xid, inode, mode, tcon, full_path,
cifs_sb); cifs_sb);
d_drop(direntry); /* for time being always refresh inode info */ d_drop(direntry); /* for time being always refresh inode info */
goto mkdir_out; goto mkdir_out;
} }
#endif /* SMB311 */
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))) {
...@@ -2071,8 +2069,8 @@ int cifs_getattr(const struct path *path, struct kstat *stat, ...@@ -2071,8 +2069,8 @@ int cifs_getattr(const struct path *path, struct kstat *stat,
/* old CIFS Unix Extensions doesn't return create time */ /* old CIFS Unix Extensions doesn't return create time */
if (CIFS_I(inode)->createtime) { if (CIFS_I(inode)->createtime) {
stat->result_mask |= STATX_BTIME; stat->result_mask |= STATX_BTIME;
stat->btime = timespec_to_timespec64( stat->btime =
cifs_NTtimeToUnix(cpu_to_le64(CIFS_I(inode)->createtime))); cifs_NTtimeToUnix(cpu_to_le64(CIFS_I(inode)->createtime));
} }
stat->attributes_mask |= (STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED); stat->attributes_mask |= (STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED);
...@@ -2278,17 +2276,17 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs) ...@@ -2278,17 +2276,17 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
args->gid = INVALID_GID; /* no change */ args->gid = INVALID_GID; /* no change */
if (attrs->ia_valid & ATTR_ATIME) if (attrs->ia_valid & ATTR_ATIME)
args->atime = cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_atime)); args->atime = cifs_UnixTimeToNT(attrs->ia_atime);
else else
args->atime = NO_CHANGE_64; args->atime = NO_CHANGE_64;
if (attrs->ia_valid & ATTR_MTIME) if (attrs->ia_valid & ATTR_MTIME)
args->mtime = cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_mtime)); args->mtime = cifs_UnixTimeToNT(attrs->ia_mtime);
else else
args->mtime = NO_CHANGE_64; args->mtime = NO_CHANGE_64;
if (attrs->ia_valid & ATTR_CTIME) if (attrs->ia_valid & ATTR_CTIME)
args->ctime = cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_ctime)); args->ctime = cifs_UnixTimeToNT(attrs->ia_ctime);
else else
args->ctime = NO_CHANGE_64; args->ctime = NO_CHANGE_64;
......
...@@ -396,7 +396,7 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, ...@@ -396,7 +396,7 @@ smb3_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
struct cifs_io_parms io_parms; struct cifs_io_parms io_parms;
int buf_type = CIFS_NO_BUFFER; int buf_type = CIFS_NO_BUFFER;
__le16 *utf16_path; __le16 *utf16_path;
__u8 oplock = SMB2_OPLOCK_LEVEL_II; __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
struct smb2_file_all_info *pfile_info = NULL; struct smb2_file_all_info *pfile_info = NULL;
oparms.tcon = tcon; oparms.tcon = tcon;
...@@ -459,7 +459,7 @@ smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, ...@@ -459,7 +459,7 @@ smb3_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
struct cifs_io_parms io_parms; struct cifs_io_parms io_parms;
int create_options = CREATE_NOT_DIR; int create_options = CREATE_NOT_DIR;
__le16 *utf16_path; __le16 *utf16_path;
__u8 oplock = SMB2_OPLOCK_LEVEL_EXCLUSIVE; __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
struct kvec iov[2]; struct kvec iov[2];
if (backup_cred(cifs_sb)) if (backup_cred(cifs_sb))
......
...@@ -122,9 +122,7 @@ tconInfoAlloc(void) ...@@ -122,9 +122,7 @@ tconInfoAlloc(void)
mutex_init(&ret_buf->crfid.fid_mutex); mutex_init(&ret_buf->crfid.fid_mutex);
ret_buf->crfid.fid = kzalloc(sizeof(struct cifs_fid), ret_buf->crfid.fid = kzalloc(sizeof(struct cifs_fid),
GFP_KERNEL); GFP_KERNEL);
#ifdef CONFIG_CIFS_STATS
spin_lock_init(&ret_buf->stat_lock); spin_lock_init(&ret_buf->stat_lock);
#endif
} }
return ret_buf; return ret_buf;
} }
......
...@@ -918,10 +918,10 @@ smbCalcSize(void *buf, struct TCP_Server_Info *server) ...@@ -918,10 +918,10 @@ smbCalcSize(void *buf, struct TCP_Server_Info *server)
* Convert the NT UTC (based 1601-01-01, in hundred nanosecond units) * Convert the NT UTC (based 1601-01-01, in hundred nanosecond units)
* into Unix UTC (based 1970-01-01, in seconds). * into Unix UTC (based 1970-01-01, in seconds).
*/ */
struct timespec struct timespec64
cifs_NTtimeToUnix(__le64 ntutc) cifs_NTtimeToUnix(__le64 ntutc)
{ {
struct timespec ts; struct timespec64 ts;
/* BB what about the timezone? BB */ /* BB what about the timezone? BB */
/* Subtract the NTFS time offset, then convert to 1s intervals. */ /* Subtract the NTFS time offset, then convert to 1s intervals. */
...@@ -935,12 +935,12 @@ cifs_NTtimeToUnix(__le64 ntutc) ...@@ -935,12 +935,12 @@ cifs_NTtimeToUnix(__le64 ntutc)
*/ */
if (t < 0) { if (t < 0) {
abs_t = -t; abs_t = -t;
ts.tv_nsec = (long)(do_div(abs_t, 10000000) * 100); ts.tv_nsec = (time64_t)(do_div(abs_t, 10000000) * 100);
ts.tv_nsec = -ts.tv_nsec; ts.tv_nsec = -ts.tv_nsec;
ts.tv_sec = -abs_t; ts.tv_sec = -abs_t;
} else { } else {
abs_t = t; abs_t = t;
ts.tv_nsec = (long)do_div(abs_t, 10000000) * 100; ts.tv_nsec = (time64_t)do_div(abs_t, 10000000) * 100;
ts.tv_sec = abs_t; ts.tv_sec = abs_t;
} }
...@@ -949,7 +949,7 @@ cifs_NTtimeToUnix(__le64 ntutc) ...@@ -949,7 +949,7 @@ cifs_NTtimeToUnix(__le64 ntutc)
/* Convert the Unix UTC into NT UTC. */ /* Convert the Unix UTC into NT UTC. */
u64 u64
cifs_UnixTimeToNT(struct timespec t) cifs_UnixTimeToNT(struct timespec64 t)
{ {
/* Convert to 100ns intervals and then add the NTFS time offset. */ /* Convert to 100ns intervals and then add the NTFS time offset. */
return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET; return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET;
...@@ -959,10 +959,11 @@ static const int total_days_of_prev_months[] = { ...@@ -959,10 +959,11 @@ static const int total_days_of_prev_months[] = {
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
}; };
struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset) struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset)
{ {
struct timespec ts; struct timespec64 ts;
int sec, min, days, month, year; time64_t sec;
int min, days, month, year;
u16 date = le16_to_cpu(le_date); u16 date = le16_to_cpu(le_date);
u16 time = le16_to_cpu(le_time); u16 time = le16_to_cpu(le_time);
SMB_TIME *st = (SMB_TIME *)&time; SMB_TIME *st = (SMB_TIME *)&time;
...@@ -973,7 +974,7 @@ struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset) ...@@ -973,7 +974,7 @@ struct timespec cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset)
sec = 2 * st->TwoSeconds; sec = 2 * st->TwoSeconds;
min = st->Minutes; min = st->Minutes;
if ((sec > 59) || (min > 59)) if ((sec > 59) || (min > 59))
cifs_dbg(VFS, "illegal time min %d sec %d\n", min, sec); cifs_dbg(VFS, "illegal time min %d sec %lld\n", min, sec);
sec += (min * 60); sec += (min * 60);
sec += 60 * 60 * st->Hours; sec += 60 * 60 * st->Hours;
if (st->Hours > 24) if (st->Hours > 24)
......
...@@ -624,7 +624,6 @@ cifs_query_file_info(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -624,7 +624,6 @@ cifs_query_file_info(const unsigned int xid, struct cifs_tcon *tcon,
static void static void
cifs_clear_stats(struct cifs_tcon *tcon) cifs_clear_stats(struct cifs_tcon *tcon)
{ {
#ifdef CONFIG_CIFS_STATS
atomic_set(&tcon->stats.cifs_stats.num_writes, 0); atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
atomic_set(&tcon->stats.cifs_stats.num_reads, 0); atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
atomic_set(&tcon->stats.cifs_stats.num_flushes, 0); atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
...@@ -646,13 +645,11 @@ cifs_clear_stats(struct cifs_tcon *tcon) ...@@ -646,13 +645,11 @@ cifs_clear_stats(struct cifs_tcon *tcon)
atomic_set(&tcon->stats.cifs_stats.num_locks, 0); atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0); atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0); atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
#endif
} }
static void static void
cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon) cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
{ {
#ifdef CONFIG_CIFS_STATS
seq_printf(m, " Oplocks breaks: %d", seq_printf(m, " Oplocks breaks: %d",
atomic_read(&tcon->stats.cifs_stats.num_oplock_brks)); atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
seq_printf(m, "\nReads: %d Bytes: %llu", seq_printf(m, "\nReads: %d Bytes: %llu",
...@@ -684,7 +681,6 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon) ...@@ -684,7 +681,6 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
atomic_read(&tcon->stats.cifs_stats.num_ffirst), atomic_read(&tcon->stats.cifs_stats.num_ffirst),
atomic_read(&tcon->stats.cifs_stats.num_fnext), atomic_read(&tcon->stats.cifs_stats.num_fnext),
atomic_read(&tcon->stats.cifs_stats.num_fclose)); atomic_read(&tcon->stats.cifs_stats.num_fclose));
#endif
} }
static void static void
......
...@@ -120,7 +120,9 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -120,7 +120,9 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon,
break; break;
} }
if (use_cached_root_handle == false) if (use_cached_root_handle)
close_shroot(&tcon->crfid);
else
rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
if (tmprc) if (tmprc)
rc = tmprc; rc = tmprc;
...@@ -281,7 +283,7 @@ smb2_set_file_info(struct inode *inode, const char *full_path, ...@@ -281,7 +283,7 @@ smb2_set_file_info(struct inode *inode, const char *full_path,
int rc; int rc;
if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) && if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) &&
(buf->LastWriteTime == 0) && (buf->ChangeTime) && (buf->LastWriteTime == 0) && (buf->ChangeTime == 0) &&
(buf->Attributes == 0)) (buf->Attributes == 0))
return 0; /* would be a no op, no sense sending this */ return 0; /* would be a no op, no sense sending this */
......
...@@ -93,7 +93,6 @@ static const __le16 smb2_rsp_struct_sizes[NUMBER_OF_SMB2_COMMANDS] = { ...@@ -93,7 +93,6 @@ static const __le16 smb2_rsp_struct_sizes[NUMBER_OF_SMB2_COMMANDS] = {
/* SMB2_OPLOCK_BREAK */ cpu_to_le16(24) /* SMB2_OPLOCK_BREAK */ cpu_to_le16(24)
}; };
#ifdef CONFIG_CIFS_SMB311
static __u32 get_neg_ctxt_len(struct smb2_sync_hdr *hdr, __u32 len, static __u32 get_neg_ctxt_len(struct smb2_sync_hdr *hdr, __u32 len,
__u32 non_ctxlen) __u32 non_ctxlen)
{ {
...@@ -127,7 +126,6 @@ static __u32 get_neg_ctxt_len(struct smb2_sync_hdr *hdr, __u32 len, ...@@ -127,7 +126,6 @@ static __u32 get_neg_ctxt_len(struct smb2_sync_hdr *hdr, __u32 len,
/* length of negcontexts including pad from end of sec blob to them */ /* length of negcontexts including pad from end of sec blob to them */
return (len - nc_offset) + size_of_pad_before_neg_ctxts; return (len - nc_offset) + size_of_pad_before_neg_ctxts;
} }
#endif /* CIFS_SMB311 */
int int
smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr) smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
...@@ -222,10 +220,9 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr) ...@@ -222,10 +220,9 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
clc_len = smb2_calc_size(buf, srvr); clc_len = smb2_calc_size(buf, srvr);
#ifdef CONFIG_CIFS_SMB311
if (shdr->Command == SMB2_NEGOTIATE) if (shdr->Command == SMB2_NEGOTIATE)
clc_len += get_neg_ctxt_len(shdr, len, clc_len); clc_len += get_neg_ctxt_len(shdr, len, clc_len);
#endif /* SMB311 */
if (len != clc_len) { if (len != clc_len) {
cifs_dbg(FYI, "Calculated size %u length %u mismatch mid %llu\n", cifs_dbg(FYI, "Calculated size %u length %u mismatch mid %llu\n",
clc_len, len, mid); clc_len, len, mid);
...@@ -451,15 +448,13 @@ cifs_convert_path_to_utf16(const char *from, struct cifs_sb_info *cifs_sb) ...@@ -451,15 +448,13 @@ cifs_convert_path_to_utf16(const char *from, struct cifs_sb_info *cifs_sb)
/* Windows doesn't allow paths beginning with \ */ /* Windows doesn't allow paths beginning with \ */
if (from[0] == '\\') if (from[0] == '\\')
start_of_path = from + 1; start_of_path = from + 1;
#ifdef CONFIG_CIFS_SMB311
/* SMB311 POSIX extensions paths do not include leading slash */ /* SMB311 POSIX extensions paths do not include leading slash */
else if (cifs_sb_master_tlink(cifs_sb) && else if (cifs_sb_master_tlink(cifs_sb) &&
cifs_sb_master_tcon(cifs_sb)->posix_extensions && cifs_sb_master_tcon(cifs_sb)->posix_extensions &&
(from[0] == '/')) { (from[0] == '/')) {
start_of_path = from + 1; start_of_path = from + 1;
} } else
#endif /* 311 */
else
start_of_path = from; start_of_path = from;
to = cifs_strndup_to_utf16(start_of_path, PATH_MAX, &len, to = cifs_strndup_to_utf16(start_of_path, PATH_MAX, &len,
...@@ -759,7 +754,6 @@ smb2_handle_cancelled_mid(char *buffer, struct TCP_Server_Info *server) ...@@ -759,7 +754,6 @@ smb2_handle_cancelled_mid(char *buffer, struct TCP_Server_Info *server)
return 0; return 0;
} }
#ifdef CONFIG_CIFS_SMB311
/** /**
* smb311_update_preauth_hash - update @ses hash with the packet data in @iov * smb311_update_preauth_hash - update @ses hash with the packet data in @iov
* *
...@@ -821,4 +815,3 @@ smb311_update_preauth_hash(struct cifs_ses *ses, struct kvec *iov, int nvec) ...@@ -821,4 +815,3 @@ smb311_update_preauth_hash(struct cifs_ses *ses, struct kvec *iov, int nvec)
return 0; return 0;
} }
#endif
This diff is collapsed.
This diff is collapsed.
...@@ -153,6 +153,8 @@ struct smb2_transform_hdr { ...@@ -153,6 +153,8 @@ struct smb2_transform_hdr {
* *
*/ */
#define COMPOUND_FID 0xFFFFFFFFFFFFFFFFULL
#define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9) #define SMB2_ERROR_STRUCTURE_SIZE2 cpu_to_le16(9)
struct smb2_err_rsp { struct smb2_err_rsp {
...@@ -765,6 +767,14 @@ struct create_durable_handle_reconnect_v2 { ...@@ -765,6 +767,14 @@ struct create_durable_handle_reconnect_v2 {
struct durable_reconnect_context_v2 dcontext; struct durable_reconnect_context_v2 dcontext;
} __packed; } __packed;
/* See MS-SMB2 2.2.13.2.5 */
struct crt_twarp_ctxt {
struct create_context ccontext;
__u8 Name[8];
__le64 Timestamp;
} __packed;
#define COPY_CHUNK_RES_KEY_SIZE 24 #define COPY_CHUNK_RES_KEY_SIZE 24
struct resume_key_req { struct resume_key_req {
char ResumeKey[COPY_CHUNK_RES_KEY_SIZE]; char ResumeKey[COPY_CHUNK_RES_KEY_SIZE];
...@@ -1223,6 +1233,7 @@ struct smb2_lease_ack { ...@@ -1223,6 +1233,7 @@ struct smb2_lease_ack {
#define FS_DRIVER_PATH_INFORMATION 9 /* Local only */ #define FS_DRIVER_PATH_INFORMATION 9 /* Local only */
#define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */ #define FS_VOLUME_FLAGS_INFORMATION 10 /* Local only */
#define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */ #define FS_SECTOR_SIZE_INFORMATION 11 /* SMB3 or later. Query */
#define FS_POSIX_INFORMATION 100 /* SMB3.1.1 POSIX. Query */
struct smb2_fs_full_size_info { struct smb2_fs_full_size_info {
__le64 TotalAllocationUnits; __le64 TotalAllocationUnits;
...@@ -1248,6 +1259,17 @@ struct smb3_fs_ss_info { ...@@ -1248,6 +1259,17 @@ struct smb3_fs_ss_info {
__le32 ByteOffsetForPartitionAlignment; __le32 ByteOffsetForPartitionAlignment;
} __packed; } __packed;
/* volume info struct - see MS-FSCC 2.5.9 */
#define MAX_VOL_LABEL_LEN 32
struct smb3_fs_vol_info {
__le64 VolumeCreationTime;
__u32 VolumeSerialNumber;
__le32 VolumeLabelLength; /* includes trailing null */
__u8 SupportsObjects; /* True if eg like NTFS, supports objects */
__u8 Reserved;
__u8 VolumeLabel[0]; /* variable len */
} __packed;
/* partial list of QUERY INFO levels */ /* partial list of QUERY INFO levels */
#define FILE_DIRECTORY_INFORMATION 1 #define FILE_DIRECTORY_INFORMATION 1
#define FILE_FULL_DIRECTORY_INFORMATION 2 #define FILE_FULL_DIRECTORY_INFORMATION 2
...@@ -1361,4 +1383,6 @@ struct smb2_file_eof_info { /* encoding of request for level 10 */ ...@@ -1361,4 +1383,6 @@ struct smb2_file_eof_info { /* encoding of request for level 10 */
__le64 EndOfFile; /* new end of file value */ __le64 EndOfFile; /* new end of file value */
} __packed; /* level 20 Set */ } __packed; /* level 20 Set */
extern char smb2_padding[7];
#endif /* _SMB2PDU_H */ #endif /* _SMB2PDU_H */
...@@ -68,6 +68,7 @@ extern int smb3_handle_read_data(struct TCP_Server_Info *server, ...@@ -68,6 +68,7 @@ extern int smb3_handle_read_data(struct TCP_Server_Info *server,
extern int open_shroot(unsigned int xid, struct cifs_tcon *tcon, extern int open_shroot(unsigned int xid, struct cifs_tcon *tcon,
struct cifs_fid *pfid); struct cifs_fid *pfid);
extern void close_shroot(struct cached_fid *cfid);
extern void move_smb2_info_to_cifs(FILE_ALL_INFO *dst, extern void move_smb2_info_to_cifs(FILE_ALL_INFO *dst,
struct smb2_file_all_info *src); struct smb2_file_all_info *src);
extern int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon, extern int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
...@@ -132,6 +133,10 @@ extern int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, ...@@ -132,6 +133,10 @@ extern int SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms,
__le16 *path, __u8 *oplock, __le16 *path, __u8 *oplock,
struct smb2_file_all_info *buf, struct smb2_file_all_info *buf,
struct kvec *err_iov, int *resp_buftype); struct kvec *err_iov, int *resp_buftype);
extern int SMB2_open_init(struct cifs_tcon *tcon, 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, extern int SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon,
u64 persistent_fid, u64 volatile_fid, u32 opcode, u64 persistent_fid, u64 volatile_fid, u32 opcode,
bool is_fsctl, char *in_data, u32 indatalen, bool is_fsctl, char *in_data, u32 indatalen,
...@@ -140,6 +145,9 @@ extern int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -140,6 +145,9 @@ extern int SMB2_close(const unsigned int xid, struct cifs_tcon *tcon,
u64 persistent_file_id, u64 volatile_file_id); u64 persistent_file_id, u64 volatile_file_id);
extern int SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, extern int SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon,
u64 persistent_fid, u64 volatile_fid, int flags); u64 persistent_fid, u64 volatile_fid, int flags);
extern int SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,
u64 persistent_file_id, u64 volatile_file_id);
extern void SMB2_close_free(struct smb_rqst *rqst);
extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
u64 persistent_file_id, u64 volatile_file_id); u64 persistent_file_id, u64 volatile_file_id);
extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon, extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
...@@ -149,6 +157,11 @@ extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon, ...@@ -149,6 +157,11 @@ extern int SMB2_query_eas(const unsigned int xid, struct cifs_tcon *tcon,
extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon, extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
u64 persistent_file_id, u64 volatile_file_id, u64 persistent_file_id, u64 volatile_file_id,
struct smb2_file_all_info *data); struct smb2_file_all_info *data);
extern int SMB2_query_info_init(struct cifs_tcon *tcon, struct smb_rqst *rqst,
u64 persistent_fid, u64 volatile_fid,
u8 info_class, u8 info_type,
u32 additional_info, size_t output_len);
extern void SMB2_query_info_free(struct smb_rqst *rqst);
extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon, extern int SMB2_query_acl(const unsigned int xid, struct cifs_tcon *tcon,
u64 persistent_file_id, u64 volatile_file_id, u64 persistent_file_id, u64 volatile_file_id,
void **data, unsigned int *plen); void **data, unsigned int *plen);
...@@ -197,6 +210,9 @@ void smb2_cancelled_close_fid(struct work_struct *work); ...@@ -197,6 +210,9 @@ void smb2_cancelled_close_fid(struct work_struct *work);
extern int SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, extern int SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon,
u64 persistent_file_id, u64 volatile_file_id, u64 persistent_file_id, u64 volatile_file_id,
struct kstatfs *FSData); struct kstatfs *FSData);
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, extern int SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon,
u64 persistent_file_id, u64 volatile_file_id, int lvl); u64 persistent_file_id, u64 volatile_file_id, int lvl);
extern int SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon, extern int SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon,
...@@ -213,9 +229,13 @@ extern int smb3_validate_negotiate(const unsigned int, struct cifs_tcon *); ...@@ -213,9 +229,13 @@ extern int smb3_validate_negotiate(const unsigned int, struct cifs_tcon *);
extern enum securityEnum smb2_select_sectype(struct TCP_Server_Info *, extern enum securityEnum smb2_select_sectype(struct TCP_Server_Info *,
enum securityEnum); enum securityEnum);
#ifdef CONFIG_CIFS_SMB311 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 void smb2_copy_fs_info_to_kstatfs(
struct smb2_fs_full_size_info *pfs_inf,
struct kstatfs *kst);
extern int smb311_crypto_shash_allocate(struct TCP_Server_Info *server); extern int smb311_crypto_shash_allocate(struct TCP_Server_Info *server);
extern int smb311_update_preauth_hash(struct cifs_ses *ses, extern int smb311_update_preauth_hash(struct cifs_ses *ses,
struct kvec *iov, int nvec); struct kvec *iov, int nvec);
#endif
#endif /* _SMB2PROTO_H */ #endif /* _SMB2PROTO_H */
...@@ -70,7 +70,6 @@ smb3_crypto_shash_allocate(struct TCP_Server_Info *server) ...@@ -70,7 +70,6 @@ smb3_crypto_shash_allocate(struct TCP_Server_Info *server)
return rc; return rc;
} }
#ifdef CONFIG_CIFS_SMB311
int int
smb311_crypto_shash_allocate(struct TCP_Server_Info *server) smb311_crypto_shash_allocate(struct TCP_Server_Info *server)
{ {
...@@ -98,7 +97,6 @@ smb311_crypto_shash_allocate(struct TCP_Server_Info *server) ...@@ -98,7 +97,6 @@ smb311_crypto_shash_allocate(struct TCP_Server_Info *server)
cifs_free_hash(&p->hmacsha256, &p->sdeschmacsha256); cifs_free_hash(&p->hmacsha256, &p->sdeschmacsha256);
return rc; return rc;
} }
#endif
static struct cifs_ses * static struct cifs_ses *
smb2_find_smb_ses_unlocked(struct TCP_Server_Info *server, __u64 ses_id) smb2_find_smb_ses_unlocked(struct TCP_Server_Info *server, __u64 ses_id)
...@@ -173,7 +171,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) ...@@ -173,7 +171,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
struct kvec *iov = rqst->rq_iov; struct kvec *iov = rqst->rq_iov;
struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base; struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)iov[0].iov_base;
struct cifs_ses *ses; struct cifs_ses *ses;
struct shash_desc *shash = &server->secmech.sdeschmacsha256->shash; struct shash_desc *shash;
struct smb_rqst drqst; struct smb_rqst drqst;
ses = smb2_find_smb_ses(server, shdr->SessionId); ses = smb2_find_smb_ses(server, shdr->SessionId);
...@@ -187,7 +185,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) ...@@ -187,7 +185,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
rc = smb2_crypto_shash_allocate(server); rc = smb2_crypto_shash_allocate(server);
if (rc) { if (rc) {
cifs_dbg(VFS, "%s: shah256 alloc failed\n", __func__); cifs_dbg(VFS, "%s: sha256 alloc failed\n", __func__);
return rc; return rc;
} }
...@@ -198,6 +196,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) ...@@ -198,6 +196,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
return rc; return rc;
} }
shash = &server->secmech.sdeschmacsha256->shash;
rc = crypto_shash_init(shash); rc = crypto_shash_init(shash);
if (rc) { if (rc) {
cifs_dbg(VFS, "%s: Could not init sha256", __func__); cifs_dbg(VFS, "%s: Could not init sha256", __func__);
...@@ -395,7 +394,6 @@ generate_smb30signingkey(struct cifs_ses *ses) ...@@ -395,7 +394,6 @@ generate_smb30signingkey(struct cifs_ses *ses)
return generate_smb3signingkey(ses, &triplet); return generate_smb3signingkey(ses, &triplet);
} }
#ifdef CONFIG_CIFS_SMB311
int int
generate_smb311signingkey(struct cifs_ses *ses) generate_smb311signingkey(struct cifs_ses *ses)
...@@ -423,7 +421,6 @@ generate_smb311signingkey(struct cifs_ses *ses) ...@@ -423,7 +421,6 @@ generate_smb311signingkey(struct cifs_ses *ses)
return generate_smb3signingkey(ses, &triplet); return generate_smb3signingkey(ses, &triplet);
} }
#endif /* 311 */
int int
smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
......
...@@ -281,6 +281,44 @@ DEFINE_EVENT(smb3_cmd_done_class, smb3_##name, \ ...@@ -281,6 +281,44 @@ DEFINE_EVENT(smb3_cmd_done_class, smb3_##name, \
TP_ARGS(tid, sesid, cmd, mid)) TP_ARGS(tid, sesid, cmd, mid))
DEFINE_SMB3_CMD_DONE_EVENT(cmd_done); DEFINE_SMB3_CMD_DONE_EVENT(cmd_done);
DEFINE_SMB3_CMD_DONE_EVENT(ses_expired);
DECLARE_EVENT_CLASS(smb3_mid_class,
TP_PROTO(__u16 cmd,
__u64 mid,
__u32 pid,
unsigned long when_sent,
unsigned long when_received),
TP_ARGS(cmd, mid, pid, when_sent, when_received),
TP_STRUCT__entry(
__field(__u16, cmd)
__field(__u64, mid)
__field(__u32, pid)
__field(unsigned long, when_sent)
__field(unsigned long, when_received)
),
TP_fast_assign(
__entry->cmd = cmd;
__entry->mid = mid;
__entry->pid = pid;
__entry->when_sent = when_sent;
__entry->when_received = when_received;
),
TP_printk("\tcmd=%u mid=%llu pid=%u, when_sent=%lu when_rcv=%lu",
__entry->cmd, __entry->mid, __entry->pid, __entry->when_sent,
__entry->when_received)
)
#define DEFINE_SMB3_MID_EVENT(name) \
DEFINE_EVENT(smb3_mid_class, smb3_##name, \
TP_PROTO(__u16 cmd, \
__u64 mid, \
__u32 pid, \
unsigned long when_sent, \
unsigned long when_received), \
TP_ARGS(cmd, mid, pid, when_sent, when_received))
DEFINE_SMB3_MID_EVENT(slow_rsp);
DECLARE_EVENT_CLASS(smb3_exit_err_class, DECLARE_EVENT_CLASS(smb3_exit_err_class,
TP_PROTO(unsigned int xid, TP_PROTO(unsigned int xid,
...@@ -422,6 +460,32 @@ DEFINE_EVENT(smb3_open_done_class, smb3_##name, \ ...@@ -422,6 +460,32 @@ DEFINE_EVENT(smb3_open_done_class, smb3_##name, \
DEFINE_SMB3_OPEN_DONE_EVENT(open_done); DEFINE_SMB3_OPEN_DONE_EVENT(open_done);
DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done); DEFINE_SMB3_OPEN_DONE_EVENT(posix_mkdir_done);
DECLARE_EVENT_CLASS(smb3_reconnect_class,
TP_PROTO(__u64 currmid,
char *hostname),
TP_ARGS(currmid, hostname),
TP_STRUCT__entry(
__field(__u64, currmid)
__field(char *, hostname)
),
TP_fast_assign(
__entry->currmid = currmid;
__entry->hostname = hostname;
),
TP_printk("server=%s current_mid=0x%llx",
__entry->hostname,
__entry->currmid)
)
#define DEFINE_SMB3_RECONNECT_EVENT(name) \
DEFINE_EVENT(smb3_reconnect_class, smb3_##name, \
TP_PROTO(__u64 currmid, \
char *hostname), \
TP_ARGS(currmid, hostname))
DEFINE_SMB3_RECONNECT_EVENT(reconnect);
DEFINE_SMB3_RECONNECT_EVENT(partial_send_reconnect);
#endif /* _CIFS_TRACE_H */ #endif /* _CIFS_TRACE_H */
#undef TRACE_INCLUDE_PATH #undef TRACE_INCLUDE_PATH
......
...@@ -115,8 +115,17 @@ DeleteMidQEntry(struct mid_q_entry *midEntry) ...@@ -115,8 +115,17 @@ DeleteMidQEntry(struct mid_q_entry *midEntry)
now = jiffies; now = jiffies;
/* commands taking longer than one second are indications that /* commands taking longer than one second are indications that
something is wrong, unless it is quite a slow link or server */ something is wrong, unless it is quite a slow link or server */
if (time_after(now, midEntry->when_alloc + HZ)) { if (time_after(now, midEntry->when_alloc + HZ) &&
if ((cifsFYI & CIFS_TIMER) && (midEntry->command != command)) { (midEntry->command != command)) {
/* smb2slowcmd[NUMBER_OF_SMB2_COMMANDS] counts by command */
if ((le16_to_cpu(midEntry->command) < NUMBER_OF_SMB2_COMMANDS) &&
(le16_to_cpu(midEntry->command) >= 0))
cifs_stats_inc(&midEntry->server->smb2slowcmd[le16_to_cpu(midEntry->command)]);
trace_smb3_slow_rsp(le16_to_cpu(midEntry->command),
midEntry->mid, midEntry->pid,
midEntry->when_sent, midEntry->when_received);
if (cifsFYI & CIFS_TIMER) {
pr_debug(" CIFS slow rsp: cmd %d mid %llu", pr_debug(" CIFS slow rsp: cmd %d mid %llu",
midEntry->command, midEntry->mid); midEntry->command, midEntry->mid);
pr_info(" A: 0x%lx S: 0x%lx R: 0x%lx\n", pr_info(" A: 0x%lx S: 0x%lx R: 0x%lx\n",
...@@ -361,6 +370,8 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, ...@@ -361,6 +370,8 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
* socket so the server throws away the partial SMB * socket so the server throws away the partial SMB
*/ */
server->tcpStatus = CifsNeedReconnect; server->tcpStatus = CifsNeedReconnect;
trace_smb3_partial_send_reconnect(server->CurrentMid,
server->hostname);
} }
smbd_done: smbd_done:
if (rc < 0 && rc != -EINTR) if (rc < 0 && rc != -EINTR)
...@@ -373,26 +384,42 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, ...@@ -373,26 +384,42 @@ __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
} }
static int static int
smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst, int flags) smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
struct smb_rqst *rqst, int flags)
{ {
struct smb_rqst cur_rqst; struct kvec iov;
struct smb2_transform_hdr tr_hdr;
struct smb_rqst cur_rqst[MAX_COMPOUND];
int rc; int rc;
if (!(flags & CIFS_TRANSFORM_REQ)) if (!(flags & CIFS_TRANSFORM_REQ))
return __smb_send_rqst(server, 1, rqst); return __smb_send_rqst(server, num_rqst, rqst);
if (!server->ops->init_transform_rq || if (num_rqst > MAX_COMPOUND - 1)
!server->ops->free_transform_rq) { return -ENOMEM;
cifs_dbg(VFS, "Encryption requested but transform callbacks are missed\n");
memset(&cur_rqst[0], 0, sizeof(cur_rqst));
memset(&iov, 0, sizeof(iov));
memset(&tr_hdr, 0, sizeof(tr_hdr));
iov.iov_base = &tr_hdr;
iov.iov_len = sizeof(tr_hdr);
cur_rqst[0].rq_iov = &iov;
cur_rqst[0].rq_nvec = 1;
if (!server->ops->init_transform_rq) {
cifs_dbg(VFS, "Encryption requested but transform callback "
"is missing\n");
return -EIO; return -EIO;
} }
rc = server->ops->init_transform_rq(server, &cur_rqst, rqst); rc = server->ops->init_transform_rq(server, num_rqst + 1,
&cur_rqst[0], rqst);
if (rc) if (rc)
return rc; return rc;
rc = __smb_send_rqst(server, 1, &cur_rqst); rc = __smb_send_rqst(server, num_rqst + 1, &cur_rqst[0]);
server->ops->free_transform_rq(&cur_rqst); smb3_free_compound_rqst(num_rqst, &cur_rqst[1]);
return rc; return rc;
} }
...@@ -606,7 +633,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst, ...@@ -606,7 +633,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_rqst *rqst,
*/ */
cifs_save_when_sent(mid); cifs_save_when_sent(mid);
cifs_in_send_inc(server); cifs_in_send_inc(server);
rc = smb_send_rqst(server, rqst, flags); rc = smb_send_rqst(server, 1, rqst, flags);
cifs_in_send_dec(server); cifs_in_send_dec(server);
if (rc < 0) { if (rc < 0) {
...@@ -746,20 +773,21 @@ cifs_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst) ...@@ -746,20 +773,21 @@ cifs_setup_request(struct cifs_ses *ses, struct smb_rqst *rqst)
} }
int int
cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
struct smb_rqst *rqst, int *resp_buf_type, const int flags, const int flags, const int num_rqst, struct smb_rqst *rqst,
struct kvec *resp_iov) int *resp_buf_type, struct kvec *resp_iov)
{ {
int rc = 0; int i, j, rc = 0;
int timeout, optype; int timeout, optype;
struct mid_q_entry *midQ; struct mid_q_entry *midQ[MAX_COMPOUND];
unsigned int credits = 1; unsigned int credits = 1;
char *buf; char *buf;
timeout = flags & CIFS_TIMEOUT_MASK; timeout = flags & CIFS_TIMEOUT_MASK;
optype = flags & CIFS_OP_MASK; optype = flags & CIFS_OP_MASK;
*resp_buf_type = CIFS_NO_BUFFER; /* no response buf yet */ for (i = 0; i < num_rqst; i++)
resp_buf_type[i] = CIFS_NO_BUFFER; /* no response buf yet */
if ((ses == NULL) || (ses->server == NULL)) { if ((ses == NULL) || (ses->server == NULL)) {
cifs_dbg(VFS, "Null session\n"); cifs_dbg(VFS, "Null session\n");
...@@ -786,44 +814,52 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, ...@@ -786,44 +814,52 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
mutex_lock(&ses->server->srv_mutex); mutex_lock(&ses->server->srv_mutex);
midQ = ses->server->ops->setup_request(ses, rqst); for (i = 0; i < num_rqst; i++) {
if (IS_ERR(midQ)) { midQ[i] = ses->server->ops->setup_request(ses, &rqst[i]);
if (IS_ERR(midQ[i])) {
for (j = 0; j < i; j++)
cifs_delete_mid(midQ[j]);
mutex_unlock(&ses->server->srv_mutex); mutex_unlock(&ses->server->srv_mutex);
/* Update # of requests on wire to server */ /* Update # of requests on wire to server */
add_credits(ses->server, 1, optype); add_credits(ses->server, 1, optype);
return PTR_ERR(midQ); return PTR_ERR(midQ[i]);
}
midQ[i]->mid_state = MID_REQUEST_SUBMITTED;
} }
midQ->mid_state = MID_REQUEST_SUBMITTED;
cifs_in_send_inc(ses->server); cifs_in_send_inc(ses->server);
rc = smb_send_rqst(ses->server, rqst, flags); rc = smb_send_rqst(ses->server, num_rqst, rqst, flags);
cifs_in_send_dec(ses->server); cifs_in_send_dec(ses->server);
cifs_save_when_sent(midQ);
for (i = 0; i < num_rqst; i++)
cifs_save_when_sent(midQ[i]);
if (rc < 0) if (rc < 0)
ses->server->sequence_number -= 2; ses->server->sequence_number -= 2;
mutex_unlock(&ses->server->srv_mutex); mutex_unlock(&ses->server->srv_mutex);
for (i = 0; i < num_rqst; i++) {
if (rc < 0) if (rc < 0)
goto out; goto out;
#ifdef CONFIG_CIFS_SMB311
if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP)) if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP))
smb311_update_preauth_hash(ses, rqst->rq_iov, smb311_update_preauth_hash(ses, rqst[i].rq_iov,
rqst->rq_nvec); rqst[i].rq_nvec);
#endif
if (timeout == CIFS_ASYNC_OP) if (timeout == CIFS_ASYNC_OP)
goto out; goto out;
rc = wait_for_response(ses->server, midQ); rc = wait_for_response(ses->server, midQ[i]);
if (rc != 0) { if (rc != 0) {
cifs_dbg(FYI, "Cancelling wait for mid %llu\n", midQ->mid); cifs_dbg(FYI, "Cancelling wait for mid %llu\n",
send_cancel(ses->server, rqst, midQ); midQ[i]->mid);
send_cancel(ses->server, &rqst[i], midQ[i]);
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if (midQ->mid_state == MID_REQUEST_SUBMITTED) { if (midQ[i]->mid_state == MID_REQUEST_SUBMITTED) {
midQ->mid_flags |= MID_WAIT_CANCELLED; midQ[i]->mid_flags |= MID_WAIT_CANCELLED;
midQ->callback = DeleteMidQEntry; midQ[i]->callback = DeleteMidQEntry;
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
add_credits(ses->server, 1, optype); add_credits(ses->server, 1, optype);
return rc; return rc;
...@@ -831,52 +867,63 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, ...@@ -831,52 +867,63 @@ cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
} }
rc = cifs_sync_mid_result(midQ, ses->server); rc = cifs_sync_mid_result(midQ[i], ses->server);
if (rc != 0) { if (rc != 0) {
add_credits(ses->server, 1, optype); add_credits(ses->server, 1, optype);
return rc; return rc;
} }
if (!midQ->resp_buf || midQ->mid_state != MID_RESPONSE_RECEIVED) { if (!midQ[i]->resp_buf ||
midQ[i]->mid_state != MID_RESPONSE_RECEIVED) {
rc = -EIO; rc = -EIO;
cifs_dbg(FYI, "Bad MID state?\n"); cifs_dbg(FYI, "Bad MID state?\n");
goto out; goto out;
} }
buf = (char *)midQ->resp_buf; buf = (char *)midQ[i]->resp_buf;
resp_iov->iov_base = buf; resp_iov[i].iov_base = buf;
resp_iov->iov_len = midQ->resp_buf_size + resp_iov[i].iov_len = midQ[i]->resp_buf_size +
ses->server->vals->header_preamble_size; ses->server->vals->header_preamble_size;
if (midQ->large_buf)
*resp_buf_type = CIFS_LARGE_BUFFER; if (midQ[i]->large_buf)
resp_buf_type[i] = CIFS_LARGE_BUFFER;
else else
*resp_buf_type = CIFS_SMALL_BUFFER; resp_buf_type[i] = CIFS_SMALL_BUFFER;
#ifdef CONFIG_CIFS_SMB311
if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP)) { if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP)) {
struct kvec iov = { struct kvec iov = {
.iov_base = resp_iov->iov_base, .iov_base = resp_iov[i].iov_base,
.iov_len = resp_iov->iov_len .iov_len = resp_iov[i].iov_len
}; };
smb311_update_preauth_hash(ses, &iov, 1); smb311_update_preauth_hash(ses, &iov, 1);
} }
#endif
credits = ses->server->ops->get_credits(midQ); credits = ses->server->ops->get_credits(midQ[i]);
rc = ses->server->ops->check_receive(midQ, ses->server, rc = ses->server->ops->check_receive(midQ[i], ses->server,
flags & CIFS_LOG_ERROR); flags & CIFS_LOG_ERROR);
/* mark it so buf will not be freed by cifs_delete_mid */ /* mark it so buf will not be freed by cifs_delete_mid */
if ((flags & CIFS_NO_RESP) == 0) if ((flags & CIFS_NO_RESP) == 0)
midQ->resp_buf = NULL; midQ[i]->resp_buf = NULL;
}
out: out:
cifs_delete_mid(midQ); for (i = 0; i < num_rqst; i++)
cifs_delete_mid(midQ[i]);
add_credits(ses->server, credits, optype); add_credits(ses->server, credits, optype);
return rc; return rc;
} }
int
cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
struct smb_rqst *rqst, int *resp_buf_type, const int flags,
struct kvec *resp_iov)
{
return compound_send_recv(xid, ses, flags, 1, rqst, resp_buf_type,
resp_iov);
}
int int
SendReceive2(const unsigned int xid, struct cifs_ses *ses, SendReceive2(const unsigned int xid, struct cifs_ses *ses,
struct kvec *iov, int n_vec, int *resp_buf_type /* ret */, struct kvec *iov, int n_vec, int *resp_buf_type /* ret */,
......
...@@ -35,6 +35,14 @@ ...@@ -35,6 +35,14 @@
#define CIFS_XATTR_CIFS_ACL "system.cifs_acl" #define CIFS_XATTR_CIFS_ACL "system.cifs_acl"
#define CIFS_XATTR_ATTRIB "cifs.dosattrib" /* full name: user.cifs.dosattrib */ #define CIFS_XATTR_ATTRIB "cifs.dosattrib" /* full name: user.cifs.dosattrib */
#define CIFS_XATTR_CREATETIME "cifs.creationtime" /* user.cifs.creationtime */ #define CIFS_XATTR_CREATETIME "cifs.creationtime" /* user.cifs.creationtime */
/*
* Although these three are just aliases for the above, need to move away from
* confusing users and using the 20+ year old term 'cifs' when it is no longer
* secure, replaced by SMB2 (then even more highly secure SMB3) many years ago
*/
#define SMB3_XATTR_CIFS_ACL "system.smb3_acl"
#define SMB3_XATTR_ATTRIB "smb3.dosattrib" /* full name: user.smb3.dosattrib */
#define SMB3_XATTR_CREATETIME "smb3.creationtime" /* user.smb3.creationtime */
/* BB need to add server (Samba e.g) support for security and trusted prefix */ /* BB need to add server (Samba e.g) support for security and trusted prefix */
enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT }; enum { XATTR_USER, XATTR_CIFS_ACL, XATTR_ACL_ACCESS, XATTR_ACL_DEFAULT };
...@@ -220,10 +228,12 @@ static int cifs_xattr_get(const struct xattr_handler *handler, ...@@ -220,10 +228,12 @@ static int cifs_xattr_get(const struct xattr_handler *handler,
switch (handler->flags) { switch (handler->flags) {
case XATTR_USER: case XATTR_USER:
cifs_dbg(FYI, "%s:querying user xattr %s\n", __func__, name); cifs_dbg(FYI, "%s:querying user xattr %s\n", __func__, name);
if (strcmp(name, CIFS_XATTR_ATTRIB) == 0) { if ((strcmp(name, CIFS_XATTR_ATTRIB) == 0) ||
(strcmp(name, SMB3_XATTR_ATTRIB) == 0)) {
rc = cifs_attrib_get(dentry, inode, value, size); rc = cifs_attrib_get(dentry, inode, value, size);
break; break;
} else if (strcmp(name, CIFS_XATTR_CREATETIME) == 0) { } else if ((strcmp(name, CIFS_XATTR_CREATETIME) == 0) ||
(strcmp(name, SMB3_XATTR_CREATETIME) == 0)) {
rc = cifs_creation_time_get(dentry, inode, value, size); rc = cifs_creation_time_get(dentry, inode, value, size);
break; break;
} }
...@@ -363,6 +373,19 @@ static const struct xattr_handler cifs_cifs_acl_xattr_handler = { ...@@ -363,6 +373,19 @@ static const struct xattr_handler cifs_cifs_acl_xattr_handler = {
.set = cifs_xattr_set, .set = cifs_xattr_set,
}; };
/*
* Although this is just an alias for the above, need to move away from
* confusing users and using the 20 year old term 'cifs' when it is no
* longer secure and was replaced by SMB2/SMB3 a long time ago, and
* SMB3 and later are highly secure.
*/
static const struct xattr_handler smb3_acl_xattr_handler = {
.name = SMB3_XATTR_CIFS_ACL,
.flags = XATTR_CIFS_ACL,
.get = cifs_xattr_get,
.set = cifs_xattr_set,
};
static const struct xattr_handler cifs_posix_acl_access_xattr_handler = { static const struct xattr_handler cifs_posix_acl_access_xattr_handler = {
.name = XATTR_NAME_POSIX_ACL_ACCESS, .name = XATTR_NAME_POSIX_ACL_ACCESS,
.flags = XATTR_ACL_ACCESS, .flags = XATTR_ACL_ACCESS,
...@@ -381,6 +404,7 @@ const struct xattr_handler *cifs_xattr_handlers[] = { ...@@ -381,6 +404,7 @@ const struct xattr_handler *cifs_xattr_handlers[] = {
&cifs_user_xattr_handler, &cifs_user_xattr_handler,
&cifs_os2_xattr_handler, &cifs_os2_xattr_handler,
&cifs_cifs_acl_xattr_handler, &cifs_cifs_acl_xattr_handler,
&smb3_acl_xattr_handler, /* alias for above since avoiding "cifs" */
&cifs_posix_acl_access_xattr_handler, &cifs_posix_acl_access_xattr_handler,
&cifs_posix_acl_default_xattr_handler, &cifs_posix_acl_default_xattr_handler,
NULL NULL
......
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