]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.60/f2fs-fix-deadlock-in-shutdown-ioctl.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 4.14.60 / f2fs-fix-deadlock-in-shutdown-ioctl.patch
1 From foo@baz Sat Jul 28 10:25:26 CEST 2018
2 From: Sahitya Tummala <stummala@codeaurora.org>
3 Date: Fri, 18 May 2018 11:51:52 +0530
4 Subject: f2fs: Fix deadlock in shutdown ioctl
5
6 From: Sahitya Tummala <stummala@codeaurora.org>
7
8 [ Upstream commit 60b2b4ee2bc01dd052f99fa9d65da2232102ef8e ]
9
10 f2fs_ioc_shutdown() ioctl gets stuck in the below path
11 when issued with F2FS_GOING_DOWN_FULLSYNC option.
12
13 __switch_to+0x90/0xc4
14 percpu_down_write+0x8c/0xc0
15 freeze_super+0xec/0x1e4
16 freeze_bdev+0xc4/0xcc
17 f2fs_ioctl+0xc0c/0x1ce0
18 f2fs_compat_ioctl+0x98/0x1f0
19
20 Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
21 Reviewed-by: Chao Yu <yuchao0@huawei.com>
22 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
23 Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25 ---
26 fs/f2fs/file.c | 11 +++++++----
27 1 file changed, 7 insertions(+), 4 deletions(-)
28
29 --- a/fs/f2fs/file.c
30 +++ b/fs/f2fs/file.c
31 @@ -1808,9 +1808,11 @@ static int f2fs_ioc_shutdown(struct file
32 if (get_user(in, (__u32 __user *)arg))
33 return -EFAULT;
34
35 - ret = mnt_want_write_file(filp);
36 - if (ret)
37 - return ret;
38 + if (in != F2FS_GOING_DOWN_FULLSYNC) {
39 + ret = mnt_want_write_file(filp);
40 + if (ret)
41 + return ret;
42 + }
43
44 switch (in) {
45 case F2FS_GOING_DOWN_FULLSYNC:
46 @@ -1838,7 +1840,8 @@ static int f2fs_ioc_shutdown(struct file
47 }
48 f2fs_update_time(sbi, REQ_TIME);
49 out:
50 - mnt_drop_write_file(filp);
51 + if (in != F2FS_GOING_DOWN_FULLSYNC)
52 + mnt_drop_write_file(filp);
53 return ret;
54 }
55