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: 18d, last: 18d
Similar bugs (6)
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 95d 95d 0/3 upstream: reported on 2024/09/18 00:19
upstream KASAN: use-after-free Read in tty_write_room serial 12 840d 1097d 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 429d 429d 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 543d 600d 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 67 2d09h 340d 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 441d 437d 0/28 auto-obsoleted due to no activity on 2024/01/09 18:18

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in tty_write_room+0x31/0x80 drivers/tty/tty_ioctl.c:79
Read of size 8 at addr ffff888057192018 by task aoe_tx0/1278

CPU: 1 PID: 1278 Comm: aoe_tx0 Not tainted 6.1.119-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/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:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 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:4866 [inline]
 netdev_start_xmit include/linux/netdevice.h:4880 [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:4301
 dev_queue_xmit include/linux/netdevice.h:3021 [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 5840:
 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:557 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 alloc_tty_struct+0xa5/0x7a0 drivers/tty/tty_io.c:3089
 tty_init_dev+0x57/0x4b0 drivers/tty/tty_io.c:1408
 tty_open_by_driver drivers/tty/tty_io.c:2081 [inline]
 tty_open+0x9d0/0xdd0 drivers/tty/tty_io.c:2128
 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 6930:
 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+0xa73/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
 ret_from_fork+0x15/0x30 arch/x86/entry/entry_64.S:288

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

The buggy address belongs to the physical page:
page:ffffea00015c6400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x57190
head:ffffea00015c6400 order:3 compound_mapcount:0 compound_pincount:0
memcg:ffff888057618a01
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000001 ffff888017c4c140
raw: 0000000000000000 0000000000080008 00000001ffffffff ffff888057618a01
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4249, tgid 4249 (syz-executor), ts 74231296440, free_ts 19413753270
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2517
 prep_new_page mm/page_alloc.c:2524 [inline]
 get_page_from_freelist+0x3731/0x38d0 mm/page_alloc.c:4313
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5590
 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
 __do_kmalloc_node mm/slab_common.c:935 [inline]
 __kmalloc_node_track_caller+0xa0/0x220 mm/slab_common.c:956
 kmemdup+0x26/0x60 mm/util.c:129
 neigh_sysctl_register+0xb0/0x4d0 net/core/neighbour.c:3785
 devinet_sysctl_register+0x9d/0x1a0 net/ipv4/devinet.c:2649
 inetdev_event+0xe43/0x1490 net/ipv4/devinet.c:1624
 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 net/core/dev.c:2022 [inline]
 dev_change_name+0x70b/0x9a0 net/core/dev.c:1251
 do_setlink+0xa72/0x3de0 net/core/rtnetlink.c:2810
 __rtnl_newlink net/core/rtnetlink.c:3605 [inline]
 rtnl_newlink+0x172c/0x2050 net/core/rtnetlink.c:3652
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1444 [inline]
 free_pcp_prepare mm/page_alloc.c:1494 [inline]
 free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3369
 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3464
 free_contig_range+0x9a/0x150 mm/page_alloc.c:9550
 destroy_args+0xfe/0x997 mm/debug_vm_pgtable.c:1031
 debug_vm_pgtable+0x416/0x46b mm/debug_vm_pgtable.c:1354
 do_one_initcall+0x265/0x8f0 init/main.c:1298
 do_initcall_level+0x157/0x207 init/main.c:1371
 do_initcalls+0x49/0x86 init/main.c:1387
 kernel_init_freeable+0x45c/0x60f init/main.c:1626
 kernel_init+0x19/0x290 init/main.c:1514
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Memory state around the buggy address:
 ffff888057191f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888057191f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888057192000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff888057192080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888057192100: 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
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.