From patchwork Fri Feb 1 20:03:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 10793661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C66A81390 for ; Fri, 1 Feb 2019 20:04:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B75B432C9E for ; Fri, 1 Feb 2019 20:04:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABADA330BE; Fri, 1 Feb 2019 20:04:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48B5632C9E for ; Fri, 1 Feb 2019 20:04:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730694AbfBAUEe (ORCPT ); Fri, 1 Feb 2019 15:04:34 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36284 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730654AbfBAUEe (ORCPT ); Fri, 1 Feb 2019 15:04:34 -0500 Received: by mail-pl1-f195.google.com with SMTP id g9so3755508plo.3 for ; Fri, 01 Feb 2019 12:04:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=kKasDG93CeMH7cEMyf5Ij7Z5BVEx8eWcoBJ9DOqy7Fc=; b=dWsoXlN2fs9GM6iNwiJR6rzTzVh8wb15+q7oqXZmMVoLjI6gdOqCC6MgkleMM11Trz QToVM/WKhu38AG640wPLnSxPShKq4P1l/tDyu/QTU5hAU29NPnAFnZGUP8xdj340/99V juRj4fUrclfk+7pQtWgrmrZxXhLO8q0lg2JvNraqR3JEaZr83mJ3VIT//kJK5AJFkOfA AZxiWJ1GDtYAR75xyYV8G9kRPPMJMO+9YNAOoXp6s1QOCnfACd07BKuHWa90PmJ1kNP9 iS1HU1tOPq+3wikjqhQwyo4PMZ8+3Avee65cGpa2/cTN+b5+gZAGXOaf/NTAD070LmPh ReTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=kKasDG93CeMH7cEMyf5Ij7Z5BVEx8eWcoBJ9DOqy7Fc=; b=EzptLAUEDpMbcQSnS3HusN47bBPu+Z5jw+9nNjSfNMLc2EMY0A/wtFp3psY7zwy/FC Lra1FMbD8EBmyv1DT9uQHDN8hfOP2UxdGKlEMS75J2nJ8jukF/xlQlbpVz3PvIziXC/C hRzGjGLjqGjMmiUJfqqFtr7VuTUD37iZolFBZ4uNn8VuKEEFnfWckkfy4OEZ+udPP77h QNvrIYkW3tRA2Emtgf4qiUfZUXInvRI4ITTHKiMrQKMFO3nVDxdjgiqQ8JqU9UZVoxYf bJuh2wglhsWorsp8H9S6fLB/k7F8yIopteTcXgkrwcTcVJ84O3YWVV8Y09lDvNu+KirK wr7w== X-Gm-Message-State: AJcUukcAdQM4mc/ikODFmqBfu3G8N6cg7a7wQn12zSNnAs9Xmd6WH2zu +qor07WNXiFpvtzH1WZDL/RQC3c= X-Google-Smtp-Source: ALg8bN7BmRBtflK+VFEn+YSWgPXZ1+WEL7WAcZ0luczLbTP3q4AfgY2ijpH454tzXS9cb5FQe0o3Og== X-Received: by 2002:a17:902:622:: with SMTP id 31mr40119803plg.171.1549051473424; Fri, 01 Feb 2019 12:04:33 -0800 (PST) Received: from ubuntu-vm.corp.microsoft.com ([2001:4898:80e8:0:a18e:4e9f:6b7c:507d]) by smtp.gmail.com with ESMTPSA id x11sm24247451pfe.72.2019.02.01.12.04.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Feb 2019 12:04:32 -0800 (PST) From: Pavel Shilovsky X-Google-Original-From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 08/23] CIFS: Count SMB3 credits for malformed pending responses Date: Fri, 1 Feb 2019 12:03:57 -0800 Message-Id: <1549051452-5968-10-git-send-email-pshilov@microsoft.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549051452-5968-1-git-send-email-pshilov@microsoft.com> References: <1549051452-5968-1-git-send-email-pshilov@microsoft.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Even if a response is malformed, we should count credits granted by the server to avoid miscalculations and unnecessary reconnects due to client or server bugs. If the response has been received partially, the session will be reconnected anyway on the next iteration of the demultiplex thread, so counting credits for such cases shouldn't break things. Signed-off-by: Pavel Shilovsky Signed-off-by: Steve French --- fs/cifs/cifsglob.h | 4 ++-- fs/cifs/cifssmb.c | 2 +- fs/cifs/connect.c | 2 +- fs/cifs/smb2ops.c | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 94dbdbe..b84b1fc 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -383,8 +383,8 @@ struct smb_version_operations { struct cifs_fid *); /* calculate a size of SMB message */ unsigned int (*calc_smb_size)(void *buf, struct TCP_Server_Info *ptcpi); - /* check for STATUS_PENDING and process it in a positive case */ - bool (*is_status_pending)(char *, struct TCP_Server_Info *, int); + /* check for STATUS_PENDING and process the response if yes */ + bool (*is_status_pending)(char *buf, struct TCP_Server_Info *server); /* check for STATUS_NETWORK_SESSION_EXPIRED */ bool (*is_session_expired)(char *); /* send oplock break response */ diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 551924b..d40ded3 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1605,7 +1605,7 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) } if (server->ops->is_status_pending && - server->ops->is_status_pending(buf, server, 0)) { + server->ops->is_status_pending(buf, server)) { cifs_discard_remaining_data(server); return -1; } diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 8463c94..67af18a 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1053,7 +1053,7 @@ cifs_handle_standard(struct TCP_Server_Info *server, struct mid_q_entry *mid) } if (server->ops->is_status_pending && - server->ops->is_status_pending(buf, server, length)) + server->ops->is_status_pending(buf, server)) return -1; if (!mid) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 49667ae..b2849a7 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1754,14 +1754,14 @@ smb2_close_dir(const unsigned int xid, struct cifs_tcon *tcon, * the number of credits and return true. Otherwise - return false. */ static bool -smb2_is_status_pending(char *buf, struct TCP_Server_Info *server, int length) +smb2_is_status_pending(char *buf, struct TCP_Server_Info *server) { struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf; if (shdr->Status != STATUS_PENDING) return false; - if (!length) { + if (shdr->CreditRequest) { spin_lock(&server->req_lock); server->credits += le16_to_cpu(shdr->CreditRequest); spin_unlock(&server->req_lock); @@ -3211,7 +3211,7 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid, } if (server->ops->is_status_pending && - server->ops->is_status_pending(buf, server, 0)) + server->ops->is_status_pending(buf, server)) return -1; /* set up first two iov to get credits */