This is a note to let you know that I've just added the patch titled cifs: fix missing unlock in cifs_file_copychunk_range() to the 6.0-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: cifs-fix-missing-unlock-in-cifs_file_copychunk_range.patch and it can be found in the queue-6.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 502487847743018c93d75b401eac2ea4c4973123 Mon Sep 17 00:00:00 2001 From: ChenXiaoSong <chenxiaosong2@xxxxxxxxxx> Date: Sat, 19 Nov 2022 12:51:59 +0800 Subject: cifs: fix missing unlock in cifs_file_copychunk_range() From: ChenXiaoSong <chenxiaosong2@xxxxxxxxxx> commit 502487847743018c93d75b401eac2ea4c4973123 upstream. xfstests generic/013 and generic/476 reported WARNING as follows: WARNING: lock held when returning to user space! 6.1.0-rc5+ #4 Not tainted ------------------------------------------------ fsstress/504233 is leaving the kernel with locks still held! 2 locks held by fsstress/504233: #0: ffff888054c38850 (&sb->s_type->i_mutex_key#21){+.+.}-{3:3}, at: lock_two_nondirectories+0xcf/0xf0 #1: ffff8880b8fec750 (&sb->s_type->i_mutex_key#21/4){+.+.}-{3:3}, at: lock_two_nondirectories+0xb7/0xf0 This will lead to deadlock and hungtask. Fix this by releasing locks when failed to write out on a file range in cifs_file_copychunk_range(). Fixes: 3e3761f1ec7d ("smb3: use filemap_write_and_wait_range instead of filemap_write_and_wait") Cc: stable@xxxxxxxxxxxxxxx # 6.0 Reviewed-by: Paulo Alcantara (SUSE) <pc@xxxxxx> Signed-off-by: ChenXiaoSong <chenxiaosong2@xxxxxxxxxx> Signed-off-by: Steve French <stfrench@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/cifs/cifsfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1252,7 +1252,7 @@ ssize_t cifs_file_copychunk_range(unsign rc = filemap_write_and_wait_range(src_inode->i_mapping, off, off + len - 1); if (rc) - goto out; + goto unlock; /* should we flush first and last page first */ truncate_inode_pages(&target_inode->i_data, 0); @@ -1268,6 +1268,8 @@ ssize_t cifs_file_copychunk_range(unsign * that target is updated on the server */ CIFS_I(target_inode)->time = 0; + +unlock: /* although unlocking in the reverse order from locking is not * strictly necessary here it is a little cleaner to be consistent */ Patches currently in stable-queue which might be from chenxiaosong2@xxxxxxxxxx are queue-6.0/cifs-fix-missing-unlock-in-cifs_file_copychunk_range.patch