syzbot


KASAN: use-after-free Read in get_block

Status: fixed on 2020/09/11 21:52
Reported-by: syzbot+9520ccd94ee573ff7e5f@syzkaller.appspotmail.com
Fix commit: 0900097ef667 fs/minix: reject too-large maximum file size
First crash: 1687d, last: 1562d
Fix bisection: fixed by (bisect log) :
commit 0900097ef667097b0a4afb0155a4f5add77ece19
Author: Eric Biggers <ebiggers@google.com>
Date: Wed Aug 12 01:35:30 2020 +0000

  fs/minix: reject too-large maximum file size

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in get_block C done 23 1592d 1670d 15/28 fixed on 2020/09/16 22:51
linux-4.19 KASAN: use-after-free Read in get_block C done 6 1562d 1694d 1/1 fixed on 2020/09/11 09:49
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2020/09/11 15:40 3h49m bisect fix linux-4.14.y OK (1) job log
2020/08/11 22:23 25m bisect fix linux-4.14.y OK (0) job log log

Sample crash report:
audit: type=1800 audit(1594589502.166:9): pid=6356 uid=0 auid=0 ses=5 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor491" name="file0" dev="sda1" ino=15707 res=0
MINIX-fs: mounting unchecked file system, running fsck is recommended
Process accounting resumed
==================================================================
BUG: KASAN: use-after-free in add_chain fs/minix/itree_common.c:14 [inline]
BUG: KASAN: use-after-free in get_branch fs/minix/itree_common.c:52 [inline]
BUG: KASAN: use-after-free in get_block+0xe06/0x1100 fs/minix/itree_common.c:160
Read of size 2 at addr ffff8880a5fa318a by task syz-executor491/6356

CPU: 0 PID: 6356 Comm: syz-executor491 Not tainted 4.14.184-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x1b2/0x283 lib/dump_stack.c:58
 print_address_description.cold+0x54/0x1dc mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report mm/kasan/report.c:409 [inline]
 kasan_report.cold+0xa9/0x2b9 mm/kasan/report.c:393
 add_chain fs/minix/itree_common.c:14 [inline]
 get_branch fs/minix/itree_common.c:52 [inline]
 get_block+0xe06/0x1100 fs/minix/itree_common.c:160
 minix_get_block+0xd6/0x100 fs/minix/inode.c:379
 __block_write_begin_int+0x33a/0x1000 fs/buffer.c:2038
 __block_write_begin fs/buffer.c:2088 [inline]
 block_write_begin+0x58/0x260 fs/buffer.c:2147
 minix_write_begin+0x35/0xc0 fs/minix/inode.c:415
 generic_perform_write+0x1c9/0x420 mm/filemap.c:3047
 __generic_file_write_iter+0x227/0x590 mm/filemap.c:3172
 generic_file_write_iter+0x36f/0x650 mm/filemap.c:3200
 call_write_iter include/linux/fs.h:1778 [inline]
 new_sync_write fs/read_write.c:469 [inline]
 __vfs_write+0x44e/0x630 fs/read_write.c:482
 __kernel_write+0xf5/0x330 fs/read_write.c:501
 do_acct_process+0xb49/0xf60 kernel/acct.c:520
 slow_acct_process kernel/acct.c:579 [inline]
 acct_process+0x38a/0x422 kernel/acct.c:605
 do_exit+0x1728/0x2ae0 kernel/exit.c:848
 do_group_exit+0x100/0x2e0 kernel/exit.c:955
 SYSC_exit_group kernel/exit.c:966 [inline]
 SyS_exit_group+0x19/0x20 kernel/exit.c:964
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x444a18
RSP: 002b:00007fff1e105b38 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000444a18
RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
RBP: 00000000004c53f0 R08: 00000000000000e7 R09: ffffffffffffffd4
R10: 00007fff1e105a50 R11: 0000000000000246 R12: 0000000000000001
R13: 00000000006d7180 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 6089:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc.part.0+0x4f/0xd0 mm/kasan/kasan.c:551
 kmem_cache_alloc+0x124/0x3c0 mm/slab.c:3552
 dup_fd+0x81/0xa40 fs/file.c:285
 copy_files kernel/fork.c:1304 [inline]
 copy_process.part.0+0x1b58/0x6fa0 kernel/fork.c:1759
 copy_process kernel/fork.c:1586 [inline]
 _do_fork+0x180/0xc80 kernel/fork.c:2070
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 6116:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0xaf/0x190 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kmem_cache_free+0x7c/0x2b0 mm/slab.c:3758
 put_files_struct fs/file.c:426 [inline]
 put_files_struct+0x268/0x2d0 fs/file.c:418
 exit_files+0x7e/0xa0 fs/file.c:450
 do_exit+0x9d0/0x2ae0 kernel/exit.c:853
 do_group_exit+0x100/0x2e0 kernel/exit.c:955
 SYSC_exit_group kernel/exit.c:966 [inline]
 SyS_exit_group+0x19/0x20 kernel/exit.c:964
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x46/0xbb

The buggy address belongs to the object at ffff8880a5fa30c0
 which belongs to the cache files_cache of size 832
The buggy address is located 202 bytes inside of
 832-byte region [ffff8880a5fa30c0, ffff8880a5fa3400)
The buggy address belongs to the page:
page:ffffea000297e8c0 count:1 mapcount:0 mapping:ffff8880a5fa30c0 index:0xffff8880a5fa3840
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff8880a5fa30c0 ffff8880a5fa3840 0000000100000002
raw: ffffea0002a3a7a0 ffffea0002a13d20 ffff8880aa95d800 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a5fa3080: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8880a5fa3100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a5fa3180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff8880a5fa3200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a5fa3280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (8):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/07/12 21:34 linux-4.14.y b850307b279c 9ebcc5b1 .config console log report syz C ci2-linux-4-14
2020/05/02 05:38 linux-4.14.y 050272a0423e bc734e7a .config console log report syz C ci2-linux-4-14
2020/06/27 01:37 linux-4.14.y b850307b279c ffec44b5 .config console log report ci2-linux-4-14
2020/06/07 18:54 linux-4.14.y c6db52a88798 2c2b926c .config console log report ci2-linux-4-14
2020/05/10 21:38 linux-4.14.y ab9dfda23248 8742a2b9 .config console log report ci2-linux-4-14
2020/05/04 18:17 linux-4.14.y 773e2b1cd56a 58ae5e18 .config console log report ci2-linux-4-14
2020/05/02 05:17 linux-4.14.y 050272a0423e bc734e7a .config console log report ci2-linux-4-14
2020/04/08 21:21 linux-4.14.y 4520f06b03ae db9bcd4b .config console log report ci2-linux-4-14
* Struck through repros no longer work on HEAD.