syzbot


KASAN: use-after-free Read in do_blk_trace_setup

Status: fixed on 2020/06/19 01:27
Reported-by: syzbot+6986745bd39f48948eac@syzkaller.appspotmail.com
Fix commit: b390c22c0bc7 blktrace: fix unlocked access to init/start-stop/teardown
First crash: 2053d, last: 1649d
Fix bisection: fixed by (bisect log) :
commit b390c22c0bc7582e2cd3ee9f3f85606e6ebc78fa
Author: Jens Axboe <axboe@kernel.dk>
Date: Sun Nov 5 16:13:48 2017 +0000

  blktrace: fix unlocked access to init/start-stop/teardown

  
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in do_blk_trace_setup block trace C 4 2572d 2560d 0/28 closed as invalid on 2017/11/21 10:18

Sample crash report:
audit: type=1400 audit(1587343472.889:8): avc:  denied  { execmem } for  pid=6329 comm="syz-executor524" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=1
==================================================================
BUG: KASAN: use-after-free in do_blk_trace_setup+0xa5b/0xad0 kernel/trace/blktrace.c:561
Read of size 8 at addr ffff8880a0c44dc0 by task syz-executor524/6339

CPU: 1 PID: 6339 Comm: syz-executor524 Not tainted 4.14.176-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+0x13e/0x194 lib/dump_stack.c:58
 print_address_description.cold+0x7c/0x1e2 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/0x2ae mm/kasan/report.c:393
 do_blk_trace_setup+0xa5b/0xad0 kernel/trace/blktrace.c:561
 blk_trace_setup+0xa3/0x120 kernel/trace/blktrace.c:579
 sg_ioctl+0x2f9/0x2620 drivers/scsi/sg.c:1127
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xfe0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x44aef9
RSP: 002b:00007f2b10587ce8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000006dcc28 RCX: 000000000044aef9
RDX: 0000000020000080 RSI: 00000000c0481273 RDI: 0000000000000007
RBP: 00000000006dcc20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dcc2c
R13: 00007ffc1a56c28f R14: 00007f2b105889c0 R15: 0000000000000000

Allocated by task 6339:
 save_stack+0x32/0xa0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc mm/kasan/kasan.c:551 [inline]
 kasan_kmalloc+0xbf/0xe0 mm/kasan/kasan.c:529
 kmem_cache_alloc_trace+0x14d/0x7b0 mm/slab.c:3618
 kmalloc include/linux/slab.h:488 [inline]
 kzalloc include/linux/slab.h:661 [inline]
 do_blk_trace_setup+0x11e/0xad0 kernel/trace/blktrace.c:495
 blk_trace_setup+0xa3/0x120 kernel/trace/blktrace.c:579
 sg_ioctl+0x2f9/0x2620 drivers/scsi/sg.c:1127
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xfe0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 6351:
 save_stack+0x32/0xa0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xcb/0x260 mm/slab.c:3815
 blk_trace_cleanup kernel/trace/blktrace.c:351 [inline]
 blk_trace_remove+0x52/0x80 kernel/trace/blktrace.c:364
 sg_ioctl+0x22a/0x2620 drivers/scsi/sg.c:1136
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xfe0 fs/ioctl.c:684
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
 do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff8880a0c44d80
 which belongs to the cache kmalloc-128 of size 128
The buggy address is located 64 bytes inside of
 128-byte region [ffff8880a0c44d80, ffff8880a0c44e00)
The buggy address belongs to the page:
page:ffffea0002831100 count:1 mapcount:0 mapping:ffff8880a0c44000 index:0xffff8880a0c44a80
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff8880a0c44000 ffff8880a0c44a80 0000000100000009
raw: ffffea0002a00320 ffffea000280b420 ffff88812fe56640 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a0c44c80: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8880a0c44d00: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880a0c44d80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                           ^
 ffff8880a0c44e00: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8880a0c44e80: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================

Crashes (342):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/04/20 00:48 linux-4.14.y c10b57a567e4 9f7c6d12 .config console log report syz C ci2-linux-4-14
2020/04/17 09:28 linux-4.14.y c10b57a567e4 18397578 .config console log report syz C ci2-linux-4-14
2020/03/18 02:13 linux-4.14.y 12cd844a39ed 97bc55ce .config console log report syz C ci2-linux-4-14
2019/04/17 17:38 linux-4.14.y 58b454ebf81e b0e8efcb .config console log report syz C ci2-linux-4-14
2019/04/16 01:47 linux-4.14.y 1ec8f1f0bffe 505ab413 .config console log report syz C ci2-linux-4-14
2019/04/11 13:43 linux-4.14.y 1ec8f1f0bffe e955ac50 .config console log report syz C ci2-linux-4-14
2020/05/19 14:37 linux-4.14.y ab9dfda23248 6d882fd2 .config console log report ci2-linux-4-14
2020/05/18 20:33 linux-4.14.y ab9dfda23248 24d91142 .config console log report ci2-linux-4-14
2020/05/18 10:42 linux-4.14.y ab9dfda23248 24d91142 .config console log report ci2-linux-4-14
2020/05/16 08:36 linux-4.14.y ab9dfda23248 37bccd4e .config console log report ci2-linux-4-14
2020/05/15 23:50 linux-4.14.y ab9dfda23248 d7f9fffa .config console log report ci2-linux-4-14
2020/05/15 00:41 linux-4.14.y ab9dfda23248 2d572622 .config console log report ci2-linux-4-14
2020/05/14 10:46 linux-4.14.y ab9dfda23248 2d572622 .config console log report ci2-linux-4-14
2020/05/12 20:47 linux-4.14.y ab9dfda23248 a44eb8f7 .config console log report ci2-linux-4-14
2020/05/12 08:13 linux-4.14.y ab9dfda23248 a497a5b4 .config console log report ci2-linux-4-14
2020/05/11 20:57 linux-4.14.y ab9dfda23248 9eb09c40 .config console log report ci2-linux-4-14
2020/05/11 07:47 linux-4.14.y ab9dfda23248 f8f57555 .config console log report ci2-linux-4-14
2020/05/11 01:28 linux-4.14.y ab9dfda23248 8742a2b9 .config console log report ci2-linux-4-14
2020/05/10 17:47 linux-4.14.y ab9dfda23248 8742a2b9 .config console log report ci2-linux-4-14
2020/05/10 02:42 linux-4.14.y d71f695ce745 8742a2b9 .config console log report ci2-linux-4-14
2020/05/09 13:51 linux-4.14.y d71f695ce745 e97b06d3 .config console log report ci2-linux-4-14
2020/05/08 17:37 linux-4.14.y d71f695ce745 fe4122c3 .config console log report ci2-linux-4-14
2020/05/08 12:06 linux-4.14.y d71f695ce745 fe4122c3 .config console log report ci2-linux-4-14
2020/05/08 12:00 linux-4.14.y d71f695ce745 fe4122c3 .config console log report ci2-linux-4-14
2020/05/08 05:55 linux-4.14.y d71f695ce745 6c70a1c2 .config console log report ci2-linux-4-14
2020/05/07 01:16 linux-4.14.y d71f695ce745 4618eb2d .config console log report ci2-linux-4-14
2020/05/06 22:56 linux-4.14.y d71f695ce745 4618eb2d .config console log report ci2-linux-4-14
2020/05/06 14:11 linux-4.14.y d71f695ce745 4618eb2d .config console log report ci2-linux-4-14
2020/05/05 17:50 linux-4.14.y d71f695ce745 4b76dd25 .config console log report ci2-linux-4-14
2020/05/05 16:03 linux-4.14.y 773e2b1cd56a 4b76dd25 .config console log report ci2-linux-4-14
2020/05/05 14:35 linux-4.14.y 773e2b1cd56a 4b76dd25 .config console log report ci2-linux-4-14
2020/05/04 11:57 linux-4.14.y 773e2b1cd56a 58ae5e18 .config console log report ci2-linux-4-14
2020/05/04 06:32 linux-4.14.y 773e2b1cd56a 58ae5e18 .config console log report ci2-linux-4-14
2020/05/03 10:57 linux-4.14.y 773e2b1cd56a 5457883a .config console log report ci2-linux-4-14
2020/05/02 21:55 linux-4.14.y 773e2b1cd56a 58da4c35 .config console log report ci2-linux-4-14
2020/05/02 08:29 linux-4.14.y 050272a0423e bc734e7a .config console log report ci2-linux-4-14
2020/05/02 03:01 linux-4.14.y 050272a0423e bc734e7a .config console log report ci2-linux-4-14
2020/05/02 02:51 linux-4.14.y 050272a0423e bc734e7a .config console log report ci2-linux-4-14
2020/04/30 22:38 linux-4.14.y 050272a0423e 3698959a .config console log report ci2-linux-4-14
2020/04/30 00:50 linux-4.14.y 050272a0423e 2dd552a5 .config console log report ci2-linux-4-14
2020/04/29 16:47 linux-4.14.y 050272a0423e ba2806db .config console log report ci2-linux-4-14
2020/04/29 14:13 linux-4.14.y 050272a0423e ba2806db .config console log report ci2-linux-4-14
2020/04/29 06:09 linux-4.14.y 050272a0423e e3ecea2e .config console log report ci2-linux-4-14
2020/04/28 04:59 linux-4.14.y 050272a0423e 0ce7569e .config console log report ci2-linux-4-14
2020/04/25 04:42 linux-4.14.y 050272a0423e 03d97a1b .config console log report ci2-linux-4-14
2020/04/24 06:14 linux-4.14.y c10b57a567e4 03d97a1b .config console log report ci2-linux-4-14
2020/04/24 01:33 linux-4.14.y c10b57a567e4 b9233cab .config console log report ci2-linux-4-14
2020/04/23 06:06 linux-4.14.y c10b57a567e4 2e44d63e .config console log report ci2-linux-4-14
2019/04/11 12:15 linux-4.14.y 1ec8f1f0bffe e955ac50 .config console log report ci2-linux-4-14
* Struck through repros no longer work on HEAD.