]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Allow parsing vers=3.1 on cifs mount
authorSteve French <steve.french@primarydata.com>
Thu, 18 Dec 2014 04:52:58 +0000 (22:52 -0600)
committerSteve French <smfrench@gmail.com>
Tue, 7 Apr 2015 03:53:41 +0000 (22:53 -0500)
Parses and recognizes "vers=3.1" on cifs mount and allows sending
0310 as new CIFS/SMB3 dialect. Subsequent patches will add
the new negotiate contexts and updated session setup

Reviewed-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: Steve French <smfrench@gmail.com>
fs/cifs/Kconfig
fs/cifs/cifsglob.h
fs/cifs/connect.c
fs/cifs/smb2ops.c
fs/cifs/smb2pdu.c
fs/cifs/smb2pdu.h

index a2172f3f69e318915f092885da0b4d49755d33f1..7f16051861d3731c673212e76bff8abc9f45668d 100644 (file)
@@ -192,6 +192,15 @@ config CIFS_SMB2
          options are also slightly simpler (compared to CIFS) due
          to protocol improvements.
 
+config CIFS_SMB31
+       bool "SMB3.1 network file system support (Experimental)"
+       depends on CIFS_SMB2 && INET
+
+       help
+         This enables experimental support for the newest, SMB3.1, dialect.
+         This dialect includes improved security negotiation features.
+         If unsure, say N
+
 config CIFS_FSCACHE
          bool "Provide CIFS client caching support"
          depends on CIFS=m && FSCACHE || CIFS=y && FSCACHE=y
index 22b289a3b1c4d3e12727cc0a005456fa9b295a00..25b6372ca6d771a6fb822da6881be3318b0e6d1c 100644 (file)
@@ -171,6 +171,10 @@ enum smb_version {
        Smb_21,
        Smb_30,
        Smb_302,
+#ifdef CONFIG_CIFS_SMB31
+       Smb_31,
+#endif /* SMB31 */
+       Smb_version_err
 };
 
 struct mid_q_entry;
@@ -1617,4 +1621,7 @@ extern struct smb_version_values smb30_values;
 #define SMB302_VERSION_STRING  "3.02"
 /*extern struct smb_version_operations smb302_operations;*/ /* not needed yet */
 extern struct smb_version_values smb302_values;
+#define SMB31_VERSION_STRING   "3.1"
+/*extern struct smb_version_operations smb31_operations;*/ /* not needed yet */
+extern struct smb_version_values smb31_values;
 #endif /* _CIFS_GLOB_H */
index 480cf9c81d505b8351dd76eee0f012110c3f2b9c..d92fe8839e5e29c55e3376af8ef7cfb24ebb9cb8 100644 (file)
@@ -280,6 +280,10 @@ static const match_table_t cifs_smb_version_tokens = {
        { Smb_21, SMB21_VERSION_STRING },
        { Smb_30, SMB30_VERSION_STRING },
        { Smb_302, SMB302_VERSION_STRING },
+#ifdef CONFIG_CIFS_SMB31
+       { Smb_31, SMB31_VERSION_STRING },
+#endif /* SMB31 */
+       { Smb_version_err, NULL }
 };
 
 static int ip_connect(struct TCP_Server_Info *server);
@@ -1134,6 +1138,12 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol)
                vol->ops = &smb30_operations; /* currently identical with 3.0 */
                vol->vals = &smb302_values;
                break;
+#ifdef CONFIG_CIFS_SMB31
+       case Smb_31:
+               vol->ops = &smb30_operations; /* currently identical with 3.0 */
+               vol->vals = &smb31_values;
+               break;
+#endif /* SMB31 */
 #endif
        default:
                cifs_dbg(VFS, "Unknown vers= option specified: %s\n", value);
index eab05e1aa587424863d6914eb351da9fdcf17437..9b6ce02e9edeee4ce7867bfb183315e5ca7d9163 100644 (file)
@@ -1714,3 +1714,25 @@ struct smb_version_values smb302_values = {
        .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
        .create_lease_size = sizeof(struct create_lease_v2),
 };
+
+#ifdef CONFIG_CIFS_SMB31
+struct smb_version_values smb31_values = {
+       .version_string = SMB31_VERSION_STRING,
+       .protocol_id = SMB31_PROT_ID,
+       .req_capabilities = SMB2_GLOBAL_CAP_DFS | SMB2_GLOBAL_CAP_LEASING | SMB2_GLOBAL_CAP_LARGE_MTU,
+       .large_lock_type = 0,
+       .exclusive_lock_type = SMB2_LOCKFLAG_EXCLUSIVE_LOCK,
+       .shared_lock_type = SMB2_LOCKFLAG_SHARED_LOCK,
+       .unlock_lock_type = SMB2_LOCKFLAG_UNLOCK,
+       .header_size = sizeof(struct smb2_hdr),
+       .max_header_size = MAX_SMB2_HDR_SIZE,
+       .read_rsp_size = sizeof(struct smb2_read_rsp) - 1,
+       .lock_cmd = SMB2_LOCK,
+       .cap_unix = 0,
+       .cap_nt_find = SMB2_NT_FIND,
+       .cap_large_files = SMB2_LARGE_FILES,
+       .signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
+       .signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
+       .create_lease_size = sizeof(struct create_lease_v2),
+};
+#endif /* SMB31 */
index 65cd7a84c8bc3206033a917fe9d98fc939cbe1af..3d48ad440f7f034b107c7899ab3b044432db29cc 100644 (file)
@@ -393,6 +393,10 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
                cifs_dbg(FYI, "negotiated smb3.0 dialect\n");
        else if (rsp->DialectRevision == cpu_to_le16(SMB302_PROT_ID))
                cifs_dbg(FYI, "negotiated smb3.02 dialect\n");
+#ifdef CONFIG_CIFS_SMB31
+       else if (rsp->DialectRevision == cpu_to_le16(SMB31_PROT_ID))
+               cifs_dbg(FYI, "negotiated smb3.1 dialect\n");
+#endif /* SMB31 */
        else {
                cifs_dbg(VFS, "Illegal dialect returned by server %d\n",
                         le16_to_cpu(rsp->DialectRevision));
index 70867d54fb8bf485cb5ff4dcb3049f67ca86cb45..e6dd51ed31ab0c02e226d55c868fa63ed4a28466 100644 (file)
@@ -191,7 +191,10 @@ struct smb2_negotiate_req {
        __le16 Reserved;        /* MBZ */
        __le32 Capabilities;
        __u8   ClientGUID[SMB2_CLIENT_GUID_SIZE];
-       __le64 ClientStartTime; /* MBZ */
+       /* In SMB3.02 and earlier next three were MBZ le64 ClientStartTime */
+       __le32 NegotiateContextOffset; /* SMB3.1 only. MBZ earlier */
+       __le16 NegotiateContextCount;  /* SMB3.1 only. MBZ earlier */
+       __le16 Reserved2;
        __le16 Dialects[1]; /* One dialect (vers=) at a time for now */
 } __packed;
 
@@ -200,6 +203,7 @@ struct smb2_negotiate_req {
 #define SMB21_PROT_ID 0x0210
 #define SMB30_PROT_ID 0x0300
 #define SMB302_PROT_ID 0x0302
+#define SMB31_PROT_ID 0x0311
 #define BAD_PROT_ID   0xFFFF
 
 /* SecurityMode flags */
@@ -222,7 +226,7 @@ struct smb2_negotiate_rsp {
        __le16 StructureSize;   /* Must be 65 */
        __le16 SecurityMode;
        __le16 DialectRevision;
-       __le16 Reserved;        /* MBZ */
+       __le16 NegotiateContextCount;   /* Prior to SMB3.1 was Reserved & MBZ */
        __u8   ServerGUID[16];
        __le32 Capabilities;
        __le32 MaxTransactSize;
@@ -232,7 +236,7 @@ struct smb2_negotiate_rsp {
        __le64 ServerStartTime;
        __le16 SecurityBufferOffset;
        __le16 SecurityBufferLength;
-       __le32 Reserved2;       /* may be any value, ignore */
+       __le32 NegotiateContextOffset;  /* Pre:SMB3.1 was reserved/ignored */
        __u8   Buffer[1];       /* variable length GSS security buffer */
 } __packed;