From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54E4F23A3 for ; Fri, 28 Oct 2022 12:07:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE758C433B5; Fri, 28 Oct 2022 12:07:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666958839; bh=JdJn/9o0EpFKbKSqDVyIpUdzwW/fBKH4Ai+3IGpvqaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0a0/aDFR0YWpJUSnMXhI9oFKME1mBJPmsndOS+94JqVlMUkEWMnWpOVvgf4g+fM+J rfteaamHKnPFKdh5IrrrcbS1fomW51Q73cOar3JeJP16K8w6pO2HtHy8BzKf61uajP jfr49pkZiYDdvaqAmMRNGkQmDvmyngrqFSVhv8Vs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Paulo Alcantara (SUSE)" , Zhang Xiaoxu , Steve French , Sasha Levin Subject: [PATCH 5.10 31/73] cifs: Fix xid leak in cifs_copy_file_range() Date: Fri, 28 Oct 2022 14:03:28 +0200 Message-Id: <20221028120233.723245713@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221028120232.344548477@linuxfoundation.org> References: <20221028120232.344548477@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Zhang Xiaoxu [ Upstream commit 9a97df404a402fe1174d2d1119f87ff2a0ca2fe9 ] If the file is used by swap, before return -EOPNOTSUPP, should free the xid, otherwise, the xid will be leaked. Fixes: 4e8aea30f775 ("smb3: enable swap on SMB3 mounts") Reviewed-by: Paulo Alcantara (SUSE) Signed-off-by: Zhang Xiaoxu Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/cifsfs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index bc957e6ca48b..f442ef8b65da 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1221,8 +1221,11 @@ static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off, ssize_t rc; struct cifsFileInfo *cfile = dst_file->private_data; - if (cfile->swapfile) - return -EOPNOTSUPP; + if (cfile->swapfile) { + rc = -EOPNOTSUPP; + free_xid(xid); + return rc; + } rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff, len, flags); -- 2.35.1