smb3: print warning once if posix context returned on open
authorSteve French <stfrench@microsoft.com>
Thu, 6 Feb 2020 23:31:56 +0000 (17:31 -0600)
committerSteve French <stfrench@microsoft.com>
Thu, 6 Feb 2020 23:31:56 +0000 (17:31 -0600)
SMB3.1.1 POSIX Context processing is not complete yet - so print warning
(once) if server returns it on open.

Signed-off-by: Steve French <stfrench@microsoft.com>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
fs/cifs/smb2pdu.c
fs/cifs/smb2pdu.h

index 47cce0bd1afea3286ab84beee6d36538607f6bf6..1234f9ccab0302b5df63a320f12bf7f397be26c9 100644 (file)
@@ -1939,6 +1939,16 @@ parse_query_id_ctxt(struct create_context *cc, struct smb2_file_all_info *buf)
        buf->IndexNumber = pdisk_id->DiskFileId;
 }
 
+static void
+parse_posix_ctxt(struct create_context *cc, struct smb_posix_info *pposix_inf)
+{
+       /* struct smb_posix_info *ppinf = (struct smb_posix_info *)cc; */
+
+       /* TODO: Need to add parsing for the context and return */
+       printk_once(KERN_WARNING
+                   "SMB3 3.11 POSIX response context not completed yet\n");
+}
+
 void
 smb2_parse_contexts(struct TCP_Server_Info *server,
                       struct smb2_create_rsp *rsp,
@@ -1950,6 +1960,9 @@ smb2_parse_contexts(struct TCP_Server_Info *server,
        unsigned int next;
        unsigned int remaining;
        char *name;
+       const char smb3_create_tag_posix[] = {0x93, 0xAD, 0x25, 0x50, 0x9C,
+                                       0xB4, 0x11, 0xE7, 0xB4, 0x23, 0x83,
+                                       0xDE, 0x96, 0x8B, 0xCD, 0x7C};
 
        *oplock = 0;
        data_offset = (char *)rsp + le32_to_cpu(rsp->CreateContextsOffset);
@@ -1969,6 +1982,15 @@ smb2_parse_contexts(struct TCP_Server_Info *server,
                else if (buf && (le16_to_cpu(cc->NameLength) == 4) &&
                    strncmp(name, SMB2_CREATE_QUERY_ON_DISK_ID, 4) == 0)
                        parse_query_id_ctxt(cc, buf);
+               else if ((le16_to_cpu(cc->NameLength) == 16)) {
+                       if (memcmp(name, smb3_create_tag_posix, 16) == 0)
+                               parse_posix_ctxt(cc, NULL);
+               }
+               /* else {
+                       cifs_dbg(FYI, "Context not matched with len %d\n",
+                               le16_to_cpu(cc->NameLength));
+                       cifs_dump_mem("Cctxt name: ", name, 4);
+               } */
 
                next = le32_to_cpu(cc->Next);
                if (!next)
index 4c43dbd1e08962055e82cce658915c6a1c704722..ca2123d7f1998e09096a8718d02ef36d75688892 100644 (file)
@@ -1595,4 +1595,12 @@ struct smb2_file_network_open_info {
 
 extern char smb2_padding[7];
 
+/* equivalent of the contents of SMB3.1.1 POSIX open context response */
+struct smb_posix_info {
+       __le32 nlink;
+       __le32 reparse_tag;
+       __le32 mode;
+       kuid_t  uid;
+       kuid_t  gid;
+};
 #endif                         /* _SMB2PDU_H */