From patchwork Wed Apr 3 18:07:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 2388911 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 83CDBDFB79 for ; Wed, 3 Apr 2013 18:08:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762864Ab3DCSIC (ORCPT ); Wed, 3 Apr 2013 14:08:02 -0400 Received: from mail-qc0-f179.google.com ([209.85.216.179]:49160 "EHLO mail-qc0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760077Ab3DCSIB (ORCPT ); Wed, 3 Apr 2013 14:08:01 -0400 Received: by mail-qc0-f179.google.com with SMTP id v28so809257qcm.10 for ; Wed, 03 Apr 2013 11:08:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=YsK+WuoPBMYO7hr3MPvaBlsJAYlxTqn9J6UHKNCVByY=; b=lodRE9Hk08JueVqgltOOP9whUBVVjmUcl7RxgjRsSyS1Q4B7nd+eEaUyaP2wIIukP/ zHRskarBpTqbGHnThJdXcRXW/9/S5OB96KCKVrGpPRngM25sbRIU1MArO8By7lSHCk8+ PRON4dJN+g3xcG7g1SLyP2Kw9jR66Hyk04hyQz3picADtBzeghrUTi9EkzYDtJ3f18P3 4VDhuYgfSaJtSskJS9cwl2xVkarc+0U3NOlEDkcj9HnTvbaJAGrzgnqptdfjSE9hGGHl ZmxhBvwmNJh8pkQsu3E/QCWg11AcP5++NO6HlEcOKOl/QYN5c4qfktVdZ41sPiAwjDYG Ob2Q== X-Received: by 10.229.22.138 with SMTP id n10mr874734qcb.84.1365012480810; Wed, 03 Apr 2013 11:08:00 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-113-143.nc.res.rr.com. [107.15.113.143]) by mx.google.com with ESMTPS id 10sm7918208qax.13.2013.04.03.11.07.59 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 03 Apr 2013 11:08:00 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org Subject: [PATCH] cifs: store the real expected sequence number in the mid Date: Wed, 3 Apr 2013 14:07:56 -0400 Message-Id: <1365012476-6885-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 X-Gm-Message-State: ALoCoQn44FnPb3AcQ3iE37c9CBKyA8N1FOBNw1SUVf4NrwjAexKkXmdKIeYFahGDuaIGnT9Q9tQg Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Currently, the signing routines take a pointer to a place to store the expected sequence number for the mid response. It then stores a value that's one below what that sequence number should be, and then adds one to it when verifying the signature on the response. Increment the sequence number before storing the value in the mid, and eliminate the "+1" when checking the signature. Signed-off-by: Jeff Layton --- fs/cifs/cifsencrypt.c | 4 ++-- fs/cifs/cifssmb.c | 2 +- fs/cifs/transport.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index 2cbbec6..71436d1 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c @@ -135,8 +135,8 @@ int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server, cpu_to_le32(server->sequence_number); cifs_pdu->Signature.Sequence.Reserved = 0; - *pexpected_response_sequence_number = server->sequence_number++; - server->sequence_number++; + *pexpected_response_sequence_number = ++server->sequence_number; + ++server->sequence_number; rc = cifs_calc_signature(rqst, server, smb_signature); if (rc) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 076d7ed..4060c45 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1545,7 +1545,7 @@ cifs_readv_callback(struct mid_q_entry *mid) int rc = 0; rc = cifs_verify_signature(&rqst, server, - mid->sequence_number + 1); + mid->sequence_number); if (rc) cifs_dbg(VFS, "SMB signature verification returned error = %d\n", rc); diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 293d2c8..bfbf470 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -622,7 +622,7 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, iov.iov_len = len; /* FIXME: add code to kill session */ rc = cifs_verify_signature(&rqst, server, - mid->sequence_number + 1); + mid->sequence_number); if (rc) cifs_dbg(VFS, "SMB signature verification returned error = %d\n", rc);