syzbot


KASAN: use-after-free Read in relay_switch_subbuf (2)

Status: upstream: reported on 2021/10/17 18:33
Reported-by: syzbot+1a4f3a6cd1e92ae4ef9d@syzkaller.appspotmail.com
First crash: 1130d, last: 648d
Similar bugs (11)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in relay_switch_subbuf block trace C done error 93 754d 2248d 0/28 auto-obsoleted due to no activity on 2023/04/20 06:56
linux-5.15 KASAN: use-after-free Read in relay_switch_subbuf 2 567d 587d 0/3 auto-obsoleted due to no activity on 2023/08/23 09:04
linux-4.19 KASAN: use-after-free Read in relay_switch_subbuf 10 1609d 2033d 0/1 auto-closed as invalid on 2020/10/24 01:02
linux-4.14 KASAN: use-after-free Read in relay_switch_subbuf C done unreliable 5 801d 1843d 0/1 upstream: reported C repro on 2019/11/05 17:36
linux-5.15 KASAN: use-after-free Read in relay_switch_subbuf (2) 1 409d 409d 0/3 auto-obsoleted due to no activity on 2024/01/17 02:38
linux-4.14 general protection fault in relay_switch_subbuf 2 1700d 1793d 0/1 auto-closed as invalid on 2020/07/25 03:12
upstream general protection fault in relay_switch_subbuf block trace 4 2127d 2100d 0/28 auto-closed as invalid on 2019/07/23 22:29
upstream general protection fault in relay_switch_subbuf (2) block trace 1 1940d 1932d 0/28 auto-closed as invalid on 2019/10/25 14:11
upstream general protection fault in relay_switch_subbuf (3) block trace 1 1848d 1848d 0/28 auto-closed as invalid on 2020/01/29 10:20
linux-4.19 general protection fault in relay_switch_subbuf 1 1923d 1923d 0/1 auto-closed as invalid on 2019/12/15 08:14
linux-4.19 general protection fault in relay_switch_subbuf (2) 1 1620d 1620d 0/1 auto-closed as invalid on 2020/10/13 07:52

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in d_inode include/linux/dcache.h:516 [inline]
BUG: KASAN: use-after-free in relay_switch_subbuf+0x8cc/0x940 kernel/relay.c:761
Read of size 8 at addr ffff88808dd407b8 by task kworker/u4:7/6831

CPU: 0 PID: 6831 Comm: kworker/u4:7 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/21/2023
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
 kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
 kasan_report mm/kasan/report.c:412 [inline]
 __asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
 d_inode include/linux/dcache.h:516 [inline]
 relay_switch_subbuf+0x8cc/0x940 kernel/relay.c:761
 relay_reserve include/linux/relay.h:261 [inline]
 trace_note+0x5eb/0x750 kernel/trace/blktrace.c:96
 trace_note_tsk kernel/trace/blktrace.c:127 [inline]
 __blk_add_trace+0xb86/0xe20 kernel/trace/blktrace.c:267
 blk_add_trace_rq+0x36e/0x470 kernel/trace/blktrace.c:858
 trace_block_rq_complete include/trace/events/block.h:116 [inline]
 blk_update_request+0x74c/0xaf0 block/blk-core.c:3091
 scsi_end_request+0x7d/0xb60 drivers/scsi/scsi_lib.c:673
 scsi_io_completion+0x852/0x17c0 drivers/scsi/scsi_lib.c:1103
 scsi_softirq_done+0x336/0x3d0 drivers/scsi/scsi_lib.c:1759
 __blk_mq_complete_request block/blk-mq.c:583 [inline]
 blk_mq_complete_request+0x472/0x660 block/blk-mq.c:620
 virtscsi_vq_done drivers/scsi/virtio_scsi.c:223 [inline]
 virtscsi_req_done+0x14b/0x210 drivers/scsi/virtio_scsi.c:238
 vring_interrupt+0x12f/0x220 drivers/virtio/virtio_ring.c:953
 __handle_irq_event_percpu+0x27e/0x8e0 kernel/irq/handle.c:149
 handle_irq_event_percpu kernel/irq/handle.c:189 [inline]
 handle_irq_event+0x102/0x290 kernel/irq/handle.c:206
 handle_edge_irq+0x260/0xcf0 kernel/irq/chip.c:800
 generic_handle_irq_desc include/linux/irqdesc.h:155 [inline]
 handle_irq+0x35/0x50 arch/x86/kernel/irq_64.c:87
 do_IRQ+0x93/0x1c0 arch/x86/kernel/irq.c:246
 common_interrupt+0xf/0xf arch/x86/entry/entry_64.S:670
 </IRQ>
RIP: 0010:__raw_spin_unlock_irq include/linux/spinlock_api_smp.h:169 [inline]
RIP: 0010:_raw_spin_unlock_irq+0x50/0x80 kernel/locking/spinlock.c:192
Code: c0 98 82 f1 89 48 ba 00 00 00 00 00 fc ff df 48 c1 e8 03 80 3c 10 00 75 31 48 83 3d 01 31 d8 01 00 74 25 fb 66 0f 1f 44 00 00 <bf> 01 00 00 00 e8 26 1b 28 f9 65 8b 05 9f 8d e8 77 85 c0 74 02 5d
RSP: 0018:ffff888090c8ff10 EFLAGS: 00000286 ORIG_RAX: ffffffffffffffd9
RAX: 1ffffffff13e3053 RBX: ffff888049e521c0 RCX: 0000000000000000
RDX: dffffc0000000000 RSI: 0000000000000001 RDI: ffff888049e52a44
RBP: ffff8880a5672888 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffff8880a88f8200
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 spin_unlock_irq include/linux/spinlock.h:379 [inline]
 call_usermodehelper_exec_async+0xa6/0x6a0 kernel/umh.c:74
 ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:415

Allocated by task 9862:
 kmem_cache_alloc+0x122/0x370 mm/slab.c:3559
 __d_alloc+0x2b/0xa10 fs/dcache.c:1612
 d_alloc+0x4a/0x230 fs/dcache.c:1696
 d_alloc_parallel+0xeb/0x19e0 fs/dcache.c:2443
 __lookup_slow+0x18d/0x4a0 fs/namei.c:1655
 lookup_one_len+0x163/0x190 fs/namei.c:2544
 start_creating+0xc9/0x220 fs/debugfs/inode.c:313
 __debugfs_create_file+0x5e/0x480 fs/debugfs/inode.c:352
 relay_create_buf_file+0xf0/0x170 kernel/relay.c:429
 relay_open_buf.part.0+0x781/0xb80 kernel/relay.c:458
 relay_open_buf kernel/relay.c:450 [inline]
 relay_open kernel/relay.c:605 [inline]
 relay_open+0x537/0x9f0 kernel/relay.c:564
 do_blk_trace_setup+0x4f6/0xb40 kernel/trace/blktrace.c:566
 __blk_trace_setup+0xca/0x180 kernel/trace/blktrace.c:609
 blk_trace_ioctl+0x155/0x290 kernel/trace/blktrace.c:750
 blkdev_ioctl+0x112/0x1a80 block/ioctl.c:587
 block_ioctl+0xe9/0x130 fs/block_dev.c:1906
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:501 [inline]
 do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
 ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
 __do_sys_ioctl fs/ioctl.c:712 [inline]
 __se_sys_ioctl fs/ioctl.c:710 [inline]
 __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 18:
 __cache_free mm/slab.c:3503 [inline]
 kmem_cache_free+0x7f/0x260 mm/slab.c:3765
 __rcu_reclaim kernel/rcu/rcu.h:236 [inline]
 rcu_do_batch kernel/rcu/tree.c:2584 [inline]
 invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline]
 __rcu_process_callbacks kernel/rcu/tree.c:2864 [inline]
 rcu_process_callbacks+0x8ff/0x18b0 kernel/rcu/tree.c:2881
 __do_softirq+0x265/0x980 kernel/softirq.c:292

The buggy address belongs to the object at ffff88808dd40760
 which belongs to the cache dentry of size 288
The buggy address is located 88 bytes inside of
 288-byte region [ffff88808dd40760, ffff88808dd40880)
The buggy address belongs to the page:
page:ffffea0002375000 count:1 mapcount:0 mapping:ffff88813be45200 index:0x0
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea0002372008 ffffea00023758c8 ffff88813be45200
raw: 0000000000000000 ffff88808dd40080 000000010000000b 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88808dd40680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808dd40700: fb fb fb fb fc fc fc fc fc fc fc fc fb fb fb fb
>ffff88808dd40780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                        ^
 ffff88808dd40800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88808dd40880: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess), 5 bytes skipped:
   0:	48 ba 00 00 00 00 00 	movabs $0xdffffc0000000000,%rdx
   7:	fc ff df
   a:	48 c1 e8 03          	shr    $0x3,%rax
   e:	80 3c 10 00          	cmpb   $0x0,(%rax,%rdx,1)
  12:	75 31                	jne    0x45
  14:	48 83 3d 01 31 d8 01 	cmpq   $0x0,0x1d83101(%rip)        # 0x1d8311d
  1b:	00
  1c:	74 25                	je     0x43
  1e:	fb                   	sti
  1f:	66 0f 1f 44 00 00    	nopw   0x0(%rax,%rax,1)
* 25:	bf 01 00 00 00       	mov    $0x1,%edi <-- trapping instruction
  2a:	e8 26 1b 28 f9       	callq  0xf9281b55
  2f:	65 8b 05 9f 8d e8 77 	mov    %gs:0x77e88d9f(%rip),%eax        # 0x77e88dd5
  36:	85 c0                	test   %eax,%eax
  38:	74 02                	je     0x3c
  3a:	5d                   	pop    %rbp

Crashes (23):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/02/12 11:20 linux-4.19.y 3f8a27f9e27b 93e26d60 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2023/01/28 08:33 linux-4.19.y 3f8a27f9e27b 9dfcf09c .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2023/01/27 05:11 linux-4.19.y 3f8a27f9e27b 9dfcf09c .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2023/01/03 01:40 linux-4.19.y 3f8a27f9e27b ab32d508 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/12/27 22:45 linux-4.19.y 3f8a27f9e27b 44712fbc .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/11/12 18:14 linux-4.19.y 3f8a27f9e27b f42ee5d8 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/11/06 11:40 linux-4.19.y 3f8a27f9e27b 6d752409 .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/09/12 21:17 linux-4.19.y 3f8a27f9e27b f371ed7e .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/09/10 22:21 linux-4.19.y 3f8a27f9e27b 356d8217 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/08/22 13:23 linux-4.19.y 3f8a27f9e27b 26a13b38 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/08/20 03:28 linux-4.19.y 3f8a27f9e27b 26a13b38 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/07/13 22:06 linux-4.19.y 3f8a27f9e27b 5d921b08 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/07/04 16:49 linux-4.19.y 3f8a27f9e27b bff65f44 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/07/04 00:25 linux-4.19.y 3f8a27f9e27b 1434eec0 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/06/25 12:15 linux-4.19.y 3f8a27f9e27b a371c43c .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/06/10 11:10 linux-4.19.y 3f8a27f9e27b 0d5abf15 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/03/05 09:57 linux-4.19.y 3f8a27f9e27b 45a13a73 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/02/01 17:32 linux-4.19.y 3f8a27f9e27b c1c1631d .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/01/26 16:04 linux-4.19.y 3f8a27f9e27b 2cbffd88 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/01/23 08:21 linux-4.19.y 3f8a27f9e27b 214351e1 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2021/12/26 07:08 linux-4.19.y 3f8a27f9e27b 6caa12e4 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2021/10/17 18:32 linux-4.19.y 3f8a27f9e27b 0c5d9412 .config console log report info ci2-linux-4-19 KASAN: use-after-free Read in relay_switch_subbuf
2022/10/21 13:22 linux-4.19.y 3f8a27f9e27b 63e790dd .config console log report info [disk image] [vmlinux] ci2-linux-4-19 general protection fault in relay_switch_subbuf
* Struck through repros no longer work on HEAD.