================================================================== BUG: KASAN: slab-use-after-free in gsm_cleanup_mux+0x799/0x810 drivers/tty/n_gsm.c:3052 Read of size 4 at addr ffff8880783b000c by task syz-executor.2/7757 CPU: 0 PID: 7757 Comm: syz-executor.2 Not tainted 6.4.0-rc6-syzkaller-00242-g1639fae5132b #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd9/0x150 lib/dump_stack.c:106 print_address_description.constprop.0+0x2c/0x3c0 mm/kasan/report.c:351 print_report mm/kasan/report.c:462 [inline] kasan_report+0x11c/0x130 mm/kasan/report.c:572 gsm_cleanup_mux+0x799/0x810 drivers/tty/n_gsm.c:3052 gsm_config drivers/tty/n_gsm.c:3327 [inline] gsmld_ioctl+0x4cd/0x1850 drivers/tty/n_gsm.c:3733 tty_ioctl+0x80b/0x16e0 drivers/tty/tty_io.c:2786 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x197/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f3e3068c389 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f3e313ef168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f3e307ac050 RCX: 00007f3e3068c389 RDX: 0000000020000040 RSI: 00000000404c4701 RDI: 000000000000000a RBP: 00007f3e306d7493 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007f3e308cfb1f R14: 00007f3e313ef300 R15: 0000000000022000 Allocated by task 7756: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 ____kasan_kmalloc mm/kasan/common.c:374 [inline] ____kasan_kmalloc mm/kasan/common.c:333 [inline] __kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:383 kmalloc include/linux/slab.h:559 [inline] kzalloc include/linux/slab.h:680 [inline] gsm_dlci_alloc+0x46/0x7d0 drivers/tty/n_gsm.c:2618 gsm_activate_mux drivers/tty/n_gsm.c:3100 [inline] gsm_config drivers/tty/n_gsm.c:3355 [inline] gsmld_ioctl+0x846/0x1850 drivers/tty/n_gsm.c:3733 tty_ioctl+0x80b/0x16e0 drivers/tty/tty_io.c:2786 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x197/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Freed by task 7761: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2e/0x40 mm/kasan/generic.c:521 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x160/0x1c0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:162 [inline] slab_free_hook mm/slub.c:1781 [inline] slab_free_freelist_hook+0x8b/0x1c0 mm/slub.c:1807 slab_free mm/slub.c:3786 [inline] __kmem_cache_free+0xaf/0x2d0 mm/slub.c:3799 tty_port_destructor drivers/tty/tty_port.c:296 [inline] kref_put include/linux/kref.h:65 [inline] tty_port_put+0x15c/0x1c0 drivers/tty/tty_port.c:311 dlci_put drivers/tty/n_gsm.c:2681 [inline] gsm_dlci_release drivers/tty/n_gsm.c:2714 [inline] gsm_cleanup_mux+0x30a/0x810 drivers/tty/n_gsm.c:3074 gsm_config drivers/tty/n_gsm.c:3327 [inline] gsmld_ioctl+0x4cd/0x1850 drivers/tty/n_gsm.c:3733 tty_ioctl+0x80b/0x16e0 drivers/tty/tty_io.c:2786 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x197/0x210 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Last potentially related work creation: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:491 __call_rcu_common.constprop.0+0x99/0x7e0 kernel/rcu/tree.c:2627 netlink_release+0xcde/0x1e40 net/netlink/af_netlink.c:828 __sock_release+0xcd/0x290 net/socket.c:653 sock_close+0x1c/0x20 net/socket.c:1397 __fput+0x27c/0xa90 fs/file_table.c:321 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xaa3/0x29b0 kernel/exit.c:874 do_group_exit+0xd4/0x2a0 kernel/exit.c:1024 get_signal+0x2318/0x25b0 kernel/signal.c:2876 arch_do_signal_or_restart+0x79/0x5c0 arch/x86/kernel/signal.c:306 exit_to_user_mode_loop kernel/entry/common.c:168 [inline] exit_to_user_mode_prepare+0x11f/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd Second to last potentially related work creation: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 __kasan_record_aux_stack+0xbc/0xd0 mm/kasan/generic.c:491 __call_rcu_common.constprop.0+0x99/0x7e0 kernel/rcu/tree.c:2627 netlink_release+0xcde/0x1e40 net/netlink/af_netlink.c:828 __sock_release+0xcd/0x290 net/socket.c:653 sock_close+0x1c/0x20 net/socket.c:1397 __fput+0x27c/0xa90 fs/file_table.c:321 task_work_run+0x16f/0x270 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop kernel/entry/common.c:171 [inline] exit_to_user_mode_prepare+0x210/0x240 kernel/entry/common.c:204 __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd The buggy address belongs to the object at ffff8880783b0000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 12 bytes inside of freed 2048-byte region [ffff8880783b0000, ffff8880783b0800) The buggy address belongs to the physical page: page:ffffea0001e0ec00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x783b0 head:ffffea0001e0ec00 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0 anon flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff) page_type: 0xffffffff() raw: 00fff00000010200 ffff888012442000 0000000000000000 dead000000000001 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 0xd2820(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 5054, tgid 5054 (syz-executor.1), ts 200856685521, free_ts 190775741397 set_page_owner include/linux/page_owner.h:31 [inline] post_alloc_hook+0x2db/0x350 mm/page_alloc.c:1731 prep_new_page mm/page_alloc.c:1738 [inline] get_page_from_freelist+0xf41/0x2c00 mm/page_alloc.c:3502 __alloc_pages+0x1cb/0x4a0 mm/page_alloc.c:4768 alloc_pages+0x1aa/0x270 mm/mempolicy.c:2279 alloc_slab_page mm/slub.c:1851 [inline] allocate_slab+0x25f/0x390 mm/slub.c:1998 new_slab mm/slub.c:2051 [inline] ___slab_alloc+0xa91/0x1400 mm/slub.c:3192 __slab_alloc.constprop.0+0x56/0xa0 mm/slub.c:3291 __slab_alloc_node mm/slub.c:3344 [inline] slab_alloc_node mm/slub.c:3441 [inline] __kmem_cache_alloc_node+0x136/0x320 mm/slub.c:3490 __do_kmalloc_node mm/slab_common.c:965 [inline] __kmalloc_node_track_caller+0x4f/0x1a0 mm/slab_common.c:986 kmalloc_reserve+0xf0/0x270 net/core/skbuff.c:585 pskb_expand_head+0x237/0x1170 net/core/skbuff.c:2054 netlink_trim+0x1ea/0x240 net/netlink/af_netlink.c:1321 netlink_broadcast+0x63/0xd90 net/netlink/af_netlink.c:1517 nlmsg_multicast include/net/netlink.h:1083 [inline] nlmsg_notify+0x93/0x280 net/netlink/af_netlink.c:2589 rtnl_notify net/core/rtnetlink.c:771 [inline] rtmsg_ifinfo_send net/core/rtnetlink.c:4038 [inline] rtmsg_ifinfo_event net/core/rtnetlink.c:4054 [inline] rtmsg_ifinfo_event net/core/rtnetlink.c:4041 [inline] rtmsg_ifinfo+0x16e/0x1a0 net/core/rtnetlink.c:4060 __dev_notify_flags+0x240/0x2d0 net/core/dev.c:8603 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1302 [inline] free_unref_page_prepare+0x62e/0xcb0 mm/page_alloc.c:2564 free_unref_page+0x33/0x370 mm/page_alloc.c:2659 __unfreeze_partials+0x17c/0x1a0 mm/slub.c:2636 qlink_free mm/kasan/quarantine.c:166 [inline] qlist_free_all+0x6a/0x170 mm/kasan/quarantine.c:185 kasan_quarantine_reduce+0x195/0x220 mm/kasan/quarantine.c:292 __kasan_slab_alloc+0x63/0x90 mm/kasan/common.c:305 kasan_slab_alloc include/linux/kasan.h:186 [inline] slab_post_alloc_hook mm/slab.h:711 [inline] slab_alloc_node mm/slub.c:3451 [inline] kmem_cache_alloc_node+0x185/0x3e0 mm/slub.c:3496 __alloc_skb+0x288/0x330 net/core/skbuff.c:644 alloc_skb_fclone include/linux/skbuff.h:1338 [inline] tcp_stream_alloc_skb+0x3c/0x580 net/ipv4/tcp.c:866 tcp_sendmsg_locked+0xc47/0x2960 net/ipv4/tcp.c:1329 tcp_sendmsg+0x2f/0x50 net/ipv4/tcp.c:1487 inet_sendmsg+0x9d/0xe0 net/ipv4/af_inet.c:827 sock_sendmsg_nosec net/socket.c:724 [inline] sock_sendmsg+0xde/0x190 net/socket.c:747 sock_write_iter+0x295/0x3d0 net/socket.c:1140 call_write_iter include/linux/fs.h:1868 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x945/0xd50 fs/read_write.c:584 ksys_write+0x1ec/0x250 fs/read_write.c:637 Memory state around the buggy address: ffff8880783aff00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffff8880783aff80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >ffff8880783b0000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880783b0080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880783b0100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================