From patchwork Fri Jun 3 11:19:44 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suresh Jayaraman X-Patchwork-Id: 846442 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p53BUN80001559 for ; Fri, 3 Jun 2011 11:30:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752727Ab1FCLTX (ORCPT ); Fri, 3 Jun 2011 07:19:23 -0400 Received: from cantor2.suse.de ([195.135.220.15]:35830 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752631Ab1FCLTW (ORCPT ); Fri, 3 Jun 2011 07:19:22 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) by mx2.suse.de (Postfix) with ESMTP id 85D85867E2; Fri, 3 Jun 2011 13:19:21 +0200 (CEST) Message-ID: <4DE8C350.8090100@suse.de> Date: Fri, 03 Jun 2011 16:49:44 +0530 From: Suresh Jayaraman User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110414 SUSE/3.1.10 Thunderbird/3.1.10 MIME-Version: 1.0 To: Steve French Cc: linux-cifs Subject: [PATCH] cifs: make debugging SMB signature issue easier Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 03 Jun 2011 11:30:25 +0000 (UTC) ... and make the error message useful. Also make a long variable name shorter while at it. Signed-off-by: Suresh Jayaraman --- 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? */