All of lore.kernel.org
 help / color / mirror / Atom feed
From: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
To: Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-cifs <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH] cifs: make debugging SMB signature issue easier
Date: Fri, 03 Jun 2011 16:49:44 +0530	[thread overview]
Message-ID: <4DE8C350.8090100@suse.de> (raw)

... and make the error message useful. Also make a long variable name shorter
while at it.

Signed-off-by: Suresh Jayaraman <sjayaraman-l3A5Bk7waGM@public.gmane.org>
---
 fs/cifs/cifsencrypt.c |   14 +++++++-------
 fs/cifs/transport.c   |   10 +++++++---
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
index dfbd9f1..b5aa654 100644
--- a/fs/cifs/cifsencrypt.c
+++ b/fs/cifs/cifsencrypt.c
@@ -179,7 +179,7 @@ int cifs_verify_signature(struct smb_hdr *cifs_pdu,
 {
 	unsigned int rc;
 	char server_response_sig[8];
-	char what_we_think_sig_should_be[20];
+	char expected_sig[20];
 
 	if (cifs_pdu == NULL || server == NULL)
 		return -EINVAL;
@@ -211,18 +211,18 @@ int cifs_verify_signature(struct smb_hdr *cifs_pdu,
 	cifs_pdu->Signature.Sequence.Reserved = 0;
 
 	mutex_lock(&server->srv_mutex);
-	rc = cifs_calculate_signature(cifs_pdu, server,
-		what_we_think_sig_should_be);
+	rc = cifs_calculate_signature(cifs_pdu, server, expected_sig);
 	mutex_unlock(&server->srv_mutex);
 
 	if (rc)
 		return rc;
 
-/*	cifs_dump_mem("what we think it should be: ",
-		      what_we_think_sig_should_be, 16); */
-
-	if (memcmp(server_response_sig, what_we_think_sig_should_be, 8))
+	if (memcmp(server_response_sig, expected_sig, 8)) {
+		cifs_dump_mem("Expected signature: ", expected_sig, 8);
+		cifs_dump_mem("Signature from server's response: ",
+				server_response_sig, 8);
 		return -EACCES;
+	}
 	else
 		return 0;
 
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c
index 147aa22..d7bbbef 100644
--- a/fs/cifs/transport.c
+++ b/fs/cifs/transport.c
@@ -500,15 +500,19 @@ int
 cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server,
 		   bool log_error)
 {
+	int rc =0;
+
 	dump_smb(mid->resp_buf,
 		 min_t(u32, 92, be32_to_cpu(mid->resp_buf->smb_buf_length)));
 
 	/* convert the length into a more usable form */
 	if (server->sec_mode & (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED)) {
 		/* FIXME: add code to kill session */
-		if (cifs_verify_signature(mid->resp_buf, server,
-					  mid->sequence_number + 1) != 0)
-			cERROR(1, "Unexpected SMB signature");
+		rc = cifs_verify_signature(mid->resp_buf, server,
+				mid->sequence_number + 1);
+		if (rc)
+			cERROR(1, "Unexpected SMB signature, error %d while"
+					"verifying signature", rc);
 	}
 
 	/* BB special case reconnect tid and uid here? */
-- 
1.7.1

                 reply	other threads:[~2011-06-03 11:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DE8C350.8090100@suse.de \
    --to=sjayaraman-l3a5bk7wagm@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.