diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-10-17 21:49:21 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-10-17 21:49:21 -0400 |
commit | 04919afb85c8f007b7326c4da5eb61c52e91b9c7 (patch) | |
tree | 005e9dd8da59d4141d2e99570f4298624c692e90 /fs | |
parent | 83f11a9cf2578b104c0daf18fc9c7d33c3d6d53a (diff) | |
parent | 0c26606cbe4937f2228a27bb0c2cad19855be87a (diff) |
Merge branch 'for-linus' of git://git.samba.org/sfrench/cifs-2.6
Pull CIFS fixes from Steve French:
"Five small cifs fixes (includes fixes for: unmount hang, 2 security
related, symlink, large file writes)"
* 'for-linus' of git://git.samba.org/sfrench/cifs-2.6:
cifs: ntstatus_to_dos_map[] is not terminated
cifs: Allow LANMAN auth method for servers supporting unencapsulated authentication methods
cifs: Fix inability to write files >2GB to SMB2/3 shares
cifs: Avoid umount hangs with smb2 when server is unresponsive
do not treat non-symlink reparse points as valid symlinks
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/cifsfs.c | 6 | ||||
-rw-r--r-- | fs/cifs/cifspdu.h | 31 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 40 | ||||
-rw-r--r-- | fs/cifs/netmisc.c | 4 | ||||
-rw-r--r-- | fs/cifs/sess.c | 4 | ||||
-rw-r--r-- | fs/cifs/smb2pdu.c | 6 | ||||
-rw-r--r-- | fs/cifs/smbfsctl.h | 14 | ||||
-rw-r--r-- | fs/cifs/transport.c | 9 |
8 files changed, 93 insertions, 21 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index a16b4e58bcc6..77fc5e181077 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -120,14 +120,16 @@ cifs_read_super(struct super_block *sb) | |||
120 | { | 120 | { |
121 | struct inode *inode; | 121 | struct inode *inode; |
122 | struct cifs_sb_info *cifs_sb; | 122 | struct cifs_sb_info *cifs_sb; |
123 | struct cifs_tcon *tcon; | ||
123 | int rc = 0; | 124 | int rc = 0; |
124 | 125 | ||
125 | cifs_sb = CIFS_SB(sb); | 126 | cifs_sb = CIFS_SB(sb); |
127 | tcon = cifs_sb_master_tcon(cifs_sb); | ||
126 | 128 | ||
127 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) | 129 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) |
128 | sb->s_flags |= MS_POSIXACL; | 130 | sb->s_flags |= MS_POSIXACL; |
129 | 131 | ||
130 | if (cifs_sb_master_tcon(cifs_sb)->ses->capabilities & CAP_LARGE_FILES) | 132 | if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files) |
131 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 133 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
132 | else | 134 | else |
133 | sb->s_maxbytes = MAX_NON_LFS; | 135 | sb->s_maxbytes = MAX_NON_LFS; |
@@ -147,7 +149,7 @@ cifs_read_super(struct super_block *sb) | |||
147 | goto out_no_root; | 149 | goto out_no_root; |
148 | } | 150 | } |
149 | 151 | ||
150 | if (cifs_sb_master_tcon(cifs_sb)->nocase) | 152 | if (tcon->nocase) |
151 | sb->s_d_op = &cifs_ci_dentry_ops; | 153 | sb->s_d_op = &cifs_ci_dentry_ops; |
152 | else | 154 | else |
153 | sb->s_d_op = &cifs_dentry_ops; | 155 | sb->s_d_op = &cifs_dentry_ops; |
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h index a630475e421c..08f9dfb1a894 100644 --- a/fs/cifs/cifspdu.h +++ b/fs/cifs/cifspdu.h | |||
@@ -1491,15 +1491,30 @@ struct file_notify_information { | |||
1491 | __u8 FileName[0]; | 1491 | __u8 FileName[0]; |
1492 | } __attribute__((packed)); | 1492 | } __attribute__((packed)); |
1493 | 1493 | ||
1494 | struct reparse_data { | 1494 | /* For IO_REPARSE_TAG_SYMLINK */ |
1495 | __u32 ReparseTag; | 1495 | struct reparse_symlink_data { |
1496 | __u16 ReparseDataLength; | 1496 | __le32 ReparseTag; |
1497 | __le16 ReparseDataLength; | ||
1497 | __u16 Reserved; | 1498 | __u16 Reserved; |
1498 | __u16 SubstituteNameOffset; | 1499 | __le16 SubstituteNameOffset; |
1499 | __u16 SubstituteNameLength; | 1500 | __le16 SubstituteNameLength; |
1500 | __u16 PrintNameOffset; | 1501 | __le16 PrintNameOffset; |
1501 | __u16 PrintNameLength; | 1502 | __le16 PrintNameLength; |
1502 | __u32 Flags; | 1503 | __le32 Flags; |
1504 | char PathBuffer[0]; | ||
1505 | } __attribute__((packed)); | ||
1506 | |||
1507 | /* For IO_REPARSE_TAG_NFS */ | ||
1508 | #define NFS_SPECFILE_LNK 0x00000000014B4E4C | ||
1509 | #define NFS_SPECFILE_CHR 0x0000000000524843 | ||
1510 | #define NFS_SPECFILE_BLK 0x00000000004B4C42 | ||
1511 | #define NFS_SPECFILE_FIFO 0x000000004F464946 | ||
1512 | #define NFS_SPECFILE_SOCK 0x000000004B434F53 | ||
1513 | struct reparse_posix_data { | ||
1514 | __le32 ReparseTag; | ||
1515 | __le16 ReparseDataLength; | ||
1516 | __u16 Reserved; | ||
1517 | __le64 InodeType; /* LNK, FIFO, CHR etc. */ | ||
1503 | char PathBuffer[0]; | 1518 | char PathBuffer[0]; |
1504 | } __attribute__((packed)); | 1519 | } __attribute__((packed)); |
1505 | 1520 | ||
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 4baf35949b51..ccd31ab815d4 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -3088,7 +3088,8 @@ CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon, | |||
3088 | bool is_unicode; | 3088 | bool is_unicode; |
3089 | unsigned int sub_len; | 3089 | unsigned int sub_len; |
3090 | char *sub_start; | 3090 | char *sub_start; |
3091 | struct reparse_data *reparse_buf; | 3091 | struct reparse_symlink_data *reparse_buf; |
3092 | struct reparse_posix_data *posix_buf; | ||
3092 | __u32 data_offset, data_count; | 3093 | __u32 data_offset, data_count; |
3093 | char *end_of_smb; | 3094 | char *end_of_smb; |
3094 | 3095 | ||
@@ -3137,20 +3138,47 @@ CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon, | |||
3137 | goto qreparse_out; | 3138 | goto qreparse_out; |
3138 | } | 3139 | } |
3139 | end_of_smb = 2 + get_bcc(&pSMBr->hdr) + (char *)&pSMBr->ByteCount; | 3140 | end_of_smb = 2 + get_bcc(&pSMBr->hdr) + (char *)&pSMBr->ByteCount; |
3140 | reparse_buf = (struct reparse_data *) | 3141 | reparse_buf = (struct reparse_symlink_data *) |
3141 | ((char *)&pSMBr->hdr.Protocol + data_offset); | 3142 | ((char *)&pSMBr->hdr.Protocol + data_offset); |
3142 | if ((char *)reparse_buf >= end_of_smb) { | 3143 | if ((char *)reparse_buf >= end_of_smb) { |
3143 | rc = -EIO; | 3144 | rc = -EIO; |
3144 | goto qreparse_out; | 3145 | goto qreparse_out; |
3145 | } | 3146 | } |
3146 | if ((reparse_buf->PathBuffer + reparse_buf->PrintNameOffset + | 3147 | if (reparse_buf->ReparseTag == cpu_to_le32(IO_REPARSE_TAG_NFS)) { |
3147 | reparse_buf->PrintNameLength) > end_of_smb) { | 3148 | cifs_dbg(FYI, "NFS style reparse tag\n"); |
3149 | posix_buf = (struct reparse_posix_data *)reparse_buf; | ||
3150 | |||
3151 | if (posix_buf->InodeType != cpu_to_le64(NFS_SPECFILE_LNK)) { | ||
3152 | cifs_dbg(FYI, "unsupported file type 0x%llx\n", | ||
3153 | le64_to_cpu(posix_buf->InodeType)); | ||
3154 | rc = -EOPNOTSUPP; | ||
3155 | goto qreparse_out; | ||
3156 | } | ||
3157 | is_unicode = true; | ||
3158 | sub_len = le16_to_cpu(reparse_buf->ReparseDataLength); | ||
3159 | if (posix_buf->PathBuffer + sub_len > end_of_smb) { | ||
3160 | cifs_dbg(FYI, "reparse buf beyond SMB\n"); | ||
3161 | rc = -EIO; | ||
3162 | goto qreparse_out; | ||
3163 | } | ||
3164 | *symlinkinfo = cifs_strndup_from_utf16(posix_buf->PathBuffer, | ||
3165 | sub_len, is_unicode, nls_codepage); | ||
3166 | goto qreparse_out; | ||
3167 | } else if (reparse_buf->ReparseTag != | ||
3168 | cpu_to_le32(IO_REPARSE_TAG_SYMLINK)) { | ||
3169 | rc = -EOPNOTSUPP; | ||
3170 | goto qreparse_out; | ||
3171 | } | ||
3172 | |||
3173 | /* Reparse tag is NTFS symlink */ | ||
3174 | sub_start = le16_to_cpu(reparse_buf->SubstituteNameOffset) + | ||
3175 | reparse_buf->PathBuffer; | ||
3176 | sub_len = le16_to_cpu(reparse_buf->SubstituteNameLength); | ||
3177 | if (sub_start + sub_len > end_of_smb) { | ||
3148 | cifs_dbg(FYI, "reparse buf beyond SMB\n"); | 3178 | cifs_dbg(FYI, "reparse buf beyond SMB\n"); |
3149 | rc = -EIO; | 3179 | rc = -EIO; |
3150 | goto qreparse_out; | 3180 | goto qreparse_out; |
3151 | } | 3181 | } |
3152 | sub_start = reparse_buf->SubstituteNameOffset + reparse_buf->PathBuffer; | ||
3153 | sub_len = reparse_buf->SubstituteNameLength; | ||
3154 | if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) | 3182 | if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) |
3155 | is_unicode = true; | 3183 | is_unicode = true; |
3156 | else | 3184 | else |
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index af847e1cf1c1..651a5279607b 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c | |||
@@ -780,7 +780,9 @@ static const struct { | |||
780 | ERRDOS, ERRnoaccess, 0xc0000290}, { | 780 | ERRDOS, ERRnoaccess, 0xc0000290}, { |
781 | ERRDOS, ERRbadfunc, 0xc000029c}, { | 781 | ERRDOS, ERRbadfunc, 0xc000029c}, { |
782 | ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, { | 782 | ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, { |
783 | ERRDOS, ERRinvlevel, 0x007c0001}, }; | 783 | ERRDOS, ERRinvlevel, 0x007c0001}, { |
784 | 0, 0, 0 } | ||
785 | }; | ||
784 | 786 | ||
785 | /***************************************************************************** | 787 | /***************************************************************************** |
786 | Print an error message from the status code | 788 | Print an error message from the status code |
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 352358de1d7e..e87387dbf39f 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
@@ -500,9 +500,9 @@ select_sectype(struct TCP_Server_Info *server, enum securityEnum requested) | |||
500 | return NTLMv2; | 500 | return NTLMv2; |
501 | if (global_secflags & CIFSSEC_MAY_NTLM) | 501 | if (global_secflags & CIFSSEC_MAY_NTLM) |
502 | return NTLM; | 502 | return NTLM; |
503 | /* Fallthrough */ | ||
504 | default: | 503 | default: |
505 | return Unspecified; | 504 | /* Fallthrough to attempt LANMAN authentication next */ |
505 | break; | ||
506 | } | 506 | } |
507 | case CIFS_NEGFLAVOR_LANMAN: | 507 | case CIFS_NEGFLAVOR_LANMAN: |
508 | switch (requested) { | 508 | switch (requested) { |
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index eba0efde66d7..edccb5252462 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
@@ -687,6 +687,10 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) | |||
687 | else | 687 | else |
688 | return -EIO; | 688 | return -EIO; |
689 | 689 | ||
690 | /* no need to send SMB logoff if uid already closed due to reconnect */ | ||
691 | if (ses->need_reconnect) | ||
692 | goto smb2_session_already_dead; | ||
693 | |||
690 | rc = small_smb2_init(SMB2_LOGOFF, NULL, (void **) &req); | 694 | rc = small_smb2_init(SMB2_LOGOFF, NULL, (void **) &req); |
691 | if (rc) | 695 | if (rc) |
692 | return rc; | 696 | return rc; |
@@ -701,6 +705,8 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) | |||
701 | * No tcon so can't do | 705 | * No tcon so can't do |
702 | * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]); | 706 | * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]); |
703 | */ | 707 | */ |
708 | |||
709 | smb2_session_already_dead: | ||
704 | return rc; | 710 | return rc; |
705 | } | 711 | } |
706 | 712 | ||
diff --git a/fs/cifs/smbfsctl.h b/fs/cifs/smbfsctl.h index d952ee48f4dc..a4b2391fe66e 100644 --- a/fs/cifs/smbfsctl.h +++ b/fs/cifs/smbfsctl.h | |||
@@ -97,9 +97,23 @@ | |||
97 | #define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */ | 97 | #define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */ |
98 | #define FSCTL_SRV_READ_HASH 0x001441BB /* BB add struct */ | 98 | #define FSCTL_SRV_READ_HASH 0x001441BB /* BB add struct */ |
99 | 99 | ||
100 | /* See FSCC 2.1.2.5 */ | ||
100 | #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003 | 101 | #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003 |
101 | #define IO_REPARSE_TAG_HSM 0xC0000004 | 102 | #define IO_REPARSE_TAG_HSM 0xC0000004 |
102 | #define IO_REPARSE_TAG_SIS 0x80000007 | 103 | #define IO_REPARSE_TAG_SIS 0x80000007 |
104 | #define IO_REPARSE_TAG_HSM2 0x80000006 | ||
105 | #define IO_REPARSE_TAG_DRIVER_EXTENDER 0x80000005 | ||
106 | /* Used by the DFS filter. See MS-DFSC */ | ||
107 | #define IO_REPARSE_TAG_DFS 0x8000000A | ||
108 | /* Used by the DFS filter See MS-DFSC */ | ||
109 | #define IO_REPARSE_TAG_DFSR 0x80000012 | ||
110 | #define IO_REPARSE_TAG_FILTER_MANAGER 0x8000000B | ||
111 | /* See section MS-FSCC 2.1.2.4 */ | ||
112 | #define IO_REPARSE_TAG_SYMLINK 0xA000000C | ||
113 | #define IO_REPARSE_TAG_DEDUP 0x80000013 | ||
114 | #define IO_REPARSE_APPXSTREAM 0xC0000014 | ||
115 | /* NFS symlinks, Win 8/SMB3 and later */ | ||
116 | #define IO_REPARSE_TAG_NFS 0x80000014 | ||
103 | 117 | ||
104 | /* fsctl flags */ | 118 | /* fsctl flags */ |
105 | /* If Flags is set to this value, the request is an FSCTL not ioctl request */ | 119 | /* If Flags is set to this value, the request is an FSCTL not ioctl request */ |
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 6fdcb1b4a106..800b938e4061 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -410,8 +410,13 @@ static int | |||
410 | wait_for_free_request(struct TCP_Server_Info *server, const int timeout, | 410 | wait_for_free_request(struct TCP_Server_Info *server, const int timeout, |
411 | const int optype) | 411 | const int optype) |
412 | { | 412 | { |
413 | return wait_for_free_credits(server, timeout, | 413 | int *val; |
414 | server->ops->get_credits_field(server, optype)); | 414 | |
415 | val = server->ops->get_credits_field(server, optype); | ||
416 | /* Since an echo is already inflight, no need to wait to send another */ | ||
417 | if (*val <= 0 && optype == CIFS_ECHO_OP) | ||
418 | return -EAGAIN; | ||
419 | return wait_for_free_credits(server, timeout, val); | ||
415 | } | 420 | } |
416 | 421 | ||
417 | static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf, | 422 | static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf, |