From patchwork Sat May 19 07:10:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 10412609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7E4F9601F9 for ; Sat, 19 May 2018 07:10:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55294284F9 for ; Sat, 19 May 2018 07:10:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 306B82852B; Sat, 19 May 2018 07:10:54 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_TVD_MIME_EPI 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 A1190284F9 for ; Sat, 19 May 2018 07:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750771AbeESHKx (ORCPT ); Sat, 19 May 2018 03:10:53 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:39768 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750743AbeESHKw (ORCPT ); Sat, 19 May 2018 03:10:52 -0400 Received: by mail-pf0-f181.google.com with SMTP id a22-v6so4766297pfn.6 for ; Sat, 19 May 2018 00:10:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=jI2eR9pSJI5c83BlcmxqQ/UsN4rfGxHrUuECkBnV07A=; b=ZvXU+tAL1UwnETqQ7aJSzUjlKSDkC9UEy5xqPNMQZi/KgznBa8G2lSxRjBZ9ouo4bz qeImq2FIKGjBTX8IbA6A0PycxO+NSK0Bm+IpdBiZN3HccvbnxXsZRk+OW51fgOJgq2O/ ZCHvn1nyfMfpak5cUVTQQoxf7kJ/KI0YmaXrxerIAP4dIR/u9pySm524p2sLr7aNjWse hq5iBu60idVe2IGz7rqu/OomVHjMVF0aMAYY/eZTTL3hfwpFIAVmeVuj+cvY3eV6iQ3v K9/LWgB3OWzhHAYlzFZ8n8f4b0CMIRb7F9g511HwXg3utj3oIZpBWLNC9rW6TiLnS4se mpRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=jI2eR9pSJI5c83BlcmxqQ/UsN4rfGxHrUuECkBnV07A=; b=OXXAOecgq4+fcpNKIw3ObcP5qDdlPjl/q6tPljjll1NUcmjfAqvmdXs20WnTTpME6v jad9+CMbpEOU7QG2nWnO0iXUYKxnKOqiOpw4OlV3FrvbmnK8v9LzD51UQDiFSlCF0Vc3 DicCKPxMSa0Eo4VfJEEC2J+mQhVEC2d4orcBMTYcNfU6TF/EB4UZZiA4t8brX4F4BB35 7PeBCXdKLkXCqMAHziO7VBGwIIo+EIApMEep36dSGyELwRzYfnMkbPaq/0T/NwOXbruf lVMxMDWR2SQ3QmJ7OCULLOZn+JzO2tnuEGIJKtbUwNm1Jc/6K9cjUp838aGVdAUoi+tw FiWg== X-Gm-Message-State: ALKqPwcs0OBiQHq9nj/Vp4oLUggZjQeuThLUhikMgUk55yVy9dTsij7X ez9zpSrPD5lC//SOfeKXUm8EZ4l83A75zCfgJ3bgmg== X-Google-Smtp-Source: AB8JxZoKMxgexF1AB5a9Jibs0Cm0/UL4v0w/0GrsWCdo35m4OeHkprpHkVQy5S5doFTlnAtQ0NjUqs8l2nt1V0LnE90= X-Received: by 2002:a62:6402:: with SMTP id y2-v6mr12054315pfb.71.1526713851557; Sat, 19 May 2018 00:10:51 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a17:90a:bd8f:0:0:0:0 with HTTP; Sat, 19 May 2018 00:10:30 -0700 (PDT) From: Steve French Date: Sat, 19 May 2018 02:10:30 -0500 Message-ID: Subject: smb3: fix xid leak To: CIFS 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 We were leaking xids (so total active requests kept increasing) - fix the places where free_xid was missing. Reviewed-by: Ronnie Sahlberg From 0f902629cbd1717061cc755235873457c3cfb682 Mon Sep 17 00:00:00 2001 From: Steve French Date: Sat, 19 May 2018 02:04:55 -0500 Subject: [PATCH] smb3: fix various xid leaks Fix a few cases where we were not freeing the xid which led to active requests being non-zero at unmount time. Signed-off-by: Steve French CC: Stable --- fs/cifs/smb2ops.c | 63 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 19 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index ceaa358723f0..f0ae47e69cb3 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1637,8 +1637,11 @@ get_smb2_acl_by_path(struct cifs_sb_info *cifs_sb, oparms.create_options = 0; utf16_path = cifs_convert_path_to_utf16(path, cifs_sb); - if (!utf16_path) - return ERR_PTR(-ENOMEM); + if (!utf16_path) { + rc = -ENOMEM; + free_xid(xid); + return ERR_PTR(rc); + } oparms.tcon = tcon; oparms.desired_access = READ_CONTROL; @@ -1696,8 +1699,11 @@ set_smb2_acl(struct cifs_ntsd *pnntsd, __u32 acllen, access_flags = WRITE_DAC; utf16_path = cifs_convert_path_to_utf16(path, cifs_sb); - if (!utf16_path) - return -ENOMEM; + if (!utf16_path) { + rc = -ENOMEM; + free_xid(xid); + return rc; + } oparms.tcon = tcon; oparms.desired_access = access_flags; @@ -1757,15 +1763,21 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, /* if file not oplocked can't be sure whether asking to extend size */ if (!CIFS_CACHE_READ(cifsi)) - if (keep_size == false) - return -EOPNOTSUPP; + if (keep_size == false) { + rc = -EOPNOTSUPP; + free_xid(xid); + return rc; + } /* * Must check if file sparse since fallocate -z (zero range) assumes * non-sparse allocation */ - if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE)) - return -EOPNOTSUPP; + if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE)) { + rc = -EOPNOTSUPP; + free_xid(xid); + return rc; + } /* * need to make sure we are not asked to extend the file since the SMB3 @@ -1774,8 +1786,11 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon, * which for a non sparse file would zero the newly extended range */ if (keep_size == false) - if (i_size_read(inode) < offset + len) - return -EOPNOTSUPP; + if (i_size_read(inode) < offset + len) { + rc = -EOPNOTSUPP; + free_xid(xid); + return rc; + } cifs_dbg(FYI, "offset %lld len %lld", offset, len); @@ -1808,8 +1823,11 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon, /* Need to make file sparse, if not already, before freeing range. */ /* Consider adding equivalent for compressed since it could also work */ - if (!smb2_set_sparse(xid, tcon, cfile, inode, set_sparse)) - return -EOPNOTSUPP; + if (!smb2_set_sparse(xid, tcon, cfile, inode, set_sparse)) { + rc = -EOPNOTSUPP; + free_xid(xid); + return rc; + } cifs_dbg(FYI, "offset %lld len %lld", offset, len); @@ -1840,8 +1858,10 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, /* if file not oplocked can't be sure whether asking to extend size */ if (!CIFS_CACHE_READ(cifsi)) - if (keep_size == false) - return -EOPNOTSUPP; + if (keep_size == false) { + free_xid(xid); + return rc; + } /* * Files are non-sparse by default so falloc may be a no-op @@ -1850,14 +1870,16 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, */ if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) == 0) { if (keep_size == true) - return 0; + rc = 0; /* check if extending file */ else if (i_size_read(inode) >= off + len) /* not extending file and already not sparse */ - return 0; + rc = 0; /* BB: in future add else clause to extend file */ else - return -EOPNOTSUPP; + rc = -EOPNOTSUPP; + free_xid(xid); + return rc; } if ((keep_size == true) || (i_size_read(inode) >= off + len)) { @@ -1869,8 +1891,11 @@ static long smb3_simple_falloc(struct file *file, struct cifs_tcon *tcon, * ie potentially making a few extra pages at the beginning * or end of the file non-sparse via set_sparse is harmless. */ - if ((off > 8192) || (off + len + 8192 < i_size_read(inode))) - return -EOPNOTSUPP; + if ((off > 8192) || (off + len + 8192 < i_size_read(inode))) { + rc = -EOPNOTSUPP; + free_xid(xid); + return rc; + } rc = smb2_set_sparse(xid, tcon, cfile, inode, false); } -- 2.17.0