================================================================== BUG: KASAN: use-after-free in list_empty include/linux/list.h:189 [inline] BUG: KASAN: use-after-free in sg_remove_request+0xf9/0x110 drivers/scsi/sg.c:2120 Read of size 8 at addr ffff8801d28a61c0 by task syz-executor2/11272 CPU: 1 PID: 11272 Comm: syz-executor2 Not tainted 4.4.120-gd63fdf6 #29 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 0000000000000000 3b5df311781a19eb ffff8800b6587a40 ffffffff81d0408d ffffea00074a2980 ffff8801d28a61c0 0000000000000000 ffff8801d28a61c0 ffff8800b6d90238 ffff8800b6587a78 ffffffff814fe143 ffff8801d28a61c0 Call Trace: [] __dump_stack lib/dump_stack.c:15 [inline] [] dump_stack+0xc1/0x124 lib/dump_stack.c:51 [] print_address_description+0x73/0x260 mm/kasan/report.c:252 [] kasan_report_error mm/kasan/report.c:351 [inline] [] kasan_report+0x285/0x370 mm/kasan/report.c:408 [] __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:429 [] list_empty include/linux/list.h:189 [inline] [] sg_remove_request+0xf9/0x110 drivers/scsi/sg.c:2120 [] sg_finish_rem_req+0x295/0x340 drivers/scsi/sg.c:1837 [] sg_read+0xa1b/0x1490 drivers/scsi/sg.c:537 [] __vfs_read+0x103/0x440 fs/read_write.c:432 [] vfs_read+0x123/0x3a0 fs/read_write.c:454 [] SYSC_read fs/read_write.c:569 [inline] [] SyS_read+0xd9/0x1b0 fs/read_write.c:562 [] do_syscall_32_irqs_on arch/x86/entry/common.c:392 [inline] [] do_fast_syscall_32+0x321/0x8a0 arch/x86/entry/common.c:459 [] sysenter_flags_fixed+0xd/0x17 Allocated by task 9773: [] save_stack_trace+0x26/0x50 arch/x86/kernel/stacktrace.c:63 [] save_stack+0x43/0xd0 mm/kasan/kasan.c:512 [] set_track mm/kasan/kasan.c:524 [inline] [] kasan_kmalloc+0xad/0xe0 mm/kasan/kasan.c:616 [] kasan_slab_alloc+0x12/0x20 mm/kasan/kasan.c:554 [] slab_post_alloc_hook mm/slub.c:1349 [inline] [] slab_alloc_node mm/slub.c:2615 [inline] [] slab_alloc mm/slub.c:2623 [inline] [] kmem_cache_alloc+0xba/0x290 mm/slub.c:2628 [] fasync_alloc fs/fcntl.c:607 [inline] [] fasync_add_entry fs/fcntl.c:665 [inline] [] fasync_helper+0x37/0xb0 fs/fcntl.c:694 [] random_fasync+0x2a/0x40 drivers/char/random.c:1587 [] ioctl_fioasync fs/ioctl.c:511 [inline] [] do_vfs_ioctl+0x981/0xee0 fs/ioctl.c:576 [] C_SYSC_ioctl fs/compat_ioctl.c:1614 [inline] [] compat_SyS_ioctl+0x64e/0x2540 fs/compat_ioctl.c:1544 [] do_syscall_32_irqs_on arch/x86/entry/common.c:392 [inline] [] do_fast_syscall_32+0x321/0x8a0 arch/x86/entry/common.c:459 [] sysenter_flags_fixed+0xd/0x17 Freed by task 9794: [] save_stack_trace+0x26/0x50 arch/x86/kernel/stacktrace.c:63 [] save_stack+0x43/0xd0 mm/kasan/kasan.c:512 [] set_track mm/kasan/kasan.c:524 [inline] [] kasan_slab_free+0x72/0xc0 mm/kasan/kasan.c:589 [] slab_free_hook mm/slub.c:1383 [inline] [] slab_free_freelist_hook mm/slub.c:1405 [inline] [] slab_free mm/slub.c:2859 [inline] [] kmem_cache_free+0xc7/0x320 mm/slub.c:2881 [] fasync_free_rcu+0x1d/0x20 fs/fcntl.c:566 [] __rcu_reclaim kernel/rcu/rcu.h:118 [inline] [] rcu_do_batch kernel/rcu/tree.c:2705 [inline] [] invoke_rcu_callbacks kernel/rcu/tree.c:2973 [inline] [] __rcu_process_callbacks kernel/rcu/tree.c:2940 [inline] [] rcu_process_callbacks+0x7f4/0x14a0 kernel/rcu/tree.c:2957 [] __do_softirq+0x227/0xa38 kernel/softirq.c:273 The buggy address belongs to the object at ffff8801d28a6180 which belongs to the cache fasync_cache of size 96 The buggy address is located 64 bytes inside of 96-byte region [ffff8801d28a6180, ffff8801d28a61e0) The buggy address belongs to the page: INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. CPU: 0 PID: 3857 Comm: syz-executor0 Not tainted 4.4.120-gd63fdf6 #29 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 0000000000000000 6d1b84cefc86e9a6 ffff8800ba9279d0 ffffffff81d0408d ffffffff8514e270 0000000000000000 ffff8801d8d1e000 ffff8800b639aa38 0000000000000000 ffff8800ba9279e0 ffffffff8141adb3 ffff8800ba927b88 Call Trace: [] __dump_stack lib/dump_stack.c:15 [inline] [] dump_stack+0xc1/0x124 lib/dump_stack.c:51 [] register_lock_class.part.26+0x32/0x36 kernel/locking/lockdep.c:762 [] register_lock_class kernel/locking/lockdep.c:767 [inline] [] __lock_acquire+0x3a49/0x4b50 kernel/locking/lockdep.c:3101 [] lock_acquire+0x15e/0x460 kernel/locking/lockdep.c:3592 [] __raw_spin_lock include/linux/spinlock_api_smp.h:144 [inline] [] _raw_spin_lock+0x36/0x50 kernel/locking/spinlock.c:151 [] spin_lock include/linux/spinlock.h:302 [inline] [] fast_dput fs/dcache.c:677 [inline] [] dput.part.19+0x3b0/0x760 fs/dcache.c:784 [] dput+0x1f/0x30 fs/dcache.c:777 [] path_put+0x31/0x70 fs/namei.c:505 [] free_fs_struct+0x16/0x60 fs/fs_struct.c:89 [] exit_fs+0xe1/0x120 fs/fs_struct.c:108 [] do_exit+0x803/0x2a10 kernel/exit.c:751 [] do_group_exit+0x108/0x320 kernel/exit.c:885 [] SYSC_exit_group kernel/exit.c:896 [inline] [] SyS_exit_group+0x1d/0x20 kernel/exit.c:894 [] do_syscall_32_irqs_on arch/x86/entry/common.c:392 [inline] [] do_fast_syscall_32+0x321/0x8a0 arch/x86/entry/common.c:459 [] sysenter_flags_fixed+0xd/0x17 kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory accessgeneral protection fault: 0000 [#1] PREEMPT SMP KASAN Dumping ftrace buffer: (ftrace buffer empty) Modules linked in: CPU: 0 PID: 3857 Comm: syz-executor0 Not tainted 4.4.120-gd63fdf6 #29 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 task: ffff8801d8d1e000 task.stack: ffff8800ba920000 RIP: 0010:[] [] ____rb_erase_color lib/rbtree.c:263 [inline] RIP: 0010:[] [] rb_erase+0x626/0x1b60 lib/rbtree.c:429 RSP: 0018:ffff8801db207d38 EFLAGS: 00010003 RAX: ffff8801c712fe00 RBX: ffff8801c712fdf8 RCX: 0a0508a8e82a0be9 RDX: ffffed003b6432e2 RSI: ffff8801db219710 RDI: ffffffff838a9068 RBP: ffff8801db207d80 R08: 1ffff1003b0ef73e R09: 0000000000000000 R10: 0000000000000000 R11: 1ffff1003b640f6a R12: dffffc0000000000 R13: ffffffff838a9060 R14: 2862616c53656761 R15: 5028454741505f4e FS: 0000000000000000(0000) GS:ffff8801db200000(0000) knlGS:0000000000000000 CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033 CR2: 0000000000000000 CR3: 000000000420c000 CR4: 0000000000160670 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Stack: ffff8801db219c40 0000000041b58ab3 ffffffff83fce929 ffffffff81d65e60 ffff8801db219c40 ffff8801db219710 ffff8801db219718 0000000000000000 0000000000000000 ffff8801db207db0 ffffffff81d21b68 dffffc0000000000 Call Trace: [] timerqueue_del+0x78/0x170 lib/timerqueue.c:86 [] __remove_hrtimer+0x90/0x250 kernel/time/hrtimer.c:916 [] __run_hrtimer kernel/time/hrtimer.c:1241 [inline] [] __hrtimer_run_queues+0x238/0xfe0 kernel/time/hrtimer.c:1324 [] hrtimer_interrupt+0x1a6/0x440 kernel/time/hrtimer.c:1358 [] local_apic_timer_interrupt+0x6a/0xb0 arch/x86/kernel/apic/apic.c:901 [] smp_apic_timer_interrupt+0x76/0xa0 arch/x86/kernel/apic/apic.c:925 [] apic_timer_interrupt+0xa0/0xb0 arch/x86/entry/entry_64.S:737 [] __raw_spin_lock include/linux/spinlock_api_smp.h:144 [inline] [] _raw_spin_lock+0x36/0x50 kernel/locking/spinlock.c:151 [] spin_lock include/linux/spinlock.h:302 [inline] [] fast_dput fs/dcache.c:677 [inline] [] dput.part.19+0x3b0/0x760 fs/dcache.c:784 [] dput+0x1f/0x30 fs/dcache.c:777 [] path_put+0x31/0x70 fs/namei.c:505 [] free_fs_struct+0x16/0x60 fs/fs_struct.c:89 [] exit_fs+0xe1/0x120 fs/fs_struct.c:108 [] do_exit+0x803/0x2a10 kernel/exit.c:751 [] do_group_exit+0x108/0x320 kernel/exit.c:885 [] SYSC_exit_group kernel/exit.c:896 [inline] [] SyS_exit_group+0x1d/0x20 kernel/exit.c:894 [] do_syscall_32_irqs_on arch/x86/entry/common.c:392 [inline] [] do_fast_syscall_32+0x321/0x8a0 arch/x86/entry/common.c:459 [] sysenter_flags_fixed+0xd/0x17 Code: f5 4d 8b 76 10 49 8d 7d 08 48 89 f9 48 c1 e9 03 42 80 3c 21 00 0f 85 84 0b 00 00 4d 8b 7d 08 4d 85 ff 74 1c 4c 89 f9 48 c1 e9 03 <42> 80 3c 21 00 0f 85 44 0b 00 00 41 f6 07 01 0f 84 12 06 00 00 RIP [] ____rb_erase_color lib/rbtree.c:263 [inline] RIP [] rb_erase+0x626/0x1b60 lib/rbtree.c:429 RSP ---[ end trace b09a5396229184c3 ]---