syzbot


KASAN: use-after-free Write in __tasklet_schedule_common

Status: upstream: reported on 2023/01/25 23:49
Reported-by: syzbot+77d129635401b6149461@syzkaller.appspotmail.com
First crash: 695d, last: 695d

Sample crash report:
audit: type=1804 audit(1674690533.450:167): pid=21609 uid=0 auid=4294967295 ses=4294967295 subj==unconfined op=invalid_pcr cause=open_writers comm="syz-executor.3" name="/root/syzkaller-testdir4178837161/syzkaller.ZjcYKn/574/file0/bus" dev="loop3" ino=41 res=1
XFS (loop3): Unmounting Filesystem
==================================================================
BUG: KASAN: use-after-free in __tasklet_schedule_common+0x276/0x2c0 kernel/softirq.c:480
Write of size 8 at addr ffff8880987bb790 by task syz-executor.5/8133

CPU: 0 PID: 8133 Comm: syz-executor.5 Not tainted 4.19.211-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/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_store8_noabort+0x88/0x90 mm/kasan/report.c:438
 __tasklet_schedule_common+0x276/0x2c0 kernel/softirq.c:480
 tasklet_schedule include/linux/interrupt.h:591 [inline]
 ieee80211_rx_irqsafe+0xb1/0xd0 net/mac80211/rx.c:4692
 mac80211_hwsim_tx_frame_no_nl.isra.0+0xcaf/0x1330 drivers/net/wireless/mac80211_hwsim.c:1369
 mac80211_hwsim_tx_frame+0x12b/0x210 drivers/net/wireless/mac80211_hwsim.c:1556
 mac80211_hwsim_beacon_tx+0x3f8/0x680 drivers/net/wireless/mac80211_hwsim.c:1595
 __iterate_interfaces+0x2e1/0x4a0 net/mac80211/util.c:614
 ieee80211_iterate_active_interfaces_atomic+0x8d/0x170 net/mac80211/util.c:650
 mac80211_hwsim_beacon+0xc9/0x190 drivers/net/wireless/mac80211_hwsim.c:1615
 __tasklet_hrtimer_trampoline+0x29/0xa0 kernel/softirq.c:601
 tasklet_action_common.constprop.0+0x265/0x360 kernel/softirq.c:522
 __do_softirq+0x265/0x980 kernel/softirq.c:292
 invoke_softirq kernel/softirq.c:372 [inline]
 irq_exit+0x215/0x260 kernel/softirq.c:412
 exiting_irq arch/x86/include/asm/apic.h:536 [inline]
 smp_apic_timer_interrupt+0x136/0x550 arch/x86/kernel/apic/apic.c:1098
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:894
 </IRQ>
RIP: 0010:arch_local_irq_restore arch/x86/include/asm/paravirt.h:789 [inline]
RIP: 0010:qlink_free mm/kasan/quarantine.c:150 [inline]
RIP: 0010:qlist_free_all+0xfc/0x140 mm/kasan/quarantine.c:166
Code: 50 08 48 8d 4a ff 83 e2 01 48 0f 45 c1 4c 8b 70 18 e9 40 ff ff ff e8 a3 36 cf ff 48 83 3d e3 0f 59 08 00 74 38 4c 89 ff 57 9d <0f> 1f 44 00 00 4d 85 e4 75 9e 49 c7 45 08 00 00 00 00 49 c7 45 00
RSP: 0018:ffff8880a331f8c8 EFLAGS: 00000286 ORIG_RAX: ffffffffffffff13
RAX: 0000000000000007 RBX: ffff888050d3b5c0 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffff8880a3102b48 RDI: 0000000000000286
RBP: 0000000000000000 R08: ffffed1008f20800 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffff888050d46000
R13: ffff8880a331f900 R14: ffff88813bff0940 R15: 0000000000000286
 quarantine_reduce+0x1a9/0x230 mm/kasan/quarantine.c:259
 kasan_kmalloc+0xa2/0x160 mm/kasan/kasan.c:538
 slab_post_alloc_hook mm/slab.h:445 [inline]
 slab_alloc mm/slab.c:3397 [inline]
 kmem_cache_alloc+0x110/0x370 mm/slab.c:3557
 kmem_cache_zalloc include/linux/slab.h:699 [inline]
 __delayacct_tsk_init+0x1b/0x80 kernel/delayacct.c:45
 delayacct_tsk_init include/linux/delayacct.h:105 [inline]
 copy_process.part.0+0x3635/0x8260 kernel/fork.c:1799
 copy_process kernel/fork.c:1710 [inline]
 _do_fork+0x22f/0xf30 kernel/fork.c:2219
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f0c32f5fdfb
Code: ed 0f 85 60 01 00 00 64 4c 8b 0c 25 10 00 00 00 45 31 c0 4d 8d 91 d0 02 00 00 31 d2 31 f6 bf 11 00 20 01 b8 38 00 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 89 00 00 00 41 89 c5 85 c0 0f 85 90 00 00
RSP: 002b:00007fff058386d0 EFLAGS: 00000246 ORIG_RAX: 0000000000000038
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f0c32f5fdfb
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000001200011
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000555556f67400
R10: 0000555556f676d0 R11: 0000000000000246 R12: 0000000000000001
R13: 0000000000000000 R14: 0000000000000001 R15: 00007fff058387b0

Allocated by task 21559:
 kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 bcm_tx_setup net/can/bcm.c:947 [inline]
 bcm_sendmsg+0x25d7/0x4150 net/can/bcm.c:1386
 sock_sendmsg_nosec net/socket.c:651 [inline]
 sock_sendmsg+0xc3/0x120 net/socket.c:661
 ___sys_sendmsg+0x7bb/0x8e0 net/socket.c:2227
 __sys_sendmsg net/socket.c:2265 [inline]
 __do_sys_sendmsg net/socket.c:2274 [inline]
 __se_sys_sendmsg net/socket.c:2272 [inline]
 __x64_sys_sendmsg+0x132/0x220 net/socket.c:2272
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 21598:
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 bcm_release+0x260/0x950 net/can/bcm.c:1561
 __sock_release+0xcd/0x2a0 net/socket.c:599
 sock_close+0x15/0x20 net/socket.c:1214
 __fput+0x2ce/0x890 fs/file_table.c:278
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xbf3/0x2be0 kernel/exit.c:870
 do_group_exit+0x125/0x310 kernel/exit.c:967
 get_signal+0x3f2/0x1f70 kernel/signal.c:2589
 do_signal+0x8f/0x1670 arch/x86/kernel/signal.c:799
 exit_to_usermode_loop+0x204/0x2a0 arch/x86/entry/common.c:163
 prepare_exit_to_usermode arch/x86/entry/common.c:198 [inline]
 syscall_return_slowpath+0x3f0/0x4a0 arch/x86/entry/common.c:271
 ret_from_fork+0x15/0x30 arch/x86/entry/entry_64.S:407

The buggy address belongs to the object at ffff8880987bb6c0
 which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 208 bytes inside of
 1024-byte region [ffff8880987bb6c0, ffff8880987bbac0)
The buggy address belongs to the page:
page:ffffea000261ee80 count:1 mapcount:0 mapping:ffff88813bff0ac0 index:0x0 compound_mapcount: 0
flags: 0xfff00000008100(slab|head)
raw: 00fff00000008100 ffffea0002aa0688 ffffea0002b80788 ffff88813bff0ac0
raw: 0000000000000000 ffff8880987ba040 0000000100000007 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880987bb680: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
 ffff8880987bb700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880987bb780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
 ffff8880987bb800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880987bb880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
   0:	50                   	push   %rax
   1:	08 48 8d             	or     %cl,-0x73(%rax)
   4:	4a ff 83 e2 01 48 0f 	rex.WX incq 0xf4801e2(%rbx)
   b:	45 c1 4c 8b 70 18    	rex.RB rorl $0x18,0x70(%r11,%rcx,4)
  11:	e9 40 ff ff ff       	jmpq   0xffffff56
  16:	e8 a3 36 cf ff       	callq  0xffcf36be
  1b:	48 83 3d e3 0f 59 08 	cmpq   $0x0,0x8590fe3(%rip)        # 0x8591006
  22:	00
  23:	74 38                	je     0x5d
  25:	4c 89 ff             	mov    %r15,%rdi
  28:	57                   	push   %rdi
  29:	9d                   	popfq
* 2a:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1) <-- trapping instruction
  2f:	4d 85 e4             	test   %r12,%r12
  32:	75 9e                	jne    0xffffffd2
  34:	49 c7 45 08 00 00 00 	movq   $0x0,0x8(%r13)
  3b:	00
  3c:	49                   	rex.WB
  3d:	c7                   	.byte 0xc7
  3e:	45                   	rex.RB

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/01/25 23:49 linux-4.19.y 3f8a27f9e27b 9dfcf09c .config console log report info [disk image] [vmlinux] ci2-linux-4-19 KASAN: use-after-free Write in __tasklet_schedule_common
* Struck through repros no longer work on HEAD.