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: 169d, last: 37d
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 245d 245d 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 100d 100d 0/3 auto-obsoleted due to no activity on 2025/05/21 00:47
upstream KASAN: use-after-free Read in tty_write_room serial 12 990d 1248d 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 580d 580d 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 694d 751d 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 160 1h51m 491d 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 591d 587d 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 ffff88801ca75018 by task aoe_tx0/1266

CPU: 0 PID: 1266 Comm: aoe_tx0 Not tainted 6.1.134-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/12/2025
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:4896 [inline]
 netdev_start_xmit include/linux/netdevice.h:4910 [inline]
 xmit_one net/core/dev.c:3658 [inline]
 dev_hard_start_xmit+0x261/0x8c0 net/core/dev.c:3674
 __dev_queue_xmit+0x1b5d/0x3d50 net/core/dev.c:4334
 dev_queue_xmit include/linux/netdevice.h:3051 [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 9095:
 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 4382:
 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+0x917/0x1260 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
 get_signal+0x15d0/0x17a0 kernel/signal.c:2648
 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 ffff88801ca75000
 which belongs to the cache kmalloc-cg-2k of size 2048
The buggy address is located 24 bytes inside of
 2048-byte region [ffff88801ca75000, ffff88801ca75800)

The buggy address belongs to the physical page:
page:ffffea0000729c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1ca70
head:ffffea0000729c00 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff88802f8dc501
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 ffffea0001e09200 dead000000000002 ffff888017c4c140
raw: 0000000000000000 0000000080080008 00000001ffffffff ffff88802f8dc501
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 8461, tgid 8458 (syz.1.1101), ts 544962559605, free_ts 544920848188
 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:5606
 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]
 bpf_prog_alloc_no_stats+0xb0/0x3f0 kernel/bpf/core.c:96
 bpf_prog_alloc+0x1c/0x1b0 kernel/bpf/core.c:130
 bpf_prog_load+0x84a/0x1bf0 kernel/bpf/syscall.c:2584
 __sys_bpf+0x382/0x6c0 kernel/bpf/syscall.c:5017
 __do_sys_bpf kernel/bpf/syscall.c:5121 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5119 [inline]
 __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:5119
 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
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
 free_slab mm/slub.c:2031 [inline]
 discard_slab mm/slub.c:2037 [inline]
 __unfreeze_partials+0x1b7/0x210 mm/slub.c:2586
 put_cpu_partial+0x17b/0x250 mm/slub.c:2662
 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
 getname_flags+0xb8/0x4f0 fs/namei.c:139
 do_sys_openat2+0xd2/0x4f0 fs/open.c:1312
 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

Memory state around the buggy address:
 ffff88801ca74f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88801ca74f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88801ca75000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff88801ca75080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88801ca75100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/04/13 23:57 linux-6.1.y 420102835862 0bd6db41 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in tty_write_room
2025/04/13 13:44 linux-6.1.y 420102835862 0bd6db41 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in tty_write_room
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.