Skip to contentSkip to conversation

cifs: use memcpy for magic string in cifs signature generation BSRSPYL

PATCH In review Jeff Layton 2 participants 3 messages Aug 20, 2011 – Aug 24, 2011 2 messages not in the archive

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

PATCH 1/1 cifs: use memcpy for magic string in cifs signature generation BSRSPYL

...it's more efficient since we know the length.

---
 fs/cifs/cifsencrypt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/cifs/cifsencrypt.c +2 -2
index e76bfeb..f11dfb6 100644
@@ -92,7 +92,7 @@ int cifs_sign_smb(struct smb_hdr *cifs_pdu, struct TCP_Server_Info *server,
 		return rc;
 
 	if (!server->session_estab) {
-		strncpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
+		memcpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
 		return rc;
 	}
 
@@ -189,7 +189,7 @@ int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *server,
 		return rc;
 
 	if (!server->session_estab) {
-		strncpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
+		memcpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
 		return rc;
 	}
 
Signature · 1 line
1.7.6
Reviewed-by
#2 lore raw
In reply to a message not in the archive
Quoted 21 lines · Jeff Layton

...it's more efficient since we know the length.

---
 fs/cifs/cifsencrypt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/cifs/cifsencrypt.c +1 -1
index e76bfeb..f11dfb6 100644
@@ -92,7 +92,7 @@ int cifs_sign_smb(struct smb_hdr *cifs_pdu, struct TCP_Server_Info *server,
 		return rc;
 
 	if (!server->session_estab) {
-		strncpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
+		memcpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
 		return rc;
 	}
 

fs/cifs/cifsencrypt.c int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *server, · line 195

Quoted 8 lines
fs/cifs/cifsencrypt.c +1 -1
@@ -189,7 +189,7 @@ int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *server,
 		return rc;
 
 	if (!server->session_estab) {
-		strncpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
+		memcpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
 		return rc;
 	}
 

Looks good to me.

Any reason why some of the strncpy/strncmp cases were only picked up among the rest? May be depending on how hot the code path is?

#4 lore raw
In reply to a message not in the archive
Quoted 34 lines · On Wed, 24 Aug 2011 12:00:11 +0530 Suresh Jayaraman…
Quoted 21 lines · Jeff Layton

...it's more efficient since we know the length.

---
 fs/cifs/cifsencrypt.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/cifs/cifsencrypt.c +1 -1
index e76bfeb..f11dfb6 100644
@@ -92,7 +92,7 @@ int cifs_sign_smb(struct smb_hdr *cifs_pdu, struct TCP_Server_Info *server,
 		return rc;
 
 	if (!server->session_estab) {
-		strncpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
+		memcpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
 		return rc;
 	}
 

fs/cifs/cifsencrypt.c int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *server, · line 195

Quoted 8 lines
fs/cifs/cifsencrypt.c +1 -1
@@ -189,7 +189,7 @@ int cifs_sign_smb2(struct kvec *iov, int n_vec, struct TCP_Server_Info *server,
 		return rc;
 
 	if (!server->session_estab) {
-		strncpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
+		memcpy(cifs_pdu->Signature.SecuritySignature, "BSRSPYL", 8);
 		return rc;
 	}
 

Looks good to me.

Quoted 5 lines

Any reason why some of the strncpy/strncmp cases were only picked up among the rest? May be depending on how hot the code path is?

Simply because that's where I noticed them. If you see other places that could benefit, then it's probably reasonable to patch them too.

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