Tudor Ambarus
6d9a705a65
ext4: avoid a potential slab-out-of-bounds in ext4_group_desc_csum
...
commit 4f04351888a83e595571de672e0a4a8b74f4fb31 upstream.
When modifying the block device while it is mounted by the filesystem,
syzbot reported the following:
BUG: KASAN: slab-out-of-bounds in crc16+0x206/0x280 lib/crc16.c:58
Read of size 1 at addr ffff888075f5c0a8 by task syz-executor.2/15586
CPU: 1 PID: 15586 Comm: syz-executor.2 Not tainted 6.2.0-rc5-syzkaller-00205-gc96618275234 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1b1/0x290 lib/dump_stack.c:106
print_address_description+0x74/0x340 mm/kasan/report.c:306
print_report+0x107/0x1f0 mm/kasan/report.c:417
kasan_report+0xcd/0x100 mm/kasan/report.c:517
crc16+0x206/0x280 lib/crc16.c:58
ext4_group_desc_csum+0x81b/0xb20 fs/ext4/super.c:3187
ext4_group_desc_csum_set+0x195/0x230 fs/ext4/super.c:3210
ext4_mb_clear_bb fs/ext4/mballoc.c:6027 [inline]
ext4_free_blocks+0x191a/0x2810 fs/ext4/mballoc.c:6173
ext4_remove_blocks fs/ext4/extents.c:2527 [inline]
ext4_ext_rm_leaf fs/ext4/extents.c:2710 [inline]
ext4_ext_remove_space+0x24ef/0x46a0 fs/ext4/extents.c:2958
ext4_ext_truncate+0x177/0x220 fs/ext4/extents.c:4416
ext4_truncate+0xa6a/0xea0 fs/ext4/inode.c:4342
ext4_setattr+0x10c8/0x1930 fs/ext4/inode.c:5622
notify_change+0xe50/0x1100 fs/attr.c:482
do_truncate+0x200/0x2f0 fs/open.c:65
handle_truncate fs/namei.c:3216 [inline]
do_open fs/namei.c:3561 [inline]
path_openat+0x272b/0x2dd0 fs/namei.c:3714
do_filp_open+0x264/0x4f0 fs/namei.c:3741
do_sys_openat2+0x124/0x4e0 fs/open.c:1310
do_sys_open fs/open.c:1326 [inline]
__do_sys_creat fs/open.c:1402 [inline]
__se_sys_creat fs/open.c:1396 [inline]
__x64_sys_creat+0x11f/0x160 fs/open.c:1396
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f72f8a8c0c9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f72f97e3168 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 00007f72f8bac050 RCX: 00007f72f8a8c0c9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000020000280
RBP: 00007f72f8ae7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd165348bf R14: 00007f72f97e3300 R15: 0000000000022000
Replace
le16_to_cpu(sbi->s_es->s_desc_size)
with
sbi->s_desc_size
It reduces ext4's compiled text size, and makes the code more efficient
(we remove an extra indirect reference and a potential byte
swap on big endian systems), and there is no downside. It also avoids the
potential KASAN / syzkaller failure, as a bonus.
Reported-by: syzbot+fc51227e7100c9294894@syzkaller.appspotmail.com
Reported-by: syzbot+8785e41224a3afd04321@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?id=70d28d11ab14bd7938f3e088365252aa923cff42
Link: https://syzkaller.appspot.com/bug?id=b85721b38583ecc6b5e72ff524c67302abbc30f3
Link: https://lore.kernel.org/all/000000000000ece18705f3b20934@google.com/
Fixes: 717d50e4971b ("Ext4: Uninitialized Block Groups")
Cc: stable@vger.kernel.org
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Link: https://lore.kernel.org/r/20230504121525.3275886-1-tudor.ambarus@linaro.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-17 11:50:29 +02:00
..
2022-08-17 14:24:07 +02:00
2023-02-01 08:27:06 +01:00
2023-05-11 23:00:38 +09:00
2021-10-20 21:09:02 -04:00
2021-08-19 09:02:55 +09:00
2023-05-17 11:50:22 +02:00
2022-07-02 16:41:14 +02:00
2023-03-10 09:40:08 +01:00
2023-05-17 11:50:23 +02:00
2023-03-10 09:39:50 +01:00
2022-12-31 13:14:15 +01:00
2022-11-10 18:15:37 +01:00
2022-12-31 13:14:03 +01:00
2022-02-01 17:27:01 +01:00
2023-03-17 08:48:50 +01:00
2022-07-02 16:41:14 +02:00
2023-05-11 23:00:20 +09:00
2023-03-10 09:39:58 +01:00
2022-06-09 10:23:32 +02:00
2022-10-26 12:35:51 +02:00
2023-05-17 11:50:29 +02:00
2023-05-17 11:50:25 +02:00
2022-06-09 10:22:42 +02:00
2021-10-04 22:13:12 +01:00
2023-04-26 13:51:54 +02:00
2023-03-10 09:39:53 +01:00
2023-03-10 09:39:57 +01:00
2023-03-10 09:39:57 +01:00
2021-08-26 22:28:02 +02:00
2021-07-27 11:00:36 +02:00
2022-12-31 13:14:44 +01:00
2022-06-09 10:22:55 +02:00
2021-11-12 15:05:50 +01:00
2023-05-11 23:00:29 +09:00
2023-03-22 13:31:30 +01:00
2023-03-11 13:57:22 +01:00
2022-11-03 23:59:13 +09:00
2023-05-17 11:50:29 +02:00
2023-03-30 12:47:56 +02:00
2022-04-13 20:59:10 +02:00
2021-12-29 12:28:59 +01:00
2023-05-11 23:00:36 +09:00
2021-10-04 22:02:17 +01:00
2023-04-13 16:48:19 +02:00
2023-05-11 23:00:39 +09:00
2023-05-17 11:50:22 +02:00
2022-11-26 09:24:52 +01:00
2023-05-17 11:50:26 +02:00
2023-04-13 16:48:26 +02:00
2022-12-31 13:14:44 +01:00
2023-02-09 11:26:47 +01:00
2023-02-09 11:26:44 +01:00
2023-05-11 23:00:31 +09:00
2021-09-21 08:36:48 -07:00
2023-01-12 11:59:01 +01:00
2023-05-11 23:00:17 +09:00
2021-12-14 10:57:12 +01:00
2023-02-22 12:57:07 +01:00
2021-08-06 13:05:28 +02:00
2022-12-31 13:14:05 +01:00
2022-09-20 12:39:43 +02:00
2023-05-17 11:50:14 +02:00
2023-03-17 08:48:50 +01:00
2021-08-19 09:02:55 +09:00
2021-09-27 11:26:21 -07:00
2023-04-05 11:24:51 +02:00
2023-05-11 23:00:18 +09:00
2023-04-05 11:25:01 +02:00
2023-02-22 12:57:05 +01:00
2023-03-17 08:49:01 +01:00
2021-08-18 22:08:24 +02:00
2021-09-05 10:15:05 -07:00
2023-01-12 11:58:46 +01:00
2022-11-03 23:59:12 +09:00
2022-06-09 10:22:26 +02:00
2022-12-31 13:14:39 +01:00
2022-11-26 09:24:51 +01:00
2022-12-31 13:14:30 +01:00
2022-04-08 14:24:18 +02:00
2021-09-02 10:07:29 -07:00
2022-09-28 11:11:56 +02:00
2021-09-03 09:58:10 -07:00
2023-01-24 07:22:43 +01:00
2023-01-24 07:22:43 +01:00
2022-11-03 23:59:12 +09:00
2021-09-03 10:08:28 -07:00
2022-10-26 12:34:58 +02:00
2023-03-17 08:48:47 +01:00
2021-08-23 01:25:40 -04:00
2022-01-20 09:13:14 +01:00
2021-09-07 16:07:47 -04:00
2023-05-17 11:50:16 +02:00
2023-03-17 08:49:01 +01:00
2023-03-17 08:49:01 +01:00
2022-05-25 09:57:26 +02:00
2021-09-12 10:10:21 -07:00
2021-07-25 22:33:03 -07:00
2021-10-18 20:22:03 -10:00
2022-12-31 13:14:03 +01:00
2023-03-17 08:49:02 +01:00
2022-12-14 11:37:31 +01:00
2023-01-12 11:59:20 +01:00
2023-03-17 08:49:00 +01:00
2023-04-13 16:48:25 +02:00
2023-03-17 08:49:01 +01:00
2022-06-06 08:43:37 +02:00
2023-01-12 11:58:47 +01:00
2022-07-02 16:41:17 +02:00
2022-07-02 16:41:14 +02:00
2022-12-19 12:36:39 +01:00
2022-07-21 21:24:14 +02:00
2022-01-29 10:58:25 +01:00
2022-07-12 16:35:08 +02:00
2021-12-14 10:57:15 +01:00
2022-10-26 12:34:17 +02:00
2022-04-27 14:38:57 +02:00
2023-03-30 12:47:56 +02:00
2022-04-27 14:38:50 +02:00
2021-08-10 17:57:22 +02:00
2022-10-26 12:34:36 +02:00
2022-12-31 13:14:01 +01:00