KASAN: use-after-free Read in debugfs_remove

Status: upstream: reported C repro on 2019/04/17 06:08
First crash: 1220d, last: 665d

Fix bisection: the fix commit could be any of (bisect log):
  ddef1e8e3f6e Linux 4.14.151
  56dfe6252c68 Linux 4.14.188
similar bugs (4):
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in debugfs_remove (2) 1 1581d 1579d 6/23 fixed on 2018/05/17 10:02
linux-4.19 KASAN: use-after-free Read in debugfs_remove C done 15 656d 1153d 1/1 fixed on 2020/12/01 11:25
upstream KASAN: use-after-free Read in debugfs_remove (3) C done error 88 942d 1409d 0/23 closed as dup on 2020/06/28 17:08
upstream KASAN: use-after-free Read in debugfs_remove 1 1602d 1601d 0/23 closed as invalid on 2018/04/10 15:18

Sample crash report:
blktrace: Concurrent blktraces are not allowed on loop0
blktrace: Concurrent blktraces are not allowed on loop0
blktrace: Concurrent blktraces are not allowed on loop0
BUG: KASAN: use-after-free in debugfs_remove fs/debugfs/inode.c:662 [inline]
BUG: KASAN: use-after-free in debugfs_remove+0xef/0x110 fs/debugfs/inode.c:654
Read of size 8 at addr ffff8880a6b37340 by task kworker/0:0/3

CPU: 0 PID: 3 Comm: kworker/0:0 Not tainted 4.14.195-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: events __blk_release_queue
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x1b2/0x283 lib/dump_stack.c:58
 print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
 kasan_report_error.cold+0x8a/0x194 mm/kasan/report.c:351
 kasan_report mm/kasan/report.c:409 [inline]
 __asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:430
 debugfs_remove fs/debugfs/inode.c:662 [inline]
 debugfs_remove+0xef/0x110 fs/debugfs/inode.c:654
 blk_trace_free+0x31/0x130 kernel/trace/blktrace.c:327
 blk_trace_cleanup kernel/trace/blktrace.c:355 [inline]
 __blk_trace_remove+0x68/0xc0 kernel/trace/blktrace.c:368
 blk_trace_shutdown+0x77/0xe0 kernel/trace/blktrace.c:780
 __blk_release_queue+0x227/0x4b0 block/blk-sysfs.c:830
 process_one_work+0x793/0x14a0 kernel/workqueue.c:2116
 worker_thread+0x5cc/0xff0 kernel/workqueue.c:2250
 kthread+0x30d/0x420 kernel/kthread.c:232
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:404

Allocated by task 6910:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
 kmem_cache_alloc+0x124/0x3c0 mm/slab.c:3552
 __d_alloc+0x2a/0xa20 fs/dcache.c:1623
 d_alloc+0x46/0x240 fs/dcache.c:1710
 __lookup_hash fs/namei.c:1571 [inline]
 __lookup_hash+0x101/0x270 fs/namei.c:1563
 lookup_one_len+0x279/0x3a0 fs/namei.c:2539
 start_creating.part.0+0x62/0x150 fs/tracefs/inode.c:336
 start_creating fs/debugfs/inode.c:302 [inline]
 __debugfs_create_file+0x8a/0x480 fs/debugfs/inode.c:353
 do_blk_trace_setup+0x358/0xb80 kernel/trace/blktrace.c:554
 __blk_trace_setup+0xa3/0x120 kernel/trace/blktrace.c:603
 blk_trace_ioctl+0x136/0x250 kernel/trace/blktrace.c:744
 blkdev_ioctl+0xec/0x1830 block/ioctl.c:580
 block_ioctl+0xd9/0x120 fs/block_dev.c:1883
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:500 [inline]
 do_vfs_ioctl+0x75a/0xff0 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

Freed by task 7:
 save_stack mm/kasan/kasan.c:447 [inline]
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kmem_cache_free+0x7c/0x2b0 mm/slab.c:3758
 __rcu_reclaim kernel/rcu/rcu.h:195 [inline]
 rcu_do_batch kernel/rcu/tree.c:2699 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2962 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:2929 [inline]
 rcu_process_callbacks+0x780/0x1180 kernel/rcu/tree.c:2946
 __do_softirq+0x254/0xa1d kernel/softirq.c:288

The buggy address belongs to the object at ffff8880a6b37300
 which belongs to the cache dentry of size 288
The buggy address is located 64 bytes inside of
 288-byte region [ffff8880a6b37300, ffff8880a6b37420)
The buggy address belongs to the page:
page:ffffea00029acdc0 count:1 mapcount:0 mapping:ffff8880a6b37040 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff8880a6b37040 0000000000000000 000000010000000b
raw: ffffea00029acda0 ffffea00029ace20 ffff88821f8b9680 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a6b37200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a6b37280: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8880a6b37300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a6b37380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a6b37400: fb fb fb fb fc fc fc fc fc fc fc fc 00 00 00 00

Crashes (14):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci2-linux-4-14 2020/09/02 04:38 linux-4.14.y d7e78d08fa77 abf9ba4f .config log report syz C
ci2-linux-4-14 2019/11/06 04:59 linux-4.14.y ddef1e8e3f6e bc2c6e45 .config log report syz C
ci2-linux-4-14 2019/07/22 08:48 linux-4.14.y ff33472c282e b3c615f5 .config log report syz C
ci2-linux-4-14 2020/10/23 10:51 linux-4.14.y 5b7a52cd2eef 4e740c00 .config log report info
ci2-linux-4-14 2020/06/19 17:13 linux-4.14.y b850307b279c 123cf502 .config log report
ci2-linux-4-14 2020/03/23 05:53 linux-4.14.y 01364dad1d45 78267cec .config log report
ci2-linux-4-14 2020/02/14 11:06 linux-4.14.y e0f8b8a65a47 5d7b90f1 .config log report
ci2-linux-4-14 2019/11/30 03:03 linux-4.14.y 43598c571e7e 3a75be00 .config log report
ci2-linux-4-14 2019/11/08 12:26 linux-4.14.y c9fda4f22428 1e35461e .config log report
ci2-linux-4-14 2019/10/03 20:33 linux-4.14.y f6e27dbb1afa fc17ba49 .config log report
ci2-linux-4-14 2019/08/28 23:11 linux-4.14.y b5260801526c 40203c15 .config log report
ci2-linux-4-14 2019/06/26 12:55 linux-4.14.y bc2bccef19ee 4d342240 .config log report
ci2-linux-4-14 2019/04/19 00:10 linux-4.14.y 58b454ebf81e b0e8efcb .config log report
ci2-linux-4-14 2019/04/17 05:07 linux-4.14.y 1ec8f1f0bffe b0e8efcb .config log report