]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cifs: fix handle leak in smb2_query_symlink()
authorRonnie Sahlberg <lsahlber@redhat.com>
Tue, 9 Apr 2019 21:47:22 +0000 (07:47 +1000)
committerBen Hutchings <ben@decadent.org.uk>
Tue, 13 Aug 2019 11:39:09 +0000 (12:39 +0100)
commit e6d0fb7b34f264f72c33053558a360a6a734905e upstream.

If we enter smb2_query_symlink() for something that is not a symlink
and where the SMB2_open() would succeed we would never end up
closing this handle and would thus leak a handle on the server.

Fix this by immediately calling SMB2_close() on successfull open.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/cifs/smb2ops.c

index 376ccd96127f373e406bac28a88977c0a1faa640..d95a547cf94ef5d54dd119e62c1b16225d5c4be6 100644 (file)
@@ -906,6 +906,8 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
 
        rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, &err_buf);
 
+       if (!rc)
+               SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
        if (!rc || !err_buf) {
                kfree(utf16_path);
                return -ENOENT;