Chao Yu
f41ee8b91c
f2fs: fix to do sanity check on curseg->alloc_type
...
As Wenqing Liu reported in bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=215657
- Overview
UBSAN: array-index-out-of-bounds in fs/f2fs/segment.c:3460:2 when mount and operate a corrupted image
- Reproduce
tested on kernel 5.17-rc4, 5.17-rc6
1. mkdir test_crash
2. cd test_crash
3. unzip tmp2.zip
4. mkdir mnt
5. ./single_test.sh f2fs 2
- Kernel dump
[ 46.434454] loop0: detected capacity change from 0 to 131072
[ 46.529839] F2FS-fs (loop0): Mounted with checkpoint version = 7548c2d9
[ 46.738319] ================================================================================
[ 46.738412] UBSAN: array-index-out-of-bounds in fs/f2fs/segment.c:3460:2
[ 46.738475] index 231 is out of range for type 'unsigned int [2]'
[ 46.738539] CPU: 2 PID: 939 Comm: umount Not tainted 5.17.0-rc6 #1
[ 46.738547] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.13.0-1ubuntu1.1 04/01/2014
[ 46.738551] Call Trace:
[ 46.738556] <TASK>
[ 46.738563] dump_stack_lvl+0x47/0x5c
[ 46.738581] ubsan_epilogue+0x5/0x50
[ 46.738592] __ubsan_handle_out_of_bounds+0x68/0x80
[ 46.738604] f2fs_allocate_data_block+0xdff/0xe60 [f2fs]
[ 46.738819] do_write_page+0xef/0x210 [f2fs]
[ 46.738934] f2fs_do_write_node_page+0x3f/0x80 [f2fs]
[ 46.739038] __write_node_page+0x2b7/0x920 [f2fs]
[ 46.739162] f2fs_sync_node_pages+0x943/0xb00 [f2fs]
[ 46.739293] f2fs_write_checkpoint+0x7bb/0x1030 [f2fs]
[ 46.739405] kill_f2fs_super+0x125/0x150 [f2fs]
[ 46.739507] deactivate_locked_super+0x60/0xc0
[ 46.739517] deactivate_super+0x70/0xb0
[ 46.739524] cleanup_mnt+0x11a/0x200
[ 46.739532] __cleanup_mnt+0x16/0x20
[ 46.739538] task_work_run+0x67/0xa0
[ 46.739547] exit_to_user_mode_prepare+0x18c/0x1a0
[ 46.739559] syscall_exit_to_user_mode+0x26/0x40
[ 46.739568] do_syscall_64+0x46/0xb0
[ 46.739584] entry_SYSCALL_64_after_hwframe+0x44/0xae
The root cause is we missed to do sanity check on curseg->alloc_type,
result in out-of-bound accessing on sbi->block_count[] array, fix it.
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-03-03 18:19:41 -08:00
..
2022-01-16 07:36:49 +02:00
2022-01-20 08:52:55 +02:00
2021-10-18 14:43:22 -06:00
2022-01-22 08:33:37 +02:00
2021-10-20 21:09:02 -04:00
2021-08-19 09:02:55 +09:00
2021-06-29 10:53:48 -07:00
2022-01-22 08:33:38 +02:00
2022-01-21 21:36:28 +00:00
2022-01-22 10:59:32 +02:00
2022-01-19 23:14:34 -06:00
2021-11-09 10:02:51 -08:00
2021-08-25 07:58:49 +02:00
2021-10-18 14:43:22 -06:00
2021-10-25 19:11:50 -07:00
2022-01-06 15:47:41 +01:00
2022-01-12 11:11:34 -08:00
2021-12-03 18:44:06 +01:00
2022-01-12 15:46:11 -08:00
2022-01-10 11:00:04 +09:00
2021-12-04 08:58:54 -08:00
2022-01-22 08:33:38 +02:00
2022-03-03 18:19:41 -08:00
2022-01-20 08:52:54 +02:00
2022-01-21 21:36:28 +00:00
2022-01-18 10:05:48 +02:00
2022-01-12 11:11:34 -08:00
2021-11-09 10:11:53 -08:00
2022-01-20 08:52:54 +02:00
2021-12-21 21:44:27 +01:00
2021-10-18 12:28:53 -07:00
2022-01-15 16:30:30 +02:00
2022-01-12 15:46:11 -08:00
2021-10-19 12:51:02 +02:00
2022-01-22 08:33:37 +02:00
2022-01-17 05:49:30 +02:00
2021-11-03 09:23:25 -07:00
2021-12-03 14:36:21 +01:00
2022-01-20 13:39:13 +02:00
2022-01-17 05:49:30 +02:00
2021-06-29 10:53:48 -07:00
2022-01-21 21:36:28 +00:00
2022-01-17 05:49:30 +02:00
2021-10-04 22:02:17 +01:00
2022-01-17 05:49:30 +02:00
2022-01-20 10:41:01 +02:00
2022-01-22 08:33:35 +02:00
2022-01-15 16:30:24 +02:00
2022-01-22 08:33:38 +02:00
2022-01-23 06:20:44 +02:00
2021-06-29 10:53:48 -07:00
2021-12-31 14:37:43 -05:00
2021-12-03 18:44:06 +01:00
2022-01-22 08:33:37 +02:00
2022-01-10 11:48:37 -08:00
2021-09-21 08:36:48 -07:00
2021-11-06 16:40:48 -07:00
2021-11-09 10:11:53 -08:00
2021-11-18 11:52:22 +01:00
2022-01-18 16:50:47 -06:00
2022-01-15 16:30:24 +02:00
2021-10-05 16:35:05 +02:00
2021-11-09 10:02:52 -08:00
2022-01-16 10:15:32 +02:00
2021-12-23 22:30:38 +01:00
2021-12-15 13:08:34 +01:00
2021-08-19 09:02:55 +09:00
2022-01-17 07:26:43 +02:00
2021-09-27 11:26:21 -07:00
2021-09-22 10:56:34 -07:00
2022-01-22 11:04:27 +02:00
2021-12-17 16:56:35 +09:00
2022-01-22 08:33:34 +02:00
2021-09-19 22:35:37 -04:00
2021-11-17 09:26:09 +01:00
2021-08-18 22:08:24 +02:00
2021-09-05 10:15:05 -07:00
2021-10-08 12:06:02 -05:00
2022-01-20 08:52:54 +02:00
2021-06-29 10:53:50 -07:00
2022-01-22 08:33:35 +02:00
2021-12-16 15:49:51 -05:00
2022-01-22 08:33:36 +02:00
2021-11-06 13:30:32 -07:00
2021-12-18 08:04:53 -08:00
2022-01-22 08:33:36 +02:00
2021-10-25 10:36:24 -06:00
2021-09-03 09:58:10 -07:00
2021-09-06 07:20:56 -04:00
2022-01-22 08:33:35 +02:00
2022-01-22 08:33:36 +02:00
2021-09-03 10:08:28 -07:00
2022-01-22 08:33:36 +02:00
2021-12-13 10:55:30 -08:00
2021-08-23 01:25:40 -04:00
2022-01-18 09:23:19 +02:00
2021-12-09 14:09:36 -05:00
2022-01-12 13:45:12 -08:00
2022-01-22 08:33:35 +02:00
2021-12-16 15:49:51 -05:00
2022-01-18 19:28:43 -07:00
2022-01-21 16:07:21 +02:00
2022-01-17 05:49:30 +02:00
2022-01-15 16:30:25 +02:00
2022-01-07 13:40:39 +00:00
2021-07-25 22:33:03 -07:00
2021-10-18 20:22:03 -10:00
2021-11-03 15:43:08 +01:00
2022-01-22 08:33:36 +02:00
2022-01-22 08:33:36 +02:00
2022-01-22 08:33:38 +02:00
2022-01-22 08:33:36 +02:00
2022-01-22 08:33:36 +02:00
2021-12-05 10:28:57 +01:00
2022-01-22 08:33:36 +02:00
2021-12-05 10:28:57 +01:00
2021-12-03 18:44:06 +01:00
2021-10-26 12:20:50 -04:00
2022-01-08 00:28:41 -05:00
2022-01-11 09:03:05 -08:00
2021-11-09 10:02:52 -08:00
2022-01-17 05:49:30 +02:00
2021-08-17 11:47:43 +02:00
2022-01-22 08:33:38 +02:00
2021-10-22 08:36:55 -06:00
2022-01-22 08:33:36 +02:00
2021-08-10 17:57:22 +02:00
2022-01-15 16:30:27 +02:00