Skip to contentSkip to conversation

cifs: remove unnecessary locking around sequence_number

PATCH In review Jeff Layton 4 participants 13 messages Nov 22, 2010 – Dec 1, 2010 9 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: remove unnecessary locking around sequence_number

The server->sequence_number is already protected by the srv_mutex. The GlobalMid_lock is unneeded here.

---
 fs/cifs/cifsencrypt.c |    6 ++----
 fs/cifs/cifsglob.h    |    2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)
fs/cifs/cifsencrypt.c +2 -4
index f856732..66f3d50 100644
@@ -72,6 +72,7 @@ static int cifs_calculate_signature(const struct smb_hdr *cifs_pdu,
 	return 0;
 }
 
+/* must be called with server->srv_mutex held */
 int cifs_sign_smb(struct smb_hdr *cifs_pdu, struct TCP_Server_Info *server,
 		  __u32 *pexpected_response_sequence_number)
 {
@@ -84,14 +85,12 @@ int cifs_sign_smb(struct smb_hdr *cifs_pdu, struct TCP_Server_Info *server,
 	if ((cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) == 0)
 		return rc;
 
-	spin_lock(&GlobalMid_Lock);
 	cifs_pdu->Signature.Sequence.SequenceNumber =
 			cpu_to_le32(server->sequence_number);
 	cifs_pdu->Signature.Sequence.Reserved = 0;
 
 	*pexpected_response_sequence_number = server->sequence_number++;
 	server->sequence_number++;
-	spin_unlock(&GlobalMid_Lock);
 
 	rc = cifs_calculate_signature(cifs_pdu, server, smb_signature);
 	if (rc)
@@ -149,6 +148,7 @@ static int cifs_calc_signature2(const struct kvec *iov, int n_vec,
 	return rc;
 }
 
+/* must be called with server->srv_mutex held */
 int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *server,
 		   __u32 *pexpected_response_sequence_number)
 {
@@ -162,14 +162,12 @@ int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *server,
 	if ((cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) == 0)
 		return rc;
 
-	spin_lock(&GlobalMid_Lock);
 	cifs_pdu->Signature.Sequence.SequenceNumber =
 				cpu_to_le32(server->sequence_number);
 	cifs_pdu->Signature.Sequence.Reserved = 0;
 
 	*pexpected_response_sequence_number = server->sequence_number++;
 	server->sequence_number++;
-	spin_unlock(&GlobalMid_Lock);
 
 	rc = cifs_calc_signature2(iov, n_vec, server, smb_signature);
 	if (rc)
fs/cifs/cifsglob.h +1 -1
index a8d9f32..bba731c 100644
@@ -200,7 +200,7 @@ struct TCP_Server_Info {
 	char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlm, ntlmv2 etc */
 	/* 16th byte of RFC1001 workstation name is always null */
 	char workstation_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
-	__u32 sequence_number; /* needed for CIFS PDU signature */
+	__u32 sequence_number; /* for signing, protected by srv_mutex */
 	struct session_key session_key;
 	unsigned long lstrp; /* when we got last response from this server */
 	u16 dialect; /* dialect index that server chose */
Signature · 1 line
1.7.3.2

A message that is not in the archive (sent off-list or not yet received): 1290457863-10804-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

PATCH 1/1 cifs: remove unused CIFSSMBNotify

...and the global variables that only it references.

---
 fs/cifs/cifsfs.c    |    4 ---
 fs/cifs/cifsglob.h  |    5 ---
 fs/cifs/cifsproto.h |    4 ---
 fs/cifs/cifssmb.c   |   73 ---------------------------------------------------
 4 files changed, 0 insertions(+), 86 deletions(-)
fs/cifs/cifsfs.c +0 -4
index 0ab2e2f..041d7c3 100644
@@ -911,10 +911,6 @@ init_cifs(void)
 	int rc = 0;
 	cifs_proc_init();
 	INIT_LIST_HEAD(&cifs_tcp_ses_list);
-#ifdef CONFIG_CIFS_EXPERIMENTAL
-	INIT_LIST_HEAD(&GlobalDnotifyReqList);
-	INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
-#endif
 /*
  *  Initialize Global counters
  */
fs/cifs/cifsglob.h +0 -5
index bba731c..b4c2524 100644
@@ -735,11 +735,6 @@ GLOBAL_EXTERN spinlock_t		cifs_tcp_ses_lock;
  */
 GLOBAL_EXTERN spinlock_t	cifs_file_list_lock;
 
-/* Outstanding dir notify requests */
-GLOBAL_EXTERN struct list_head GlobalDnotifyReqList;
-/* DirNotify response queue */
-GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q;
-
 /*
  * Global transaction id (XID) information
  */
fs/cifs/cifsproto.h +0 -4
index 6ed59af..7b0ca3a 100644
@@ -383,10 +383,6 @@ extern int CIFSSMBCopy(int xid,
 			const char *toName, const int flags,
 			const struct nls_table *nls_codepage,
 			int remap_special_chars);
-extern int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
-			const int notify_subdirs, const __u16 netfid,
-			__u32 filter, struct file *file, int multishot,
-			const struct nls_table *nls_codepage);
 extern ssize_t CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
 			const unsigned char *searchName,
 			const unsigned char *ea_name, char *EAData,
fs/cifs/cifssmb.c +0 -73

79 lines not on this page · raw message

Signature · 1 line
1.7.3.2

A message that is not in the archive (sent off-list or not yet received): 1290457863-10804-2-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

Reviewed-by
#4 lore raw

Re: [PATCH] cifs: remove unused CIFSSMBNotify

Quoted 143 lines · Jeff Layton

...and the global variables that only it references.

---
 fs/cifs/cifsfs.c    |    4 ---
 fs/cifs/cifsglob.h  |    5 ---
 fs/cifs/cifsproto.h |    4 ---
 fs/cifs/cifssmb.c   |   73 ---------------------------------------------------

 4 files changed, 0 insertions(+), 86 deletions(-)
fs/cifs/cifsfs.c +0 -4
index 0ab2e2f..041d7c3 100644
@@ -911,10 +911,6 @@ init_cifs(void)
        int rc = 0;
        cifs_proc_init();
        INIT_LIST_HEAD(&cifs_tcp_ses_list);
-#ifdef CONFIG_CIFS_EXPERIMENTAL
-       INIT_LIST_HEAD(&GlobalDnotifyReqList);
-       INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
-#endif
  /*
  *  Initialize Global counters
  */
fs/cifs/cifsglob.h +0 -5
index bba731c..b4c2524 100644
@@ -735,11 +735,6 @@ GLOBAL_EXTERN spinlock_t           cifs_tcp_ses_lock;
  */
  GLOBAL_EXTERN spinlock_t       cifs_file_list_lock;
 
-/* Outstanding dir notify requests */
-GLOBAL_EXTERN struct list_head GlobalDnotifyReqList;
-/* DirNotify response queue */
-GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q;
-
  /*
  * Global transaction id (XID) information
  */
fs/cifs/cifsproto.h +0 -4
index 6ed59af..7b0ca3a 100644
@@ -383,10 +383,6 @@ extern int CIFSSMBCopy(int xid,
                        const char *toName, const int flags,
                        const struct nls_table *nls_codepage,
                        int remap_special_chars);
-extern int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
-                       const int notify_subdirs, const __u16 netfid,
-                       __u32 filter, struct file *file, int multishot,
-                       const struct nls_table *nls_codepage);
  extern ssize_t CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
                        const unsigned char *searchName,
                        const unsigned char *ea_name, char *EAData,
fs/cifs/cifssmb.c +0 -74
index 2f2632b..0ef7c3a 100644
@@ -5381,79 +5381,6 @@ setPermsRetry:
        return rc;
  }
 
-int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
-                 const int notify_subdirs, const __u16 netfid,
-                 __u32 filter, struct file *pfile, int multishot,
-                 const struct nls_table *nls_codepage)
-{
-       int rc = 0;
-       struct smb_com_transaction_change_notify_req *pSMB = NULL;
-       struct smb_com_ntransaction_change_notify_rsp *pSMBr = NULL;
-       struct dir_notify_req *dnotify_req;
-       int bytes_returned;
-
-       cFYI(1, "In CIFSSMBNotify for file handle %d", (int)netfid);
-       rc = smb_init(SMB_COM_NT_TRANSACT, 23, tcon, (void **) &pSMB,
-                     (void **) &pSMBr);
-       if (rc)
-               return rc;
-
-       pSMB->TotalParameterCount = 0 ;
-       pSMB->TotalDataCount = 0;
-       pSMB->MaxParameterCount = cpu_to_le32(2);
-       /* BB find exact data count max from sess structure BB */
-       pSMB->MaxDataCount = 0; /* same in little endian or be */
-/* BB VERIFY verify which is correct for above BB */
-       pSMB->MaxDataCount = cpu_to_le32((tcon->ses->server->maxBuf -
-                                            MAX_CIFS_HDR_SIZE) & 0xFFFFFF00);
-
-       pSMB->MaxSetupCount = 4;
-       pSMB->Reserved = 0;
-       pSMB->ParameterOffset = 0;
-       pSMB->DataCount = 0;
-       pSMB->DataOffset = 0;
-       pSMB->SetupCount = 4; /* single byte does not need le conversion */
-       pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_NOTIFY_CHANGE);
-       pSMB->ParameterCount = pSMB->TotalParameterCount;
-       if (notify_subdirs)
-               pSMB->WatchTree = 1; /* one byte - no le conversion needed */
-       pSMB->Reserved2 = 0;
-       pSMB->CompletionFilter = cpu_to_le32(filter);
-       pSMB->Fid = netfid; /* file handle always le */
-       pSMB->ByteCount = 0;
-
-       rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
-                        (struct smb_hdr *)pSMBr, &bytes_returned,
-                        CIFS_ASYNC_OP);
-       if (rc) {
-               cFYI(1, "Error in Notify = %d", rc);
-       } else {
-               /* Add file to outstanding requests */
-               /* BB change to kmem cache alloc */
-               dnotify_req = kmalloc(
-                                               sizeof(struct dir_notify_req),
-                                                GFP_KERNEL);
-               if (dnotify_req) {
-                       dnotify_req->Pid = pSMB->hdr.Pid;
-                       dnotify_req->PidHigh = pSMB->hdr.PidHigh;
-                       dnotify_req->Mid = pSMB->hdr.Mid;
-                       dnotify_req->Tid = pSMB->hdr.Tid;
-                       dnotify_req->Uid = pSMB->hdr.Uid;
-                       dnotify_req->netfid = netfid;
-                       dnotify_req->pfile = pfile;
-                       dnotify_req->filter = filter;
-                       dnotify_req->multishot = multishot;
-                       spin_lock(&GlobalMid_Lock);
-                       list_add_tail(&dnotify_req->lhead,
-                                       &GlobalDnotifyReqList);
-                       spin_unlock(&GlobalMid_Lock);
-               } else
-                       rc = -ENOMEM;
-       }
-       cifs_buf_release(pSMB);
-       return rc;
-}
-
  #ifdef CONFIG_CIFS_XATTR
  /*
  * Do a path-based QUERY_ALL_EAS call and parse the result. This is a common
--

1.7.3.2

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Do not think this function has been used for a long time.

A message that is not in the archive (sent off-list or not yet received): AANLkTimqQSDWs9kCmXpuWGQTLkwBbM1WA-XTsPgH5G8R-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw

Re: [PATCH] cifs: remove unused CIFSSMBNotify

Quoted 152 lines · On Wed, 1 Dec 2010 07:55:54 -0600 Shirish Pargaonkar…
Quoted 143 lines · Jeff Layton

...and the global variables that only it references.

---
 fs/cifs/cifsfs.c    |    4 ---
 fs/cifs/cifsglob.h  |    5 ---
 fs/cifs/cifsproto.h |    4 ---
 fs/cifs/cifssmb.c   |   73 ---------------------------------------------------

 4 files changed, 0 insertions(+), 86 deletions(-)
fs/cifs/cifsfs.c +0 -4
index 0ab2e2f..041d7c3 100644
@@ -911,10 +911,6 @@ init_cifs(void)
        int rc = 0;
        cifs_proc_init();
        INIT_LIST_HEAD(&cifs_tcp_ses_list);
-#ifdef CONFIG_CIFS_EXPERIMENTAL
-       INIT_LIST_HEAD(&GlobalDnotifyReqList);
-       INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
-#endif
  /*
  *  Initialize Global counters
  */
fs/cifs/cifsglob.h +0 -5
index bba731c..b4c2524 100644
@@ -735,11 +735,6 @@ GLOBAL_EXTERN spinlock_t           cifs_tcp_ses_lock;
  */
  GLOBAL_EXTERN spinlock_t       cifs_file_list_lock;
 
-/* Outstanding dir notify requests */
-GLOBAL_EXTERN struct list_head GlobalDnotifyReqList;
-/* DirNotify response queue */
-GLOBAL_EXTERN struct list_head GlobalDnotifyRsp_Q;
-
  /*
  * Global transaction id (XID) information
  */
fs/cifs/cifsproto.h +0 -4
index 6ed59af..7b0ca3a 100644
@@ -383,10 +383,6 @@ extern int CIFSSMBCopy(int xid,
                        const char *toName, const int flags,
                        const struct nls_table *nls_codepage,
                        int remap_special_chars);
-extern int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
-                       const int notify_subdirs, const __u16 netfid,
-                       __u32 filter, struct file *file, int multishot,
-                       const struct nls_table *nls_codepage);
  extern ssize_t CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
                        const unsigned char *searchName,
                        const unsigned char *ea_name, char *EAData,
fs/cifs/cifssmb.c +0 -74
index 2f2632b..0ef7c3a 100644
@@ -5381,79 +5381,6 @@ setPermsRetry:
        return rc;
  }
 
-int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon,
-                 const int notify_subdirs, const __u16 netfid,
-                 __u32 filter, struct file *pfile, int multishot,
-                 const struct nls_table *nls_codepage)
-{
-       int rc = 0;
-       struct smb_com_transaction_change_notify_req *pSMB = NULL;
-       struct smb_com_ntransaction_change_notify_rsp *pSMBr = NULL;
-       struct dir_notify_req *dnotify_req;
-       int bytes_returned;
-
-       cFYI(1, "In CIFSSMBNotify for file handle %d", (int)netfid);
-       rc = smb_init(SMB_COM_NT_TRANSACT, 23, tcon, (void **) &pSMB,
-                     (void **) &pSMBr);
-       if (rc)
-               return rc;
-
-       pSMB->TotalParameterCount = 0 ;
-       pSMB->TotalDataCount = 0;
-       pSMB->MaxParameterCount = cpu_to_le32(2);
-       /* BB find exact data count max from sess structure BB */
-       pSMB->MaxDataCount = 0; /* same in little endian or be */
-/* BB VERIFY verify which is correct for above BB */
-       pSMB->MaxDataCount = cpu_to_le32((tcon->ses->server->maxBuf -
-                                            MAX_CIFS_HDR_SIZE) & 0xFFFFFF00);
-
-       pSMB->MaxSetupCount = 4;
-       pSMB->Reserved = 0;
-       pSMB->ParameterOffset = 0;
-       pSMB->DataCount = 0;
-       pSMB->DataOffset = 0;
-       pSMB->SetupCount = 4; /* single byte does not need le conversion */
-       pSMB->SubCommand = cpu_to_le16(NT_TRANSACT_NOTIFY_CHANGE);
-       pSMB->ParameterCount = pSMB->TotalParameterCount;
-       if (notify_subdirs)
-               pSMB->WatchTree = 1; /* one byte - no le conversion needed */
-       pSMB->Reserved2 = 0;
-       pSMB->CompletionFilter = cpu_to_le32(filter);
-       pSMB->Fid = netfid; /* file handle always le */
-       pSMB->ByteCount = 0;
-
-       rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB,
-                        (struct smb_hdr *)pSMBr, &bytes_returned,
-                        CIFS_ASYNC_OP);
-       if (rc) {
-               cFYI(1, "Error in Notify = %d", rc);
-       } else {
-               /* Add file to outstanding requests */
-               /* BB change to kmem cache alloc */
-               dnotify_req = kmalloc(
-                                               sizeof(struct dir_notify_req),
-                                                GFP_KERNEL);
-               if (dnotify_req) {
-                       dnotify_req->Pid = pSMB->hdr.Pid;
-                       dnotify_req->PidHigh = pSMB->hdr.PidHigh;
-                       dnotify_req->Mid = pSMB->hdr.Mid;
-                       dnotify_req->Tid = pSMB->hdr.Tid;
-                       dnotify_req->Uid = pSMB->hdr.Uid;
-                       dnotify_req->netfid = netfid;
-                       dnotify_req->pfile = pfile;
-                       dnotify_req->filter = filter;
-                       dnotify_req->multishot = multishot;
-                       spin_lock(&GlobalMid_Lock);
-                       list_add_tail(&dnotify_req->lhead,
-                                       &GlobalDnotifyReqList);
-                       spin_unlock(&GlobalMid_Lock);
-               } else
-                       rc = -ENOMEM;
-       }
-       cifs_buf_release(pSMB);
-       return rc;
-}
-
  #ifdef CONFIG_CIFS_XATTR
  /*
  * Do a path-based QUERY_ALL_EAS call and parse the result. This is a common
--

1.7.3.2

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Do not think this function has been used for a long time.

Quoted 1 line

...not since the dir_notify stuff was ripped out of the VFS a couple of years ago.

Signature · 1 line
Jeff Layton <[email protected]>
#7 lore raw

PATCH 1/1 cifs: remove Local_System_Name

In reply to a message not in the archive

...this string is zeroed out and nothing ever changes it.

---
 fs/cifs/cifsfs.c   |    1 -
 fs/cifs/cifsglob.h |    2 --
 fs/cifs/connect.c  |   23 ++++++++++-------------
 3 files changed, 10 insertions(+), 16 deletions(-)
fs/cifs/cifsfs.c +0 -1
index 041d7c3..57a7386 100644
@@ -931,7 +931,6 @@ init_cifs(void)
 	GlobalCurrentXid = 0;
 	GlobalTotalActiveXid = 0;
 	GlobalMaxActiveXid = 0;
-	memset(Local_System_Name, 0, 15);
 	spin_lock_init(&cifs_tcp_ses_lock);
 	spin_lock_init(&cifs_file_list_lock);
 	spin_lock_init(&GlobalMid_Lock);
fs/cifs/cifsglob.h +0 -2
index b4c2524..2ffa029 100644
@@ -743,8 +743,6 @@ GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */
 GLOBAL_EXTERN unsigned int GlobalMaxActiveXid;	/* prot by GlobalMid_Sem */
 GLOBAL_EXTERN spinlock_t GlobalMid_Lock;  /* protects above & list operations */
 					  /* on midQ entries */
-GLOBAL_EXTERN char Local_System_Name[15];
-
 /*
  *  Global counters, updated atomically
  */
fs/cifs/connect.c +10 -13
index 251a17c..7758120 100644
@@ -806,23 +806,20 @@ cifs_parse_mount_options(char *options, const char *devname,
 	short int override_gid = -1;
 	bool uid_specified = false;
 	bool gid_specified = false;
+	char *nodename = utsname()->nodename;
 
 	separator[0] = ',';
 	separator[1] = 0;
 
-	if (Local_System_Name[0] != 0)
-		memcpy(vol->source_rfc1001_name, Local_System_Name, 15);
-	else {
-		char *nodename = utsname()->nodename;
-		int n = strnlen(nodename, 15);
-		memset(vol->source_rfc1001_name, 0x20, 15);
-		for (i = 0; i < n; i++) {
-			/* does not have to be perfect mapping since field is
-			informational, only used for servers that do not support
-			port 445 and it can be overridden at mount time */
-			vol->source_rfc1001_name[i] = toupper(nodename[i]);
-		}
-	}
+	/*
+	 * does not have to be perfect mapping since field is
+	 * informational, only used for servers that do not support
+	 * port 445 and it can be overridden at mount time
+	 */
+	memset(vol->source_rfc1001_name, 0x20, 15);
+	for (i = 0; i < strnlen(nodename, 15); i++)
+		vol->source_rfc1001_name[i] = toupper(nodename[i]);
+
 	vol->source_rfc1001_name[15] = 0;
 	/* null target name indicates to use *SMBSERVR default called name
 	   if we end up sending RFC1001 session initialize */
Signature · 1 line
1.7.3.2

A message that is not in the archive (sent off-list or not yet received): 1290457863-10804-3-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#9 lore raw

Re: [PATCH] cifs: remove Local_System_Name

Quoted 75 lines · Jeff Layton

...this string is zeroed out and nothing ever changes it.

---
 fs/cifs/cifsfs.c   |    1 - fs/cifs/cifsglob.h |    2 -- fs/cifs/connect.c  |   23 ++++++++++-------------

 3 files changed, 10 insertions(+), 16 deletions(-)
fs/cifs/cifsfs.c +0 -1
index 041d7c3..57a7386 100644
@@ -931,7 +931,6 @@ init_cifs(void)
        GlobalCurrentXid = 0;
        GlobalTotalActiveXid = 0;
        GlobalMaxActiveXid = 0;
-       memset(Local_System_Name, 0, 15);
        spin_lock_init(&cifs_tcp_ses_lock);
        spin_lock_init(&cifs_file_list_lock);
        spin_lock_init(&GlobalMid_Lock);
fs/cifs/cifsglob.h +0 -0
index b4c2524..2ffa029 100644
@@ -743,8 +743,6 @@ GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */

 GLOBAL_EXTERN unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */ GLOBAL_EXTERN spinlock_t GlobalMid_Lock;  /* protects above & list operations */ /* on midQ entries */

fs/cifs/cifsglob.h +0 -2
-GLOBAL_EXTERN char Local_System_Name[15];
-

 /*
 *  Global counters, updated atomically
 */

fs/cifs/connect.c +10 -13
index 251a17c..7758120 100644
@@ -806,23 +806,20 @@ cifs_parse_mount_options(char *options, const char *devname,
        short int override_gid = -1;
        bool uid_specified = false;
        bool gid_specified = false;
+       char *nodename = utsname()->nodename;
 
        separator[0] = ',';
        separator[1] = 0;
 
-       if (Local_System_Name[0] != 0)
-               memcpy(vol->source_rfc1001_name, Local_System_Name, 15);
-       else {
-               char *nodename = utsname()->nodename;
-               int n = strnlen(nodename, 15);
-               memset(vol->source_rfc1001_name, 0x20, 15);
-               for (i = 0; i < n; i++) {
-                       /* does not have to be perfect mapping since field is
-                       informational, only used for servers that do not support
-                       port 445 and it can be overridden at mount time */
-                       vol->source_rfc1001_name[i] = toupper(nodename[i]);
-               }
-       }
+       /*
+        * does not have to be perfect mapping since field is
+        * informational, only used for servers that do not support
+        * port 445 and it can be overridden at mount time
+        */
+       memset(vol->source_rfc1001_name, 0x20, 15);
+       for (i = 0; i < strnlen(nodename, 15); i++)
+               vol->source_rfc1001_name[i] = toupper(nodename[i]);
+
        vol->source_rfc1001_name[15] = 0;
        /* null target name indicates to use *SMBSERVR default called name

          if we end up sending RFC1001 session initialize */ --
1.7.3.2

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

We probably should define 15 or add an explanation for 15.

A message that is not in the archive (sent off-list or not yet received): AANLkTinNLbq1c57TvejaR8hvBxJTD62T6kP1hLOpGegX-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#11 lore raw

Re: [PATCH] cifs: remove Local_System_Name

Quoted 76 lines · On Wed, 1 Dec 2010 08:10:03 -0600 Shirish Pargaonkar…
Quoted 75 lines · Jeff Layton

...this string is zeroed out and nothing ever changes it.

---
 fs/cifs/cifsfs.c   |    1 - fs/cifs/cifsglob.h |    2 -- fs/cifs/connect.c  |   23 ++++++++++-------------

 3 files changed, 10 insertions(+), 16 deletions(-)
fs/cifs/cifsfs.c +0 -1
index 041d7c3..57a7386 100644
@@ -931,7 +931,6 @@ init_cifs(void)
        GlobalCurrentXid = 0;
        GlobalTotalActiveXid = 0;
        GlobalMaxActiveXid = 0;
-       memset(Local_System_Name, 0, 15);
        spin_lock_init(&cifs_tcp_ses_lock);
        spin_lock_init(&cifs_file_list_lock);
        spin_lock_init(&GlobalMid_Lock);
fs/cifs/cifsglob.h +0 -0
index b4c2524..2ffa029 100644
@@ -743,8 +743,6 @@ GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */

 GLOBAL_EXTERN unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */ GLOBAL_EXTERN spinlock_t GlobalMid_Lock;  /* protects above & list operations */ /* on midQ entries */

fs/cifs/cifsglob.h +0 -2
-GLOBAL_EXTERN char Local_System_Name[15];
-

 /*
 *  Global counters, updated atomically
 */

fs/cifs/connect.c +10 -13
index 251a17c..7758120 100644
@@ -806,23 +806,20 @@ cifs_parse_mount_options(char *options, const char *devname,
        short int override_gid = -1;
        bool uid_specified = false;
        bool gid_specified = false;
+       char *nodename = utsname()->nodename;
 
        separator[0] = ',';
        separator[1] = 0;
 
-       if (Local_System_Name[0] != 0)
-               memcpy(vol->source_rfc1001_name, Local_System_Name, 15);
-       else {
-               char *nodename = utsname()->nodename;
-               int n = strnlen(nodename, 15);
-               memset(vol->source_rfc1001_name, 0x20, 15);
-               for (i = 0; i < n; i++) {
-                       /* does not have to be perfect mapping since field is
-                       informational, only used for servers that do not support
-                       port 445 and it can be overridden at mount time */
-                       vol->source_rfc1001_name[i] = toupper(nodename[i]);
-               }
-       }
+       /*
+        * does not have to be perfect mapping since field is
+        * informational, only used for servers that do not support
+        * port 445 and it can be overridden at mount time
+        */
+       memset(vol->source_rfc1001_name, 0x20, 15);
+       for (i = 0; i < strnlen(nodename, 15); i++)
+               vol->source_rfc1001_name[i] = toupper(nodename[i]);
+
        vol->source_rfc1001_name[15] = 0;
        /* null target name indicates to use *SMBSERVR default called name

          if we end up sending RFC1001 session initialize */ --
1.7.3.2

Quoted 7 lines
Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

We probably should define 15 or add an explanation for 15.

Good point. I guess that should probably be RFC1001_NAME_LEN ? There are a number of other places that use hardcoded "15" or "16" values around this as well. Any objection to me fixing that in a separate cleanup patch?

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20101201092731.7aeded31-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

Reviewed-by
#13 lore raw

Re: [PATCH] cifs: remove Local_System_Name

Quoted 87 lines · Jeff Layton
Quoted 76 lines · On Wed, 1 Dec 2010 08:10:03 -0600 Shirish Pargaonkar…
Quoted 75 lines · Jeff Layton

...this string is zeroed out and nothing ever changes it.

---
 fs/cifs/cifsfs.c   |    1 - fs/cifs/cifsglob.h |    2 -- fs/cifs/connect.c  |   23 ++++++++++-------------

 3 files changed, 10 insertions(+), 16 deletions(-)
fs/cifs/cifsfs.c +0 -1
index 041d7c3..57a7386 100644
@@ -931,7 +931,6 @@ init_cifs(void)
        GlobalCurrentXid = 0;
        GlobalTotalActiveXid = 0;
        GlobalMaxActiveXid = 0;
-       memset(Local_System_Name, 0, 15);
        spin_lock_init(&cifs_tcp_ses_lock);
        spin_lock_init(&cifs_file_list_lock);
        spin_lock_init(&GlobalMid_Lock);
fs/cifs/cifsglob.h +0 -0
index b4c2524..2ffa029 100644
@@ -743,8 +743,6 @@ GLOBAL_EXTERN unsigned int GlobalTotalActiveXid; /* prot by GlobalMid_Sem */

 GLOBAL_EXTERN unsigned int GlobalMaxActiveXid; /* prot by GlobalMid_Sem */ GLOBAL_EXTERN spinlock_t GlobalMid_Lock;  /* protects above & list operations */ /* on midQ entries */

fs/cifs/cifsglob.h +0 -2
-GLOBAL_EXTERN char Local_System_Name[15];
-

 /*
 *  Global counters, updated atomically
 */

fs/cifs/connect.c +10 -13
index 251a17c..7758120 100644
@@ -806,23 +806,20 @@ cifs_parse_mount_options(char *options, const char *devname,
        short int override_gid = -1;
        bool uid_specified = false;
        bool gid_specified = false;
+       char *nodename = utsname()->nodename;
 
        separator[0] = ',';
        separator[1] = 0;
 
-       if (Local_System_Name[0] != 0)
-               memcpy(vol->source_rfc1001_name, Local_System_Name, 15);
-       else {
-               char *nodename = utsname()->nodename;
-               int n = strnlen(nodename, 15);
-               memset(vol->source_rfc1001_name, 0x20, 15);
-               for (i = 0; i < n; i++) {
-                       /* does not have to be perfect mapping since field is
-                       informational, only used for servers that do not support
-                       port 445 and it can be overridden at mount time */
-                       vol->source_rfc1001_name[i] = toupper(nodename[i]);
-               }
-       }
+       /*
+        * does not have to be perfect mapping since field is
+        * informational, only used for servers that do not support
+        * port 445 and it can be overridden at mount time
+        */
+       memset(vol->source_rfc1001_name, 0x20, 15);
+       for (i = 0; i < strnlen(nodename, 15); i++)
+               vol->source_rfc1001_name[i] = toupper(nodename[i]);
+
        vol->source_rfc1001_name[15] = 0;
        /* null target name indicates to use *SMBSERVR default called name

          if we end up sending RFC1001 session initialize */ --
1.7.3.2

Quoted 7 lines
Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

We probably should define 15 or add an explanation for 15.

Quoted 8 lines

Good point. I guess that should probably be RFC1001_NAME_LEN ? There are a number of other places that use hardcoded "15" or "16" values around this as well. Any objection to me fixing that in a separate cleanup patch?

--
Jeff Layton <[email protected]>

RFC1001_NAME_LEN sounds apt.
No objection.

#14 lore raw

PATCH 1/1 cifs: replace some hardcoded values with preprocessor constants

In reply to a message not in the archive

A number of places that deal with RFC1001/1002 negotiations have bare "15" or "16" values. Replace them with RFC_1001_NAME_LEN and RFC_1001_NAME_LEN_WITH_NULL.

The patch also cleans up some checkpatch warnings for code surrounding the changes. This should apply cleanly on top of the patch to remove Local_System_Name.

---
 fs/cifs/connect.c |   37 +++++++++++++++++++------------------
 1 files changed, 19 insertions(+), 18 deletions(-)
fs/cifs/connect.c +19 -18
index 5d48e09..a96324b 100644
@@ -64,8 +64,8 @@ struct smb_vol {
 	char *UNC;
 	char *UNCip;
 	char *iocharset;  /* local code page for mapping to and from Unicode */
-	char source_rfc1001_name[16]; /* netbios name of client */
-	char target_rfc1001_name[16]; /* netbios name of server for Win9x/ME */
+	char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
+	char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
 	uid_t cred_uid;
 	uid_t linux_uid;
 	gid_t linux_gid;
@@ -816,11 +816,11 @@ cifs_parse_mount_options(char *options, const char *devname,
 	 * informational, only used for servers that do not support
 	 * port 445 and it can be overridden at mount time
 	 */
-	memset(vol->source_rfc1001_name, 0x20, 15);
-	for (i = 0; i < strnlen(nodename, 15); i++)
+	memset(vol->source_rfc1001_name, 0x20, RFC1001_NAME_LEN);
+	for (i = 0; i < strnlen(nodename, RFC1001_NAME_LEN); i++)
 		vol->source_rfc1001_name[i] = toupper(nodename[i]);
 
-	vol->source_rfc1001_name[15] = 0;
+	vol->source_rfc1001_name[RFC1001_NAME_LEN] = 0;
 	/* null target name indicates to use *SMBSERVR default called name
 	   if we end up sending RFC1001 session initialize */
 	vol->target_rfc1001_name[0] = 0;
@@ -1165,22 +1165,22 @@ cifs_parse_mount_options(char *options, const char *devname,
 			if (!value || !*value || (*value == ' ')) {
 				cFYI(1, "invalid (empty) netbiosname");
 			} else {
-				memset(vol->source_rfc1001_name, 0x20, 15);
-				for (i = 0; i < 15; i++) {
-				/* BB are there cases in which a comma can be
-				valid in this workstation netbios name (and need
-				special handling)? */
-
-				/* We do not uppercase netbiosname for user */
+				memset(vol->source_rfc1001_name, 0x20,
+					RFC1001_NAME_LEN);
+				/*
+				 * FIXME: are there cases in which a comma can
+				 * be valid in workstation netbios name (and
+				 * need special handling)?
+				 */
+				for (i = 0; i < RFC1001_NAME_LEN; i++) {
+					/* don't ucase netbiosname for user */
 					if (value[i] == 0)
 						break;
-					else
-						vol->source_rfc1001_name[i] =
-								value[i];
+					vol->source_rfc1001_name[i] = value[i];
 				}
 				/* The string has 16th byte zero still from
 				set at top of the function  */
-				if ((i == 15) && (value[i] != 0))
+				if (i == RFC1001_NAME_LEN && value[i] != 0)
 					printk(KERN_WARNING "CIFS: netbiosname"
 						" longer than 15 truncated.\n");
 			}
@@ -1190,7 +1190,8 @@ cifs_parse_mount_options(char *options, const char *devname,
 				cFYI(1, "empty server netbiosname specified");
 			} else {
 				/* last byte, type, is 0x20 for servr type */
-				memset(vol->target_rfc1001_name, 0x20, 16);
+				memset(vol->target_rfc1001_name, 0x20,
+					RFC1001_NAME_LEN_WITH_NULL);
 
 				for (i = 0; i < 15; i++) {
 				/* BB are there cases in which a comma can be
@@ -1207,7 +1208,7 @@ cifs_parse_mount_options(char *options, const char *devname,
 				}
 				/* The string has 16th byte zero still from
 				   set at top of the function  */
-				if ((i == 15) && (value[i] != 0))
+				if (i == RFC1001_NAME_LEN && value[i] != 0)
 					printk(KERN_WARNING "CIFS: server net"
 					"biosname longer than 15 truncated.\n");
 			}
Signature · 1 line
1.7.3.2

A message that is not in the archive (sent off-list or not yet received): 1291214985-31607-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#16 lore raw

Re: [PATCH] cifs: replace some hardcoded values with preprocessor constants

Quoted 91 lines · Jeff Layton

A number of places that deal with RFC1001/1002 negotiations have bare "15" or "16" values. Replace them with RFC_1001_NAME_LEN and RFC_1001_NAME_LEN_WITH_NULL.

The patch also cleans up some checkpatch warnings for code surrounding the changes. This should apply cleanly on top of the patch to remove Local_System_Name.

---
 fs/cifs/connect.c |   37 +++++++++++++++++++------------------

 1 files changed, 19 insertions(+), 18 deletions(-)
fs/cifs/connect.c +0 -0
index 5d48e09..a96324b 100644
@@ -64,8 +64,8 @@ struct smb_vol {
        char *UNC;
        char *UNCip;

       char *iocharset;  /* local code page for mapping to and from Unicode */
-       char source_rfc1001_name[16]; /* netbios name of client */
-       char target_rfc1001_name[16]; /* netbios name of server for Win9x/ME */
+       char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
+       char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */ uid_t cred_uid;
       uid_t linux_uid;
       gid_t linux_gid;

fs/cifs/connect.c +3 -3
@@ -816,11 +816,11 @@ cifs_parse_mount_options(char *options, const char *devname,
         * informational, only used for servers that do not support
         * port 445 and it can be overridden at mount time
         */
-       memset(vol->source_rfc1001_name, 0x20, 15);
-       for (i = 0; i < strnlen(nodename, 15); i++)
+       memset(vol->source_rfc1001_name, 0x20, RFC1001_NAME_LEN);
+       for (i = 0; i < strnlen(nodename, RFC1001_NAME_LEN); i++)
                vol->source_rfc1001_name[i] = toupper(nodename[i]);
 
-       vol->source_rfc1001_name[15] = 0;
+       vol->source_rfc1001_name[RFC1001_NAME_LEN] = 0;
        /* null target name indicates to use *SMBSERVR default called name

          if we end up sending RFC1001 session initialize */ vol->target_rfc1001_name[0] = 0;

fs/cifs/connect.c +10 -10
@@ -1165,22 +1165,22 @@ cifs_parse_mount_options(char *options, const char *devname,
                        if (!value || !*value || (*value == ' ')) {
                                cFYI(1, "invalid (empty) netbiosname");
                        } else {
-                               memset(vol->source_rfc1001_name, 0x20, 15);
-                               for (i = 0; i < 15; i++) {
-                               /* BB are there cases in which a comma can be
-                               valid in this workstation netbios name (and need
-                               special handling)? */
-
-                               /* We do not uppercase netbiosname for user */
+                               memset(vol->source_rfc1001_name, 0x20,
+                                       RFC1001_NAME_LEN);
+                               /*
+                                * FIXME: are there cases in which a comma can
+                                * be valid in workstation netbios name (and
+                                * need special handling)?
+                                */
+                               for (i = 0; i < RFC1001_NAME_LEN; i++) {
+                                       /* don't ucase netbiosname for user */
                                        if (value[i] == 0)
                                                break;
-                                       else
-                                               vol->source_rfc1001_name[i] =
-                                                               value[i];
+                                       vol->source_rfc1001_name[i] = value[i];
                                }
                                /* The string has 16th byte zero still from

                               set at top of the function  */
-                               if ((i == 15) && (value[i] != 0))
+                               if (i == RFC1001_NAME_LEN && value[i] != 0) printk(KERN_WARNING "CIFS: netbiosname" " longer than 15 truncated.\n"); }

fs/cifs/connect.c +2 -1
@@ -1190,7 +1190,8 @@ cifs_parse_mount_options(char *options, const char *devname,
                                cFYI(1, "empty server netbiosname specified");
                        } else {
                                /* last byte, type, is 0x20 for servr type */
-                               memset(vol->target_rfc1001_name, 0x20, 16);
+                               memset(vol->target_rfc1001_name, 0x20,
+                                       RFC1001_NAME_LEN_WITH_NULL);
 
                                for (i = 0; i < 15; i++) {
                                /* BB are there cases in which a comma can be
@@ -1207,7 +1208,7 @@ cifs_parse_mount_options(char *options, const char *devname,
                                }
                                /* The string has 16th byte zero still from
Quoted 10 lines

                                  set at top of the function  */
-                               if ((i == 15) && (value[i] != 0))
+                               if (i == RFC1001_NAME_LEN && value[i] != 0) printk(KERN_WARNING "CIFS: server net" "biosname longer than 15 truncated.\n"); }
--
1.7.3.2

Jeff, I do not see where RFC1001_NAME_LEN_WITH_NULL and RFC1000_NAME_LEN are defined.

A message that is not in the archive (sent off-list or not yet received): AANLkTi=ntwuoeEoBk5RfEFbu_3M4EaRu=wSqAhR1RcEc-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#18 lore raw

Re: [PATCH] cifs: replace some hardcoded values with preprocessor constants

Quoted 97 lines · On Wed, 1 Dec 2010 09:03:32 -0600 Shirish Pargaonkar…
Quoted 96 lines · Jeff Layton

A number of places that deal with RFC1001/1002 negotiations have bare "15" or "16" values. Replace them with RFC_1001_NAME_LEN and RFC_1001_NAME_LEN_WITH_NULL.

The patch also cleans up some checkpatch warnings for code surrounding the changes. This should apply cleanly on top of the patch to remove Local_System_Name.

---
 fs/cifs/connect.c |   37 +++++++++++++++++++------------------

 1 files changed, 19 insertions(+), 18 deletions(-)
fs/cifs/connect.c +0 -0
index 5d48e09..a96324b 100644
@@ -64,8 +64,8 @@ struct smb_vol {
        char *UNC;
        char *UNCip;

       char *iocharset;  /* local code page for mapping to and from Unicode */
-       char source_rfc1001_name[16]; /* netbios name of client */
-       char target_rfc1001_name[16]; /* netbios name of server for Win9x/ME */
+       char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
+       char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */ uid_t cred_uid;
       uid_t linux_uid;
       gid_t linux_gid;

fs/cifs/connect.c +3 -3
@@ -816,11 +816,11 @@ cifs_parse_mount_options(char *options, const char *devname,
         * informational, only used for servers that do not support
         * port 445 and it can be overridden at mount time
         */
-       memset(vol->source_rfc1001_name, 0x20, 15);
-       for (i = 0; i < strnlen(nodename, 15); i++)
+       memset(vol->source_rfc1001_name, 0x20, RFC1001_NAME_LEN);
+       for (i = 0; i < strnlen(nodename, RFC1001_NAME_LEN); i++)
                vol->source_rfc1001_name[i] = toupper(nodename[i]);
 
-       vol->source_rfc1001_name[15] = 0;
+       vol->source_rfc1001_name[RFC1001_NAME_LEN] = 0;
        /* null target name indicates to use *SMBSERVR default called name

          if we end up sending RFC1001 session initialize */ vol->target_rfc1001_name[0] = 0;

fs/cifs/connect.c +10 -10
@@ -1165,22 +1165,22 @@ cifs_parse_mount_options(char *options, const char *devname,
                        if (!value || !*value || (*value == ' ')) {
                                cFYI(1, "invalid (empty) netbiosname");
                        } else {
-                               memset(vol->source_rfc1001_name, 0x20, 15);
-                               for (i = 0; i < 15; i++) {
-                               /* BB are there cases in which a comma can be
-                               valid in this workstation netbios name (and need
-                               special handling)? */
-
-                               /* We do not uppercase netbiosname for user */
+                               memset(vol->source_rfc1001_name, 0x20,
+                                       RFC1001_NAME_LEN);
+                               /*
+                                * FIXME: are there cases in which a comma can
+                                * be valid in workstation netbios name (and
+                                * need special handling)?
+                                */
+                               for (i = 0; i < RFC1001_NAME_LEN; i++) {
+                                       /* don't ucase netbiosname for user */
                                        if (value[i] == 0)
                                                break;
-                                       else
-                                               vol->source_rfc1001_name[i] =
-                                                               value[i];
+                                       vol->source_rfc1001_name[i] = value[i];
                                }
                                /* The string has 16th byte zero still from

                               set at top of the function  */
-                               if ((i == 15) && (value[i] != 0))
+                               if (i == RFC1001_NAME_LEN && value[i] != 0) printk(KERN_WARNING "CIFS: netbiosname" " longer than 15 truncated.\n"); }

fs/cifs/connect.c +2 -1
@@ -1190,7 +1190,8 @@ cifs_parse_mount_options(char *options, const char *devname,
                                cFYI(1, "empty server netbiosname specified");
                        } else {
                                /* last byte, type, is 0x20 for servr type */
-                               memset(vol->target_rfc1001_name, 0x20, 16);
+                               memset(vol->target_rfc1001_name, 0x20,
+                                       RFC1001_NAME_LEN_WITH_NULL);
 
                                for (i = 0; i < 15; i++) {
                                /* BB are there cases in which a comma can be
@@ -1207,7 +1208,7 @@ cifs_parse_mount_options(char *options, const char *devname,
                                }
                                /* The string has 16th byte zero still from

                                  set at top of the function  */
-                               if ((i == 15) && (value[i] != 0))
+                               if (i == RFC1001_NAME_LEN && value[i] != 0) printk(KERN_WARNING "CIFS: server net" "biosname longer than 15 truncated.\n");

Quoted 8 lines
Quoted 5 lines

                       }
--
1.7.3.2

Jeff, I do not see where RFC1001_NAME_LEN_WITH_NULL and RFC1000_NAME_LEN are defined.

In cifsglob.h...

There's a tool for this sort of thing called "cscope":

http://cscope.sourceforge.net/

Cheers,

Signature · 1 line
Jeff Layton <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20101201100748.507bd4ce-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org

Reviewed-by
#20 lore raw

Re: [PATCH] cifs: replace some hardcoded values with preprocessor constants

Quoted 111 lines · Jeff Layton
Quoted 97 lines · On Wed, 1 Dec 2010 09:03:32 -0600 Shirish Pargaonkar…
Quoted 96 lines · Jeff Layton

A number of places that deal with RFC1001/1002 negotiations have bare "15" or "16" values. Replace them with RFC_1001_NAME_LEN and RFC_1001_NAME_LEN_WITH_NULL.

The patch also cleans up some checkpatch warnings for code surrounding the changes. This should apply cleanly on top of the patch to remove Local_System_Name.

---
 fs/cifs/connect.c |   37 +++++++++++++++++++------------------

 1 files changed, 19 insertions(+), 18 deletions(-)
fs/cifs/connect.c +0 -0
index 5d48e09..a96324b 100644
@@ -64,8 +64,8 @@ struct smb_vol {
        char *UNC;
        char *UNCip;

       char *iocharset;  /* local code page for mapping to and from Unicode */
-       char source_rfc1001_name[16]; /* netbios name of client */
-       char target_rfc1001_name[16]; /* netbios name of server for Win9x/ME */
+       char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
+       char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */ uid_t cred_uid;
       uid_t linux_uid;
       gid_t linux_gid;

fs/cifs/connect.c +3 -3
@@ -816,11 +816,11 @@ cifs_parse_mount_options(char *options, const char *devname,
         * informational, only used for servers that do not support
         * port 445 and it can be overridden at mount time
         */
-       memset(vol->source_rfc1001_name, 0x20, 15);
-       for (i = 0; i < strnlen(nodename, 15); i++)
+       memset(vol->source_rfc1001_name, 0x20, RFC1001_NAME_LEN);
+       for (i = 0; i < strnlen(nodename, RFC1001_NAME_LEN); i++)
                vol->source_rfc1001_name[i] = toupper(nodename[i]);
 
-       vol->source_rfc1001_name[15] = 0;
+       vol->source_rfc1001_name[RFC1001_NAME_LEN] = 0;
        /* null target name indicates to use *SMBSERVR default called name

          if we end up sending RFC1001 session initialize */ vol->target_rfc1001_name[0] = 0;

fs/cifs/connect.c +10 -10
@@ -1165,22 +1165,22 @@ cifs_parse_mount_options(char *options, const char *devname,
                        if (!value || !*value || (*value == ' ')) {
                                cFYI(1, "invalid (empty) netbiosname");
                        } else {
-                               memset(vol->source_rfc1001_name, 0x20, 15);
-                               for (i = 0; i < 15; i++) {
-                               /* BB are there cases in which a comma can be
-                               valid in this workstation netbios name (and need
-                               special handling)? */
-
-                               /* We do not uppercase netbiosname for user */
+                               memset(vol->source_rfc1001_name, 0x20,
+                                       RFC1001_NAME_LEN);
+                               /*
+                                * FIXME: are there cases in which a comma can
+                                * be valid in workstation netbios name (and
+                                * need special handling)?
+                                */
+                               for (i = 0; i < RFC1001_NAME_LEN; i++) {
+                                       /* don't ucase netbiosname for user */
                                        if (value[i] == 0)
                                                break;
-                                       else
-                                               vol->source_rfc1001_name[i] =
-                                                               value[i];
+                                       vol->source_rfc1001_name[i] = value[i];
                                }
                                /* The string has 16th byte zero still from

                               set at top of the function  */
-                               if ((i == 15) && (value[i] != 0))
+                               if (i == RFC1001_NAME_LEN && value[i] != 0) printk(KERN_WARNING "CIFS: netbiosname" " longer than 15 truncated.\n"); }

fs/cifs/connect.c +2 -1
@@ -1190,7 +1190,8 @@ cifs_parse_mount_options(char *options, const char *devname,
                                cFYI(1, "empty server netbiosname specified");
                        } else {
                                /* last byte, type, is 0x20 for servr type */
-                               memset(vol->target_rfc1001_name, 0x20, 16);
+                               memset(vol->target_rfc1001_name, 0x20,
+                                       RFC1001_NAME_LEN_WITH_NULL);
 
                                for (i = 0; i < 15; i++) {
                                /* BB are there cases in which a comma can be
@@ -1207,7 +1208,7 @@ cifs_parse_mount_options(char *options, const char *devname,
                                }
                                /* The string has 16th byte zero still from

                                  set at top of the function  */
-                               if ((i == 15) && (value[i] != 0))
+                               if (i == RFC1001_NAME_LEN && value[i] != 0) printk(KERN_WARNING "CIFS: server net" "biosname longer than 15 truncated.\n");

Quoted 8 lines
Quoted 5 lines

                       }
--
1.7.3.2

Jeff, I do not see where RFC1001_NAME_LEN_WITH_NULL and RFC1000_NAME_LEN are defined.

In cifsglob.h...

Quoted 8 lines

There's a tool for this sort of thing called "cscope":

   http://cscope.sourceforge.net/

Cheers,
--
Jeff Layton <[email protected]>

Oh, I did not realize that these defines existed already.

Reviewed-by
#21 lore raw
In reply to a message not in the archive
Quoted 75 lines · Jeff Layton

The server->sequence_number is already protected by the srv_mutex. The GlobalMid_lock is unneeded here.

---
 fs/cifs/cifsencrypt.c |    6 ++----
 fs/cifs/cifsglob.h    |    2 +-

 2 files changed, 3 insertions(+), 5 deletions(-)
fs/cifs/cifsencrypt.c +1 -1
index f856732..66f3d50 100644
@@ -72,6 +72,7 @@ static int cifs_calculate_signature(const struct smb_hdr *cifs_pdu,
        return 0;
  }
 
+/* must be called with server->srv_mutex held */
  int cifs_sign_smb(struct smb_hdr *cifs_pdu, struct TCP_Server_Info *server,
                  __u32 *pexpected_response_sequence_number)
  {
@@ -84,14 +85,12 @@ int cifs_sign_smb(struct smb_hdr *cifs_pdu, struct TCP_Server_Info *server,
        if ((cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) == 0)
                return rc;
 
-       spin_lock(&GlobalMid_Lock);

       cifs_pdu->Signature.Sequence.SequenceNumber = cpu_to_le32(server->sequence_number); cifs_pdu->Signature.Sequence.Reserved = 0;

       *pexpected_response_sequence_number = server->sequence_number++; server->sequence_number++;
-       spin_unlock(&GlobalMid_Lock);

       rc = cifs_calculate_signature(cifs_pdu, server, smb_signature); if (rc)

fs/cifs/cifsencrypt.c +1 -1
@@ -149,6 +148,7 @@ static int cifs_calc_signature2(const struct kvec *iov, int n_vec,
        return rc;
  }
 
+/* must be called with server->srv_mutex held */
  int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *server,
                   __u32 *pexpected_response_sequence_number)
  {
@@ -162,14 +162,12 @@ int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *server,
        if ((cifs_pdu->Flags2 & SMBFLG2_SECURITY_SIGNATURE) == 0)
                return rc;
 
-       spin_lock(&GlobalMid_Lock);

       cifs_pdu->Signature.Sequence.SequenceNumber = cpu_to_le32(server->sequence_number); cifs_pdu->Signature.Sequence.Reserved = 0;

       *pexpected_response_sequence_number = server->sequence_number++; server->sequence_number++;
-       spin_unlock(&GlobalMid_Lock);

       rc = cifs_calc_signature2(iov, n_vec, server, smb_signature); if (rc)

fs/cifs/cifsglob.h +0 -0
index a8d9f32..bba731c 100644
@@ -200,7 +200,7 @@ struct TCP_Server_Info {

       char cryptkey[CIFS_CRYPTO_KEY_SIZE]; /* used by ntlm, ntlmv2 etc */ /* 16th byte of RFC1001 workstation name is always null */ char workstation_RFC1001_name[RFC1001_NAME_LEN_WITH_NULL];
-       __u32 sequence_number; /* needed for CIFS PDU signature */
+       __u32 sequence_number; /* for signing, protected by srv_mutex */ struct session_key session_key;
       unsigned long lstrp; /* when we got last response from this server */ u16 dialect; /* dialect index that server chose */
--
1.7.3.2

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Looks correct. Two less contenders for global mid lock.