Commit 2dda093
f2fs: fix to avoid panic once fallocation fails for pinfile
[ Upstream commit 48ea8b2 ]
syzbot reports a f2fs bug as below:
------------[ cut here ]------------
kernel BUG at fs/f2fs/segment.c:2746!
CPU: 0 UID: 0 PID: 5323 Comm: syz.0.0 Not tainted 6.13.0-rc2-syzkaller-00018-g7cb1b4663150 #0
RIP: 0010:get_new_segment fs/f2fs/segment.c:2746 [inline]
RIP: 0010:new_curseg+0x1f52/0x1f70 fs/f2fs/segment.c:2876
Call Trace:
<TASK>
__allocate_new_segment+0x1ce/0x940 fs/f2fs/segment.c:3210
f2fs_allocate_new_section fs/f2fs/segment.c:3224 [inline]
f2fs_allocate_pinning_section+0xfa/0x4e0 fs/f2fs/segment.c:3238
f2fs_expand_inode_data+0x696/0xca0 fs/f2fs/file.c:1830
f2fs_fallocate+0x537/0xa10 fs/f2fs/file.c:1940
vfs_fallocate+0x569/0x6e0 fs/open.c:327
do_vfs_ioctl+0x258c/0x2e40 fs/ioctl.c:885
__do_sys_ioctl fs/ioctl.c:904 [inline]
__se_sys_ioctl+0x80/0x170 fs/ioctl.c:892
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Concurrent pinfile allocation may run out of free section, result in
panic in get_new_segment(), let's expand pin_sem lock coverage to
include f2fs_gc(), so that we can make sure to reclaim enough free
space for following allocation.
In addition, do below changes to enhance error path handling:
- call f2fs_bug_on() only in non-pinfile allocation path in
get_new_segment().
- call reset_curseg_fields() to reset all fields of curseg in
new_curseg()
Fixes: f5a53ed ("f2fs: support aligned pinned file")
Reported-by: syzbot+15669ec8c35ddf6c3d43@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-f2fs-devel/675cd64e.050a0220.37aaf.00bb.GAE@google.com
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Rajani Kantha <681739313@139.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent bdb0e04 commit 2dda093
2 files changed
+15
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1836 | 1836 | | |
1837 | 1837 | | |
1838 | 1838 | | |
| 1839 | + | |
| 1840 | + | |
1839 | 1841 | | |
1840 | 1842 | | |
1841 | 1843 | | |
1842 | 1844 | | |
1843 | 1845 | | |
1844 | 1846 | | |
1845 | | - | |
| 1847 | + | |
| 1848 | + | |
1846 | 1849 | | |
| 1850 | + | |
1847 | 1851 | | |
1848 | 1852 | | |
1849 | | - | |
1850 | | - | |
1851 | 1853 | | |
1852 | 1854 | | |
1853 | 1855 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2749 | 2749 | | |
2750 | 2750 | | |
2751 | 2751 | | |
2752 | | - | |
| 2752 | + | |
2753 | 2753 | | |
2754 | 2754 | | |
2755 | 2755 | | |
| |||
2795 | 2795 | | |
2796 | 2796 | | |
2797 | 2797 | | |
2798 | | - | |
| 2798 | + | |
2799 | 2799 | | |
2800 | 2800 | | |
2801 | 2801 | | |
| |||
2868 | 2868 | | |
2869 | 2869 | | |
2870 | 2870 | | |
| 2871 | + | |
| 2872 | + | |
| 2873 | + | |
| 2874 | + | |
| 2875 | + | |
| 2876 | + | |
| 2877 | + | |
2871 | 2878 | | |
2872 | 2879 | | |
2873 | 2880 | | |
| |||
2886 | 2893 | | |
2887 | 2894 | | |
2888 | 2895 | | |
2889 | | - | |
| 2896 | + | |
2890 | 2897 | | |
2891 | 2898 | | |
2892 | 2899 | | |
| |||
3640 | 3647 | | |
3641 | 3648 | | |
3642 | 3649 | | |
3643 | | - | |
3644 | | - | |
3645 | | - | |
3646 | | - | |
3647 | | - | |
3648 | | - | |
3649 | | - | |
3650 | 3650 | | |
3651 | 3651 | | |
3652 | 3652 | | |
| |||
0 commit comments