syzbot


KASAN: use-after-free Read in tty_write_room

Status: upstream: reported on 2024/12/03 11:12
Reported-by: syzbot+0da9ad1b3b8ccde0c5ff@syzkaller.appspotmail.com
First crash: 122d, last: 65d
Similar bugs (7)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in tty_write_room (2) 1 198d 198d 0/3 auto-obsoleted due to no activity on 2024/12/27 00:19
linux-5.15 KASAN: use-after-free Read in tty_write_room (3) 1 53d 53d 0/3 upstream: reported on 2025/02/10 00:47
upstream KASAN: use-after-free Read in tty_write_room serial 12 943d 1201d 0/28 auto-obsoleted due to no activity on 2023/01/01 23:03
linux-5.15 KASAN: use-after-free Read in tty_write_room 1 533d 533d 0/3 auto-obsoleted due to no activity on 2024/01/27 09:51
upstream BUG: unable to handle kernel NULL pointer dereference in tty_write_room serial syz error 6 647d 704d 0/28 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 error error 129 3d06h 444d 0/28 upstream: reported syz repro on 2024/01/16 15:06
upstream KASAN: slab-use-after-free Read in tty_write_room serial 1 544d 540d 0/28 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:79
Read of size 8 at addr ffff888057ee3018 by task aoe_tx0/1267

CPU: 1 PID: 1267 Comm: aoe_tx0 Not tainted 6.1.127-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 12/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:316 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:427
 kasan_report+0x136/0x160 mm/kasan/report.c:531
 tty_write_room+0x31/0x80 drivers/tty/tty_ioctl.c:79
 handle_tx+0x164/0x620 drivers/net/caif/caif_serial.c:226
 __netdev_start_xmit include/linux/netdevice.h:4888 [inline]
 netdev_start_xmit include/linux/netdevice.h:4902 [inline]
 xmit_one net/core/dev.c:3627 [inline]
 dev_hard_start_xmit+0x261/0x8c0 net/core/dev.c:3643
 __dev_queue_xmit+0x1b5d/0x3d50 net/core/dev.c:4303
 dev_queue_xmit include/linux/netdevice.h:3043 [inline]
 tx+0x67/0x170 drivers/block/aoe/aoenet.c:63
 kthread+0x234/0x450 drivers/block/aoe/aoecmd.c:1237
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>

Allocated by task 16633:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0x97/0xb0 mm/kasan/common.c:383
 kmalloc include/linux/slab.h:563 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 alloc_tty_struct+0xa5/0x7a0 drivers/tty/tty_io.c:3089
 tty_init_dev+0x57/0x4b0 drivers/tty/tty_io.c:1408
 ptmx_open+0xd6/0x2b0 drivers/tty/pty.c:824
 chrdev_open+0x54a/0x630 fs/char_dev.c:414
 do_dentry_open+0x7f9/0x10f0 fs/open.c:882
 do_open fs/namei.c:3626 [inline]
 path_openat+0x2644/0x2e60 fs/namei.c:3783
 do_filp_open+0x230/0x480 fs/namei.c:3810
 do_sys_openat2+0x13b/0x4f0 fs/open.c:1318
 do_sys_open fs/open.c:1334 [inline]
 __do_sys_openat fs/open.c:1350 [inline]
 __se_sys_openat fs/open.c:1345 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1345
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 15645:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0x25c/0x3c0 mm/slub.c:3674
 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 insert_work+0x54/0x3d0 kernel/workqueue.c:1361
 __queue_work+0xb4b/0xf90 kernel/workqueue.c:1520
 queue_work_on+0x14b/0x250 kernel/workqueue.c:1548
 tty_release_struct+0xb8/0xd0 drivers/tty/tty_io.c:1700
 tty_release+0xcfb/0x12a0 drivers/tty/tty_io.c:1860
 __fput+0x3f6/0x8d0 fs/file_table.c:320
 task_work_run+0x246/0x300 kernel/task_work.c:203
 exit_task_work include/linux/task_work.h:39 [inline]
 do_exit+0xa6e/0x26a0 kernel/exit.c:871
 do_group_exit+0x202/0x2b0 kernel/exit.c:1021
 get_signal+0x16f7/0x17d0 kernel/signal.c:2871
 arch_do_signal_or_restart+0xb0/0x1a10 arch/x86/kernel/signal.c:871
 exit_to_user_mode_loop+0x6a/0x100 kernel/entry/common.c:174
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210
 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
 syscall_exit_to_user_mode+0x60/0x270 kernel/entry/common.c:303
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

The buggy address belongs to the object at ffff888057ee3000
 which belongs to the cache kmalloc-cg-2k of size 2048
The buggy address is located 24 bytes inside of
 2048-byte region [ffff888057ee3000, ffff888057ee3800)

The buggy address belongs to the physical page:
page:ffffea00015fb800 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x57ee0
head:ffffea00015fb800 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff88805f8b4c81
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888017c4c140
raw: 0000000000000000 0000000000080008 00000001ffffffff ffff88805f8b4c81
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 16625, tgid 16618 (syz.0.2687), ts 986176949304, free_ts 986166056273
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2532
 prep_new_page mm/page_alloc.c:2539 [inline]
 get_page_from_freelist+0x3731/0x38d0 mm/page_alloc.c:4328
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5605
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xc20/0x1270 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 __kmem_cache_alloc_node+0x19f/0x260 mm/slub.c:3437
 kmalloc_trace+0x26/0xe0 mm/slab_common.c:1026
 kmalloc include/linux/slab.h:563 [inline]
 kzalloc include/linux/slab.h:699 [inline]
 ipv6_add_dev+0xf9/0x1180 net/ipv6/addrconf.c:379
 addrconf_notify+0x7a6/0xf60 net/ipv6/addrconf.c:3598
 notifier_call_chain kernel/notifier.c:87 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:455
 call_netdevice_notifiers_info net/core/dev.c:1970 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2008 [inline]
 call_netdevice_notifiers+0x145/0x1b0 net/core/dev.c:2022
 register_netdevice+0x1507/0x1920 net/core/dev.c:10194
 br_dev_newlink+0x23/0x100 net/bridge/br_netlink.c:1499
 rtnl_newlink_create net/core/rtnetlink.c:3419 [inline]
 __rtnl_newlink net/core/rtnetlink.c:3639 [inline]
 rtnl_newlink+0x14e3/0x2050 net/core/rtnetlink.c:3652
 rtnetlink_rcv_msg+0x818/0xff0 net/core/rtnetlink.c:6150
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1459 [inline]
 free_pcp_prepare mm/page_alloc.c:1509 [inline]
 free_unref_page_prepare+0x12a6/0x15b0 mm/page_alloc.c:3384
 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3479
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0x76/0xe0 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x156/0x170 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x1f/0x70 mm/kasan/common.c:305
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x52/0x3a0 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x10c/0x2d0 mm/slub.c:3422
 ptlock_alloc+0x1c/0x60 mm/memory.c:6047
 ptlock_init include/linux/mm.h:2393 [inline]
 pgtable_pte_page_ctor include/linux/mm.h:2420 [inline]
 __pte_alloc_one include/asm-generic/pgalloc.h:66 [inline]
 pte_alloc_one+0xd1/0x360 arch/x86/mm/pgtable.c:33
 __pte_alloc+0x75/0x220 mm/memory.c:468
 copy_pte_range mm/memory.c:1042 [inline]
 copy_pmd_range mm/memory.c:1177 [inline]
 copy_pud_range mm/memory.c:1214 [inline]
 copy_p4d_range mm/memory.c:1238 [inline]
 copy_page_range+0x3e3e/0x4660 mm/memory.c:1336
 dup_mmap kernel/fork.c:697 [inline]
 dup_mm kernel/fork.c:1541 [inline]
 copy_mm+0xf42/0x1990 kernel/fork.c:1590
 copy_process+0x19d5/0x4060 kernel/fork.c:2266
 kernel_clone+0x222/0x920 kernel/fork.c:2681
 __do_sys_clone kernel/fork.c:2822 [inline]
 __se_sys_clone kernel/fork.c:2806 [inline]
 __x64_sys_clone+0x231/0x280 kernel/fork.c:2806
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81

Memory state around the buggy address:
 ffff888057ee2f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888057ee2f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888057ee3000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff888057ee3080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888057ee3100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/01/29 08:20 linux-6.1.y 75cefdf153f5 865ef71e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in tty_write_room
2024/12/03 11:12 linux-6.1.y e4d90d63d385 578925bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in tty_write_room
* Struck through repros no longer work on HEAD.