]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
cifs: fix credits leak for SMB1 oplock breaks
authorRonnie Sahlberg <lsahlber@redhat.com>
Wed, 1 May 2019 02:03:41 +0000 (12:03 +1000)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 12 Aug 2019 09:59:43 +0000 (11:59 +0200)
BugLink: https://bugs.launchpad.net/bugs/1837517
commit d69cb728e70c40268762182a62f5d5d6fa51c5b2 upstream.

For SMB1 oplock breaks we would grab one credit while sending the PDU
but we would never relese the credit back since we will never receive a
response to this from the server. Eventuallt this would lead to a hang
once all credits are leaked.

Fix this by defining a new flag CIFS_NO_SRV_RSP which indicates that there
is no server response to this command and thus we need to add any credits back
immediately after sending the PDU.

CC: Stable <stable@vger.kernel.org> #v5.0+
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/cifs/cifsglob.h
fs/cifs/cifssmb.c
fs/cifs/transport.c

index 10ead04346ee2f9df83ff0ab897f48352c299139..8c295e37ac236c2af81e0ab1553aa4370dc9f5a7 100644 (file)
@@ -1657,6 +1657,7 @@ static inline bool is_retryable_error(int error)
 
 #define   CIFS_HAS_CREDITS 0x0400    /* already has credits */
 #define   CIFS_TRANSFORM_REQ 0x0800    /* transform request before sending */
+#define   CIFS_NO_SRV_RSP    0x1000    /* there is no server response */
 
 /* Security Flags: indicate type of session setup needed */
 #define   CIFSSEC_MAY_SIGN     0x00001
index 551924beb86f8be7d0c010db1853626a8c2ca34c..f91e714928d4bf665770faf19793b194472eb201 100644 (file)
@@ -2533,7 +2533,7 @@ CIFSSMBLock(const unsigned int xid, struct cifs_tcon *tcon,
 
        if (lockType == LOCKING_ANDX_OPLOCK_RELEASE) {
                /* no response expected */
-               flags = CIFS_ASYNC_OP | CIFS_OBREAK_OP;
+               flags = CIFS_NO_SRV_RSP | CIFS_ASYNC_OP | CIFS_OBREAK_OP;
                pSMB->Timeout = 0;
        } else if (waitFlag) {
                flags = CIFS_BLOCKING_OP; /* blocking operation, no timeout */
index 9544eb99b5a2f9e11da4b4bea4e1cdc2b519dd65..95f3be904eed01693d4e9aef17ddb4538c58355d 100644 (file)
@@ -906,8 +906,11 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
 
        mutex_unlock(&ses->server->srv_mutex);
 
-       if (rc < 0) {
-               /* Sending failed for some reason - return credits back */
+       /*
+        * If sending failed for some reason or it is an oplock break that we
+        * will not receive a response to - return credits back
+        */
+       if (rc < 0 || (flags & CIFS_NO_SRV_RSP)) {
                for (i = 0; i < num_rqst; i++)
                        add_credits(ses->server, credits[i], optype);
                goto out;
@@ -928,9 +931,6 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
                smb311_update_preauth_hash(ses, rqst[0].rq_iov,
                                           rqst[0].rq_nvec);
 
-       if (timeout == CIFS_ASYNC_OP)
-               goto out;
-
        for (i = 0; i < num_rqst; i++) {
                rc = wait_for_response(ses->server, midQ[i]);
                if (rc != 0)