syzbot


KASAN: use-after-free Read in tty_write_room

Status: auto-obsoleted due to no activity on 2024/01/27 09:51
Reported-by: syzbot+eae296927f2e06d2d835@syzkaller.appspotmail.com
First crash: 199d, last: 199d
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in tty_write_room serial 12 610d 867d 0/26 auto-obsoleted due to no activity on 2023/01/01 23:03
upstream BUG: unable to handle kernel NULL pointer dereference in tty_write_room serial syz error 6 313d 370d 0/26 auto-obsoleted due to no activity on 2023/10/05 13:52
upstream KASAN: slab-use-after-free Read in tty_write_room (2) serial syz 6 55d 110d 0/26 upstream: reported syz repro on 2024/01/16 15:06
upstream KASAN: slab-use-after-free Read in tty_write_room serial 1 211d 207d 0/26 auto-obsoleted due to no activity on 2024/01/09 18:18

Sample crash report:
ieee802154 phy0 wpan0: encryption failed: -22
ieee802154 phy1 wpan1: encryption failed: -22
==================================================================
BUG: KASAN: use-after-free in tty_write_room+0x31/0x80 drivers/tty/tty_ioctl.c:78
Read of size 8 at addr ffff888078bc0018 by task aoe_tx0/1380

CPU: 0 PID: 1380 Comm: aoe_tx0 Not tainted 5.15.135-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/2023
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 tty_write_room+0x31/0x80 drivers/tty/tty_ioctl.c:78
 handle_tx+0x164/0x620 drivers/net/caif/caif_serial.c:226
 __netdev_start_xmit include/linux/netdevice.h:5018 [inline]
 netdev_start_xmit include/linux/netdevice.h:5032 [inline]
 xmit_one net/core/dev.c:3594 [inline]
 dev_hard_start_xmit+0x298/0x7a0 net/core/dev.c:3610
 __dev_queue_xmit+0x1cee/0x3230 net/core/dev.c:4225
 tx+0x64/0x100 drivers/block/aoe/aoenet.c:63
 kthread+0x234/0x440 drivers/block/aoe/aoecmd.c:1230
 kthread+0x3f6/0x4f0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
 </TASK>

Allocated by task 2778:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 kmem_cache_alloc_trace+0x143/0x290 mm/slub.c:3247
 kmalloc include/linux/slab.h:591 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 alloc_tty_struct+0xa5/0x7b0 drivers/tty/tty_io.c:3124
 tty_init_dev+0x56/0x4b0 drivers/tty/tty_io.c:1424
 tty_open_by_driver drivers/tty/tty_io.c:2100 [inline]
 tty_open+0x9e1/0xde0 drivers/tty/tty_io.c:2148
 chrdev_open+0x54a/0x630 fs/char_dev.c:414
 do_dentry_open+0x807/0xfb0 fs/open.c:826
 do_open fs/namei.c:3538 [inline]
 path_openat+0x2702/0x2f20 fs/namei.c:3672
 do_filp_open+0x21c/0x460 fs/namei.c:3699
 do_sys_openat2+0x13b/0x500 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 28184:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kfree+0xf1/0x270 mm/slub.c:4559
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:319
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

Last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
 insert_work+0x54/0x3e0 kernel/workqueue.c:1366
 __queue_work+0x963/0xd00 kernel/workqueue.c:1532
 queue_work_on+0x14b/0x250 kernel/workqueue.c:1559
 tty_release_struct+0xb8/0xd0 drivers/tty/tty_io.c:1719
 tty_release+0xd53/0x1310 drivers/tty/tty_io.c:1880
 __fput+0x3bf/0x890 fs/file_table.c:280
 task_work_run+0x129/0x1a0 kernel/task_work.c:164
 exit_task_work include/linux/task_work.h:32 [inline]
 do_exit+0x6a3/0x2480 kernel/exit.c:872
 do_group_exit+0x144/0x310 kernel/exit.c:994
 get_signal+0xc66/0x14e0 kernel/signal.c:2889
 arch_do_signal_or_restart+0xc3/0x1890 arch/x86/kernel/signal.c:867
 handle_signal_work kernel/entry/common.c:148 [inline]
 exit_to_user_mode_loop+0x97/0x130 kernel/entry/common.c:172
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:208
 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
 syscall_exit_to_user_mode+0x5d/0x250 kernel/entry/common.c:301
 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Second to last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
 __call_rcu kernel/rcu/tree.c:2994 [inline]
 call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3074
 netlink_release+0x1362/0x17c0 net/netlink/af_netlink.c:819
 __sock_release net/socket.c:649 [inline]
 sock_close+0xcd/0x230 net/socket.c:1334
 __fput+0x3bf/0x890 fs/file_table.c:280
 task_work_run+0x129/0x1a0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:175
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:208
 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
 syscall_exit_to_user_mode+0x5d/0x250 kernel/entry/common.c:301
 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff888078bc0000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 24 bytes inside of
 2048-byte region [ffff888078bc0000, ffff888078bc0800)
The buggy address belongs to the page:
page:ffffea0001e2f000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x78bc0
head:ffffea0001e2f000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888011c42000
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 3562, ts 310424348615, free_ts 310412756956
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5421
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 __kmalloc+0x1c9/0x300 mm/slub.c:4403
 kmalloc include/linux/slab.h:596 [inline]
 sk_prot_alloc+0xe0/0x200 net/core/sock.c:1845
 sk_alloc+0x35/0x310 net/core/sock.c:1898
 __netlink_create+0x6b/0x2c0 net/netlink/af_netlink.c:647
 netlink_create+0x3a9/0x500 net/netlink/af_netlink.c:710
 __sock_create+0x460/0x8d0 net/socket.c:1484
 sock_create net/socket.c:1535 [inline]
 __sys_socket+0x132/0x370 net/socket.c:1577
 __do_sys_socket net/socket.c:1586 [inline]
 __se_sys_socket net/socket.c:1584 [inline]
 __x64_sys_socket+0x76/0x80 net/socket.c:1584
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 free_slab mm/slub.c:2015 [inline]
 discard_slab mm/slub.c:2021 [inline]
 __unfreeze_partials+0x1b7/0x210 mm/slub.c:2507
 put_cpu_partial+0x132/0x1a0 mm/slub.c:2587
 do_slab_free mm/slub.c:3487 [inline]
 ___cache_free+0xe3/0x100 mm/slub.c:3506
 qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 __kmalloc_node+0x151/0x390 mm/slub.c:4451
 kmalloc_node include/linux/slab.h:614 [inline]
 kvmalloc_node+0x80/0x140 mm/util.c:619
 kvmalloc include/linux/mm.h:805 [inline]
 kvmalloc_array include/linux/mm.h:823 [inline]
 __ptr_ring_init_queue_alloc include/linux/ptr_ring.h:471 [inline]
 ptr_ring_init include/linux/ptr_ring.h:489 [inline]
 skb_array_init include/linux/skb_array.h:182 [inline]
 pfifo_fast_init+0x110/0x6d0 net/sched/sch_generic.c:806
 qdisc_create_dflt+0x131/0x460 net/sched/sch_generic.c:957
 mq_init+0x2ca/0x6c0 net/sched/sch_mq.c:90
 qdisc_create_dflt+0x131/0x460 net/sched/sch_generic.c:957
 attach_default_qdiscs net/sched/sch_generic.c:1136 [inline]
 dev_activate+0x18e/0x12c0 net/sched/sch_generic.c:1190

Memory state around the buggy address:
 ffff888078bbff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888078bbff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888078bc0000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff888078bc0080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888078bc0100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/10/19 09:50 linux-5.15.y 02e21884dcf2 342b9c55 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in tty_write_room
* Struck through repros no longer work on HEAD.