================================================================== BUG: KASAN: use-after-free in update_tty_status drivers/net/caif/caif_serial.c:90 [inline] BUG: KASAN: use-after-free in handle_tx+0x5aa/0x610 drivers/net/caif/caif_serial.c:237 Read of size 1 at addr ffff8880768f0490 by task aoe_tx0/1235 CPU: 0 PID: 1235 Comm: aoe_tx0 Not tainted 5.16.0-rc8-next-20220104-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 print_address_description.constprop.0.cold+0xa5/0x3ed mm/kasan/report.c:255 __kasan_report mm/kasan/report.c:442 [inline] kasan_report.cold+0x83/0xdf mm/kasan/report.c:459 update_tty_status drivers/net/caif/caif_serial.c:90 [inline] handle_tx+0x5aa/0x610 drivers/net/caif/caif_serial.c:237 __netdev_start_xmit include/linux/netdevice.h:4678 [inline] netdev_start_xmit include/linux/netdevice.h:4692 [inline] xmit_one net/core/dev.c:3473 [inline] dev_hard_start_xmit+0x1eb/0x920 net/core/dev.c:3489 __dev_queue_xmit+0x2983/0x3640 net/core/dev.c:4116 tx+0x68/0xb0 drivers/block/aoe/aoenet.c:63 kthread+0x1e7/0x3b0 drivers/block/aoe/aoecmd.c:1230 kthread+0x2e9/0x3a0 kernel/kthread.c:377 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Allocated by task 16234: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track mm/kasan/common.c:45 [inline] set_alloc_info mm/kasan/common.c:436 [inline] ____kasan_kmalloc mm/kasan/common.c:515 [inline] ____kasan_kmalloc mm/kasan/common.c:474 [inline] __kasan_kmalloc+0xa9/0xd0 mm/kasan/common.c:524 kmalloc include/linux/slab.h:581 [inline] kzalloc include/linux/slab.h:715 [inline] alloc_tty_struct+0x94/0x920 drivers/tty/tty_io.c:3091 tty_init_dev.part.0+0x20/0x610 drivers/tty/tty_io.c:1412 tty_init_dev include/linux/err.h:36 [inline] tty_open_by_driver drivers/tty/tty_io.c:2086 [inline] tty_open+0xb16/0x1000 drivers/tty/tty_io.c:2133 chrdev_open+0x266/0x770 fs/char_dev.c:414 do_dentry_open+0x4b9/0x1240 fs/open.c:824 do_open fs/namei.c:3482 [inline] path_openat+0x1c9e/0x2940 fs/namei.c:3615 do_filp_open+0x1aa/0x400 fs/namei.c:3642 do_sys_openat2+0x16d/0x4d0 fs/open.c:1214 do_sys_open fs/open.c:1230 [inline] __do_sys_openat fs/open.c:1246 [inline] __se_sys_openat fs/open.c:1241 [inline] __x64_sys_openat+0x13f/0x1f0 fs/open.c:1241 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae Freed by task 26459: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 kasan_set_track+0x21/0x30 mm/kasan/common.c:45 kasan_set_free_info+0x20/0x30 mm/kasan/generic.c:370 ____kasan_slab_free mm/kasan/common.c:366 [inline] ____kasan_slab_free+0x166/0x1a0 mm/kasan/common.c:328 kasan_slab_free include/linux/kasan.h:236 [inline] slab_free_hook mm/slub.c:1728 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1754 slab_free mm/slub.c:3509 [inline] kfree+0xce/0x380 mm/slub.c:4562 process_one_work+0x9ac/0x1650 kernel/workqueue.c:2307 worker_thread+0x657/0x1110 kernel/workqueue.c:2454 kthread+0x2e9/0x3a0 kernel/kthread.c:377 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295 Last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348 insert_work+0x48/0x370 kernel/workqueue.c:1368 __queue_work+0x5ca/0xf30 kernel/workqueue.c:1534 queue_work_on+0xee/0x110 kernel/workqueue.c:1562 kref_put include/linux/kref.h:65 [inline] tty_kref_put drivers/tty/tty_io.c:1570 [inline] release_tty+0x4e9/0x610 drivers/tty/tty_io.c:1606 tty_release_struct+0xb4/0xe0 drivers/tty/tty_io.c:1705 tty_release+0xc70/0x1200 drivers/tty/tty_io.c:1865 __fput+0x286/0x9f0 fs/file_table.c:311 task_work_run+0xdd/0x1a0 kernel/task_work.c:164 exit_task_work include/linux/task_work.h:32 [inline] do_exit+0xb31/0x2b10 kernel/exit.c:793 do_group_exit+0x128/0x330 kernel/exit.c:932 get_signal+0x4b0/0x28c0 kernel/signal.c:2868 arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:868 handle_signal_work kernel/entry/common.c:148 [inline] exit_to_user_mode_loop kernel/entry/common.c:172 [inline] exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:207 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline] syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x44/0xae Second to last potentially related work creation: kasan_save_stack+0x1e/0x40 mm/kasan/common.c:38 __kasan_record_aux_stack+0xbe/0xd0 mm/kasan/generic.c:348 call_rcu+0x99/0x730 kernel/rcu/tree.c:3072 netlink_release+0xf08/0x1db0 net/netlink/af_netlink.c:813 __sock_release+0xcd/0x280 net/socket.c:650 sock_close+0x18/0x20 net/socket.c:1315 __fput+0x286/0x9f0 fs/file_table.c:311 task_work_run+0xdd/0x1a0 kernel/task_work.c:164 exit_task_work include/linux/task_work.h:32 [inline] do_exit+0xb31/0x2b10 kernel/exit.c:793 do_group_exit+0x128/0x330 kernel/exit.c:932 get_signal+0x4b0/0x28c0 kernel/signal.c:2868 arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:868 handle_signal_work kernel/entry/common.c:148 [inline] exit_to_user_mode_loop kernel/entry/common.c:172 [inline] exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:207 __syscall_exit_to_user_mode_work kernel/entry/common.c:289 [inline] syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:300 do_syscall_64+0x42/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff8880768f0000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1168 bytes inside of 2048-byte region [ffff8880768f0000, ffff8880768f0800) The buggy address belongs to the page: page:ffffea0001da3c00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880768f3000 pfn:0x768f0 head:ffffea0001da3c00 order:3 compound_mapcount:0 compound_pincount:0 flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000010200 ffffea0000958c08 ffffea0001d26208 ffff888010c42000 raw: ffff8880768f3000 0000000000080006 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 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3636, ts 134675637119, free_ts 132034238818 prep_new_page mm/page_alloc.c:2434 [inline] get_page_from_freelist+0xa72/0x2f40 mm/page_alloc.c:4165 __alloc_pages+0x1b2/0x500 mm/page_alloc.c:5381 alloc_pages+0x1aa/0x310 mm/mempolicy.c:2271 alloc_slab_page mm/slub.c:1799 [inline] allocate_slab mm/slub.c:1944 [inline] new_slab+0x28d/0x380 mm/slub.c:2004 ___slab_alloc+0x6be/0xd60 mm/slub.c:3018 __slab_alloc.constprop.0+0x4d/0xa0 mm/slub.c:3105 slab_alloc_node mm/slub.c:3196 [inline] slab_alloc mm/slub.c:3238 [inline] __kmalloc+0x2fb/0x340 mm/slub.c:4420 kmalloc include/linux/slab.h:586 [inline] kzalloc include/linux/slab.h:715 [inline] __register_sysctl_table+0x112/0x1090 fs/proc/proc_sysctl.c:1336 __devinet_sysctl_register+0x156/0x280 net/ipv4/devinet.c:2581 devinet_sysctl_register net/ipv4/devinet.c:2621 [inline] devinet_sysctl_register+0x160/0x230 net/ipv4/devinet.c:2611 inetdev_init+0x286/0x580 net/ipv4/devinet.c:278 inetdev_event+0xa8a/0x15d0 net/ipv4/devinet.c:1532 notifier_call_chain+0xb5/0x200 kernel/notifier.c:84 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1919 call_netdevice_notifiers_extack net/core/dev.c:1931 [inline] call_netdevice_notifiers net/core/dev.c:1945 [inline] register_netdevice+0x1073/0x1500 net/core/dev.c:9691 nsim_init_netdevsim drivers/net/netdevsim/netdev.c:317 [inline] nsim_create+0x3c3/0x520 drivers/net/netdevsim/netdev.c:365 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1352 [inline] free_pcp_prepare+0x414/0xb60 mm/page_alloc.c:1404 free_unref_page_prepare mm/page_alloc.c:3325 [inline] free_unref_page+0x19/0x690 mm/page_alloc.c:3404 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2536 qlink_free mm/kasan/quarantine.c:157 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:176 kasan_quarantine_reduce+0x180/0x200 mm/kasan/quarantine.c:283 __kasan_slab_alloc+0xa2/0xc0 mm/kasan/common.c:446 kasan_slab_alloc include/linux/kasan.h:260 [inline] slab_post_alloc_hook mm/slab.h:741 [inline] slab_alloc_node mm/slub.c:3230 [inline] slab_alloc mm/slub.c:3238 [inline] kmem_cache_alloc_trace+0x1e9/0x2c0 mm/slub.c:3255 kmalloc include/linux/slab.h:581 [inline] kzalloc include/linux/slab.h:715 [inline] ref_tracker_alloc+0xe1/0x430 lib/ref_tracker.c:74 netdev_tracker_alloc include/linux/netdevice.h:3855 [inline] dev_hold_track include/linux/netdevice.h:3872 [inline] dev_hold_track include/linux/netdevice.h:3867 [inline] netdev_queue_add_kobject net/core/net-sysfs.c:1650 [inline] netdev_queue_update_kobjects+0x1a7/0x4e0 net/core/net-sysfs.c:1705 register_queue_kobjects net/core/net-sysfs.c:1766 [inline] netdev_register_kobject+0x35a/0x430 net/core/net-sysfs.c:2012 register_netdevice+0xd31/0x1500 net/core/dev.c:9660 bond_newlink drivers/net/bonding/bond_netlink.c:479 [inline] bond_newlink+0x47/0xa0 drivers/net/bonding/bond_netlink.c:469 __rtnl_newlink+0x106d/0x1750 net/core/rtnetlink.c:3457 rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3505 rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5570 netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2494 Memory state around the buggy address: ffff8880768f0380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880768f0400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8880768f0480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880768f0500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880768f0580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================