syzbot


KASAN: use-after-free Write in get_block

Status: fixed on 2020/09/16 22:51
Subsystems: fs
[Documentation on labels]
Reported-by: syzbot+c7d9ec7a1a7272dd71b3@syzkaller.appspotmail.com
Fix commit: 270ef41094e9 fs/minix: reject too-large maximum file size
First crash: 1454d, last: 1400d
Cause bisection: the issue happens on the oldest tested release (bisect log)
Crash: WARNING in sysfs_warn_dup (log)
Repro: syz .config
  
Fix bisection the fix commit could be any of (bisect log):
  5d5103595e9e x86/cpu: Reinitialize IA32_FEAT_CTL MSR on BSP during wakeup
  cc5277fe66cf x86/resctrl: Fix a NULL vs IS_ERR() static checker warning in rdt_cdp_peer_get()
  8e742aa79780 syscalls: Fix offset type of ksys_ftruncate()
  a13b9d0b9721 x86/cpu: Use pinning mask for CR4 bits needing to be 0
  2c18bd525c47 x86/resctrl: Fix memory bandwidth counter width for AMD
  bb5570ad3b54 x86/asm/64: Align start of __clear_user() loop to 16-bytes
  098c7938217d Merge tag 'x86_urgent_for_5.8_rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
  
Discussions (10)
Title Replies (including bot) Last reply
[PATCH 4.4 000/149] 4.4.233-rc1 review 163 (163) 2020/10/31 20:04
[PATCH 4.9 000/212] 4.9.233-rc1 review 220 (220) 2020/08/21 09:40
[PATCH 4.19 000/168] 4.19.140-rc1 review 183 (183) 2020/08/21 08:05
[PATCH 4.14 000/228] 4.14.194-rc1 review 234 (234) 2020/08/21 06:59
[PATCH 5.8 000/464] 5.8.2-rc1 review 475 (475) 2020/08/19 06:11
[PATCH 5.4 000/270] 5.4.59-rc1 review 275 (275) 2020/08/18 22:37
[PATCH 5.7 000/393] 5.7.16-rc1 review 398 (398) 2020/08/18 22:36
[patch 100/165] fs/minix: reject too-large maximum file size 1 (1) 2020/08/12 01:35
[PATCH 0/6] fs/minix: fix syzbot bugs and set s_maxbytes 10 (10) 2020/07/07 20:34
KASAN: use-after-free Write in get_block 0 (2) 2020/05/14 16:14
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Write in get_block C inconclusive 5 1427d 1475d 0/1 upstream: reported C repro on 2020/04/12 23:36
linux-4.19 KASAN: use-after-free Write in get_block 3 1453d 1472d 0/1 auto-closed as invalid on 2020/09/02 00:35

Sample crash report:
MINIX-fs: mounting unchecked file system, running fsck is recommended
Process accounting resumed
Process accounting resumed
==================================================================
BUG: KASAN: use-after-free in alloc_branch fs/minix/itree_common.c:92 [inline]
BUG: KASAN: use-after-free in get_block+0x1202/0x1380 fs/minix/itree_common.c:191
Write of size 2 at addr ffff8880894397b8 by task syz-executor843/7050

CPU: 0 PID: 7050 Comm: syz-executor843 Not tainted 5.7.0-rc5-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x188/0x20d lib/dump_stack.c:118
 print_address_description.constprop.0.cold+0xd3/0x413 mm/kasan/report.c:382
 __kasan_report.cold+0x20/0x38 mm/kasan/report.c:511
 kasan_report+0x33/0x50 mm/kasan/common.c:625
 alloc_branch fs/minix/itree_common.c:92 [inline]
 get_block+0x1202/0x1380 fs/minix/itree_common.c:191
 minix_get_block+0xe5/0x110 fs/minix/inode.c:376
 __block_write_begin_int+0x490/0x1b00 fs/buffer.c:2013
 __block_write_begin fs/buffer.c:2063 [inline]
 block_write_begin+0x58/0x2e0 fs/buffer.c:2122
 minix_write_begin+0x35/0xe0 fs/minix/inode.c:412
 generic_perform_write+0x20a/0x4e0 mm/filemap.c:3302
 __generic_file_write_iter+0x24c/0x610 mm/filemap.c:3431
 generic_file_write_iter+0x3f3/0x630 mm/filemap.c:3463
 call_write_iter include/linux/fs.h:1907 [inline]
 new_sync_write+0x4a2/0x700 fs/read_write.c:484
 __vfs_write+0xc9/0x100 fs/read_write.c:497
 __kernel_write+0x11c/0x3a0 fs/read_write.c:516
 do_acct_process+0xcdc/0x10e0 kernel/acct.c:522
 acct_pin_kill+0x29/0xf0 kernel/acct.c:174
 pin_kill+0x175/0x7c0 fs/fs_pin.c:44
 mnt_pin_kill+0x6c/0x1c0 fs/fs_pin.c:81
 cleanup_mnt+0x3c4/0x4b0 fs/namespace.c:1095
 task_work_run+0xf4/0x1b0 kernel/task_work.c:123
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xb34/0x2dd0 kernel/exit.c:796
 do_group_exit+0x125/0x340 kernel/exit.c:894
 get_signal+0x47b/0x24e0 kernel/signal.c:2739
 do_signal+0x81/0x2240 arch/x86/kernel/signal.c:784
 exit_to_usermode_loop+0x26c/0x360 arch/x86/entry/common.c:161
 prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:279 [inline]
 do_syscall_64+0x6b1/0x7d0 arch/x86/entry/common.c:305
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x44a639
Code: Bad RIP value.
RSP: 002b:00007f46cd2eccf8 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00000000006dcc28 RCX: 000000000044a639
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00000000006dcc28
RBP: 00000000006dcc20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dcc2c
R13: 00007ffd8ef602ef R14: 00007f46cd2ed9c0 R15: 00000000006dcc2c

The buggy address belongs to the page:
page:ffffea0002250e40 refcount:0 mapcount:0 mapping:0000000029fef0ff index:0x1
flags: 0xfffe0000000000()
raw: 00fffe0000000000 ffffea00021144c8 ffffea000224a4c8 0000000000000000
raw: 0000000000000001 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff888089439680: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888089439700: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffff888089439780: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                        ^
 ffff888089439800: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffff888089439880: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================

Crashes (12):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/05/16 07:15 upstream 12bf0b632ed0 37bccd4e .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/05/15 23:36 upstream 1ae7efb38854 d7f9fffa .config console log report syz C ci-upstream-kasan-gce-selinux-root
2020/05/15 22:44 upstream 1ae7efb38854 d7f9fffa .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/05/15 04:34 upstream 8c1684bb81f1 2d572622 .config console log report syz C ci-upstream-kasan-gce-root
2020/05/15 01:12 upstream 8c1684bb81f1 2d572622 .config console log report syz C ci-upstream-kasan-gce-smack-root
2020/05/15 05:01 linux-next ac935d227366 2d572622 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/05/14 16:13 linux-next ac935d227366 2d572622 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/05/16 18:08 upstream 12bf0b632ed0 37bccd4e .config console log report syz ci-upstream-kasan-gce-selinux-root
2020/05/03 11:20 linux-next ac935d227366 5457883a .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/06/26 10:39 upstream 4a21185cda0f aea82c00 .config console log report ci-upstream-kasan-gce-selinux-root
2020/05/05 01:23 linux-next ac935d227366 9941337c .config console log report ci-upstream-linux-next-kasan-gce-root
2020/05/03 10:35 linux-next ac935d227366 5457883a .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.