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: 916773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ZvXU+tAL"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40nx5p2YMbz9s4w for ; Sat, 19 May 2018 17:10:54 +1000 (AEST) 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 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