smb2pdu.c (df0a8a19251007b6930d4b5ef57cf54e5c1e9c30) smb2pdu.c (e8aee4f4d2e3048704474d82f2563edfe2d2fe5b)
1// SPDX-License-Identifier: LGPL-2.1
2/*
3 *
4 * Copyright (C) International Business Machines Corp., 2009, 2013
5 * Etersoft, 2012
6 * Author(s): Steve French (sfrench@us.ibm.com)
7 * Pavel Shilovsky (pshilovsky@samba.org) 2012
8 *

--- 729 unchanged lines hidden (view full) ---

738 neg_context_count = 2;
739 cifs_server_unlock(pserver);
740
741 build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt);
742 *total_len += sizeof(struct smb2_posix_neg_context);
743 pneg_ctxt += sizeof(struct smb2_posix_neg_context);
744 neg_context_count++;
745
1// SPDX-License-Identifier: LGPL-2.1
2/*
3 *
4 * Copyright (C) International Business Machines Corp., 2009, 2013
5 * Etersoft, 2012
6 * Author(s): Steve French (sfrench@us.ibm.com)
7 * Pavel Shilovsky (pshilovsky@samba.org) 2012
8 *

--- 729 unchanged lines hidden (view full) ---

738 neg_context_count = 2;
739 cifs_server_unlock(pserver);
740
741 build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt);
742 *total_len += sizeof(struct smb2_posix_neg_context);
743 pneg_ctxt += sizeof(struct smb2_posix_neg_context);
744 neg_context_count++;
745
746 if (server->compress_algorithm) {
746 if (server->compression.requested) {
747 build_compression_ctxt((struct smb2_compression_capabilities_context *)
748 pneg_ctxt);
749 ctxt_len = ALIGN(sizeof(struct smb2_compression_capabilities_context), 8);
750 *total_len += ctxt_len;
751 pneg_ctxt += ctxt_len;
752 neg_context_count++;
753 }
754

--- 31 unchanged lines hidden (view full) ---

786 if (ctxt->HashAlgorithms != SMB2_PREAUTH_INTEGRITY_SHA512)
787 pr_warn_once("unknown SMB3 hash algorithm\n");
788}
789
790static void decode_compress_ctx(struct TCP_Server_Info *server,
791 struct smb2_compression_capabilities_context *ctxt)
792{
793 unsigned int len = le16_to_cpu(ctxt->DataLength);
747 build_compression_ctxt((struct smb2_compression_capabilities_context *)
748 pneg_ctxt);
749 ctxt_len = ALIGN(sizeof(struct smb2_compression_capabilities_context), 8);
750 *total_len += ctxt_len;
751 pneg_ctxt += ctxt_len;
752 neg_context_count++;
753 }
754

--- 31 unchanged lines hidden (view full) ---

786 if (ctxt->HashAlgorithms != SMB2_PREAUTH_INTEGRITY_SHA512)
787 pr_warn_once("unknown SMB3 hash algorithm\n");
788}
789
790static void decode_compress_ctx(struct TCP_Server_Info *server,
791 struct smb2_compression_capabilities_context *ctxt)
792{
793 unsigned int len = le16_to_cpu(ctxt->DataLength);
794 __le16 alg;
794
795
796 server->compression.enabled = false;
797
795 /*
796 * Caller checked that DataLength remains within SMB boundary. We still
797 * need to confirm that one CompressionAlgorithms member is accounted
798 * for.
799 */
800 if (len < 10) {
801 pr_warn_once("server sent bad compression cntxt\n");
802 return;
803 }
798 /*
799 * Caller checked that DataLength remains within SMB boundary. We still
800 * need to confirm that one CompressionAlgorithms member is accounted
801 * for.
802 */
803 if (len < 10) {
804 pr_warn_once("server sent bad compression cntxt\n");
805 return;
806 }
807
804 if (le16_to_cpu(ctxt->CompressionAlgorithmCount) != 1) {
808 if (le16_to_cpu(ctxt->CompressionAlgorithmCount) != 1) {
805 pr_warn_once("Invalid SMB3 compress algorithm count\n");
809 pr_warn_once("invalid SMB3 compress algorithm count\n");
806 return;
807 }
810 return;
811 }
808 if (le16_to_cpu(ctxt->CompressionAlgorithms[0]) > 3) {
809 pr_warn_once("unknown compression algorithm\n");
812
813 alg = ctxt->CompressionAlgorithms[0];
814
815 /* 'NONE' (0) compressor type is never negotiated */
816 if (alg == 0 || le16_to_cpu(alg) > 3) {
817 pr_warn_once("invalid compression algorithm '%u'\n", alg);
810 return;
811 }
818 return;
819 }
812 server->compress_algorithm = ctxt->CompressionAlgorithms[0];
820
821 server->compression.alg = alg;
822 server->compression.enabled = true;
813}
814
815static int decode_encrypt_ctx(struct TCP_Server_Info *server,
816 struct smb2_encryption_neg_context *ctxt)
817{
818 unsigned int len = le16_to_cpu(ctxt->DataLength);
819
820 cifs_dbg(FYI, "decode SMB3.11 encryption neg context of len %d\n", len);

--- 5304 unchanged lines hidden ---
823}
824
825static int decode_encrypt_ctx(struct TCP_Server_Info *server,
826 struct smb2_encryption_neg_context *ctxt)
827{
828 unsigned int len = le16_to_cpu(ctxt->DataLength);
829
830 cifs_dbg(FYI, "decode SMB3.11 encryption neg context of len %d\n", len);

--- 5304 unchanged lines hidden ---