Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1982c344 authored by Steve French's avatar Steve French
Browse files

[CIFS] Ensure that cifs multiplex ids do not collide.

parent a59c6586
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -147,6 +147,7 @@ struct TCP_Server_Info {
	/* (returned on Negotiate */
	/* (returned on Negotiate */
	int capabilities; /* allow selective disabling of caps by smb sess */
	int capabilities; /* allow selective disabling of caps by smb sess */
	__u16 timeZone;
	__u16 timeZone;
	__u16 CurrentMid;         /* multiplex id - rotating counter */
	char cryptKey[CIFS_CRYPTO_KEY_SIZE];
	char cryptKey[CIFS_CRYPTO_KEY_SIZE];
	char workstation_RFC1001_name[16]; /* 16th byte is always zero */
	char workstation_RFC1001_name[16]; /* 16th byte is always zero */
	__u32 sequence_number; /* needed for CIFS PDU signature */
	__u32 sequence_number; /* needed for CIFS PDU signature */
+9 −10
Original line number Original line Diff line number Diff line
@@ -1961,18 +1961,17 @@ struct data_blob {
	perhaps add a CreateDevice - to create Pipes and other special .inodes
	perhaps add a CreateDevice - to create Pipes and other special .inodes
	Also note POSIX open flags
	Also note POSIX open flags
	2) Close - to return the last write time to do cache across close more safely
	2) Close - to return the last write time to do cache across close more safely
	3) PosixQFSInfo - to return statfs info
	3) FindFirst return unique inode number - what about resume key, two 
	4) FindFirst return unique inode number - what about resume key, two forms short (matches readdir) and full (enough info to cache inodes)
	forms short (matches readdir) and full (enough info to cache inodes)
	5) Mkdir - set mode
	4) Mkdir - set mode
	
	
	And under consideration: 
	And under consideration: 
	6) FindClose2 (return nanosecond timestamp ??)
	5) FindClose2 (return nanosecond timestamp ??)
	7) Use nanosecond timestamps throughout all time fields if 
	6) Use nanosecond timestamps throughout all time fields if 
	   corresponding attribute flag is set
	   corresponding attribute flag is set
	8) sendfile - handle based copy
	7) sendfile - handle based copy
	9) Direct i/o
	8) Direct i/o
	10) "POSIX ACL" support
	9) Misc fcntls?
	11) Misc fcntls?
	
	
	what about fixing 64 bit alignment
	what about fixing 64 bit alignment
	
	
@@ -2028,7 +2027,7 @@ struct data_blob {
	
	
 */
 */


/* xsymlink is a symlink format that can be used
/* xsymlink is a symlink format (used by MacOS) that can be used
   to save symlink info in a regular file when 
   to save symlink info in a regular file when 
   mounted to operating systems that do not
   mounted to operating systems that do not
   support the cifs Unix extensions or EAs (for xattr
   support the cifs Unix extensions or EAs (for xattr
+3 −3
Original line number Original line Diff line number Diff line
@@ -61,9 +61,9 @@ extern int decode_negTokenInit(unsigned char *security_blob, int length,
extern int cifs_inet_pton(int, char * source, void *dst);
extern int cifs_inet_pton(int, char * source, void *dst);
extern int map_smb_to_linux_error(struct smb_hdr *smb);
extern int map_smb_to_linux_error(struct smb_hdr *smb);
extern void header_assemble(struct smb_hdr *, char /* command */ ,
extern void header_assemble(struct smb_hdr *, char /* command */ ,
			const struct cifsTconInfo *, int /* specifies length
			    const struct cifsTconInfo *, int /* length of
			    of fixed section (word count) in two byte units */
			    fixed section (word count) in two byte units */);
			);
extern __u16 GetNextMid(struct TCP_Server_Info *server);
extern struct oplock_q_entry * AllocOplockQEntry(struct inode *, u16, 
extern struct oplock_q_entry * AllocOplockQEntry(struct inode *, u16, 
						 struct cifsTconInfo *);
						 struct cifsTconInfo *);
extern void DeleteOplockQEntry(struct oplock_q_entry *);
extern void DeleteOplockQEntry(struct oplock_q_entry *);
+14 −9
Original line number Original line Diff line number Diff line
@@ -330,7 +330,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
		      (void **) &pSMB, (void **) &pSMBr);
		      (void **) &pSMB, (void **) &pSMBr);
	if (rc)
	if (rc)
		return rc;
		return rc;

	pSMB->hdr.Mid = GetNextMid(server);
	pSMB->hdr.Flags2 |= SMBFLG2_UNICODE;
	pSMB->hdr.Flags2 |= SMBFLG2_UNICODE;
	if (extended_security)
	if (extended_security)
		pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC;
		pSMB->hdr.Flags2 |= SMBFLG2_EXT_SEC;
@@ -415,15 +415,14 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses)
			if(server->secMode & SECMODE_SIGN_REQUIRED)
			if(server->secMode & SECMODE_SIGN_REQUIRED)
				cERROR(1,
				cERROR(1,
				 ("Server requires /proc/fs/cifs/PacketSigningEnabled"));
				 ("Server requires /proc/fs/cifs/PacketSigningEnabled"));
			server->secMode &= ~(SECMODE_SIGN_ENABLED | 
			server->secMode &= ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED);
							SECMODE_SIGN_REQUIRED);
		} else if(sign_CIFS_PDUs == 1) {
		} else if(sign_CIFS_PDUs == 1) {
			if((server->secMode & SECMODE_SIGN_REQUIRED) == 0)
			if((server->secMode & SECMODE_SIGN_REQUIRED) == 0)
				server->secMode &= ~(SECMODE_SIGN_ENABLED |
				server->secMode &= ~(SECMODE_SIGN_ENABLED | SECMODE_SIGN_REQUIRED);
							 SECMODE_SIGN_REQUIRED);
		}
		}
				
				
	}
	}
	
	cifs_buf_release(pSMB);
	cifs_buf_release(pSMB);
	return rc;
	return rc;
}
}
@@ -519,6 +518,8 @@ CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses)
	smb_buffer_response = (struct smb_hdr *)pSMB; /* BB removeme BB */
	smb_buffer_response = (struct smb_hdr *)pSMB; /* BB removeme BB */
	
	
	if(ses->server) {
	if(ses->server) {
		pSMB->hdr.Mid = GetNextMid(ses->server);

		if(ses->server->secMode & 
		if(ses->server->secMode & 
		   (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
		   (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
			pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
			pSMB->hdr.Flags2 |= SMBFLG2_SECURITY_SIGNATURE;
@@ -2519,10 +2520,11 @@ CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
	rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);
			 (struct smb_hdr *) pSMBr, &bytes_returned, 0);


	if (rc) {/* BB add logic to retry regular search if Unix search 
	if (rc) {/* BB add logic to retry regular search if Unix search rejected unexpectedly by server */
			rejected unexpectedly by server */
		/* BB Add code to handle unsupported level rc */
		/* BB Add code to handle unsupported level rc */
		cFYI(1, ("Error in FindFirst = %d", rc));
		cFYI(1, ("Error in FindFirst = %d", rc));

		if (pSMB)
			cifs_buf_release(pSMB);
			cifs_buf_release(pSMB);


		/* BB eventually could optimize out free and realloc of buf */
		/* BB eventually could optimize out free and realloc of buf */
@@ -2858,6 +2860,9 @@ CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
	if (rc)
	if (rc)
		return rc;
		return rc;
	
	
	/* server pointer checked in called function, 
	but should never be null here anyway */
	pSMB->hdr.Mid = GetNextMid(ses->server);
	pSMB->hdr.Tid = ses->ipc_tid;
	pSMB->hdr.Tid = ses->ipc_tid;
	pSMB->hdr.Uid = ses->Suid;
	pSMB->hdr.Uid = ses->Suid;
	if (ses->capabilities & CAP_STATUS32) {
	if (ses->capabilities & CAP_STATUS32) {
+9 −0
Original line number Original line Diff line number Diff line
@@ -1857,6 +1857,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
	header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX,
	header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX,
			NULL /* no tCon exists yet */ , 13 /* wct */ );
			NULL /* no tCon exists yet */ , 13 /* wct */ );


	smb_buffer->Mid = GetNextMid(ses->server);
	pSMB->req_no_secext.AndXCommand = 0xFF;
	pSMB->req_no_secext.AndXCommand = 0xFF;
	pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
	pSMB->req_no_secext.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
	pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
	pSMB->req_no_secext.MaxMpxCount = cpu_to_le16(ses->server->maxReq);
@@ -2132,6 +2133,8 @@ CIFSSpnegoSessSetup(unsigned int xid, struct cifsSesInfo *ses,
	/* send SMBsessionSetup here */
	/* send SMBsessionSetup here */
	header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX,
	header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX,
			NULL /* no tCon exists yet */ , 12 /* wct */ );
			NULL /* no tCon exists yet */ , 12 /* wct */ );

	smb_buffer->Mid = GetNextMid(ses->server);
	pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
	pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
	pSMB->req.AndXCommand = 0xFF;
	pSMB->req.AndXCommand = 0xFF;
	pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
	pSMB->req.MaxBufferSize = cpu_to_le16(ses->server->maxBuf);
@@ -2398,6 +2401,8 @@ CIFSNTLMSSPNegotiateSessSetup(unsigned int xid,
	/* send SMBsessionSetup here */
	/* send SMBsessionSetup here */
	header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX,
	header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX,
			NULL /* no tCon exists yet */ , 12 /* wct */ );
			NULL /* no tCon exists yet */ , 12 /* wct */ );

	smb_buffer->Mid = GetNextMid(ses->server);
	pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
	pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
	pSMB->req.hdr.Flags |= (SMBFLG_CASELESS | SMBFLG_CANONICAL_PATH_FORMAT);
	pSMB->req.hdr.Flags |= (SMBFLG_CASELESS | SMBFLG_CANONICAL_PATH_FORMAT);


@@ -2740,6 +2745,8 @@ CIFSNTLMSSPAuthSessSetup(unsigned int xid, struct cifsSesInfo *ses,
	/* send SMBsessionSetup here */
	/* send SMBsessionSetup here */
	header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX,
	header_assemble(smb_buffer, SMB_COM_SESSION_SETUP_ANDX,
			NULL /* no tCon exists yet */ , 12 /* wct */ );
			NULL /* no tCon exists yet */ , 12 /* wct */ );

	smb_buffer->Mid = GetNextMid(ses->server);
	pSMB->req.hdr.Flags |= (SMBFLG_CASELESS | SMBFLG_CANONICAL_PATH_FORMAT);
	pSMB->req.hdr.Flags |= (SMBFLG_CASELESS | SMBFLG_CANONICAL_PATH_FORMAT);
	pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
	pSMB->req.hdr.Flags2 |= SMBFLG2_EXT_SEC;
	pSMB->req.AndXCommand = 0xFF;
	pSMB->req.AndXCommand = 0xFF;
@@ -3111,6 +3118,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,


	header_assemble(smb_buffer, SMB_COM_TREE_CONNECT_ANDX,
	header_assemble(smb_buffer, SMB_COM_TREE_CONNECT_ANDX,
			NULL /*no tid */ , 4 /*wct */ );
			NULL /*no tid */ , 4 /*wct */ );

	smb_buffer->Mid = GetNextMid(ses->server);
	smb_buffer->Uid = ses->Suid;
	smb_buffer->Uid = ses->Suid;
	pSMB = (TCONX_REQ *) smb_buffer;
	pSMB = (TCONX_REQ *) smb_buffer;
	pSMBr = (TCONX_RSP *) smb_buffer_response;
	pSMBr = (TCONX_RSP *) smb_buffer_response;
Loading