================================================================== BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:102 [inline] BUG: KASAN: use-after-free in atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:116 [inline] BUG: KASAN: use-after-free in __refcount_add include/linux/refcount.h:193 [inline] BUG: KASAN: use-after-free in __refcount_inc include/linux/refcount.h:250 [inline] BUG: KASAN: use-after-free in refcount_inc include/linux/refcount.h:267 [inline] BUG: KASAN: use-after-free in sock_hold include/net/sock.h:775 [inline] BUG: KASAN: use-after-free in nr_release+0x66/0x460 net/netrom/af_netrom.c:520 Write of size 4 at addr ffff88807c8e7080 by task syz-executor.3/26060 CPU: 0 PID: 26060 Comm: syz-executor.3 Not tainted 6.2.0-rc5-syzkaller-00047-g7c46948a6e9c #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023 Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:306 [inline] print_report+0x15e/0x461 mm/kasan/report.c:417 kasan_report+0xbf/0x1f0 mm/kasan/report.c:517 check_region_inline mm/kasan/generic.c:183 [inline] kasan_check_range+0x141/0x190 mm/kasan/generic.c:189 instrument_atomic_read_write include/linux/instrumented.h:102 [inline] atomic_fetch_add_relaxed include/linux/atomic/atomic-instrumented.h:116 [inline] __refcount_add include/linux/refcount.h:193 [inline] __refcount_inc include/linux/refcount.h:250 [inline] refcount_inc include/linux/refcount.h:267 [inline] sock_hold include/net/sock.h:775 [inline] nr_release+0x66/0x460 net/netrom/af_netrom.c:520 __sock_release+0xcd/0x280 net/socket.c:650 sock_close+0x1c/0x20 net/socket.c:1365 __fput+0x27c/0xa90 fs/file_table.c:320 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xaa8/0x2950 kernel/exit.c:867 do_group_exit+0xd4/0x2a0 kernel/exit.c:1012 get_signal+0x21c3/0x2450 kernel/signal.c:2859 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+0x15f/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296 do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fd65668c0c9 Code: Unable to access opcode bytes at 0x7fd65668c09f. RSP: 002b:00007fd657426168 EFLAGS: 00000246 ORIG_RAX: 0000000000000110 RAX: fffffffffffffffc RBX: 00007fd6567ac050 RCX: 00007fd65668c0c9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000000006c060000 RBP: 00007fd6566e7ae9 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffef51da52f R14: 00007fd657426300 R15: 0000000000022000 Allocated by task 26054: 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:371 [inline] ____kasan_kmalloc mm/kasan/common.c:330 [inline] __kasan_kmalloc+0xa3/0xb0 mm/kasan/common.c:380 kasan_kmalloc include/linux/kasan.h:211 [inline] __do_kmalloc_node mm/slab_common.c:968 [inline] __kmalloc+0x5a/0xd0 mm/slab_common.c:981 kmalloc include/linux/slab.h:584 [inline] sk_prot_alloc+0x140/0x290 net/core/sock.c:2038 sk_alloc+0x3a/0x7a0 net/core/sock.c:2091 nr_create+0xb6/0x5f0 net/netrom/af_netrom.c:433 __sock_create+0x359/0x790 net/socket.c:1515 sock_create net/socket.c:1566 [inline] __sys_socket_create net/socket.c:1603 [inline] __sys_socket_create net/socket.c:1588 [inline] __sys_socket+0x133/0x250 net/socket.c:1636 __do_sys_socket net/socket.c:1649 [inline] __se_sys_socket net/socket.c:1647 [inline] __x64_sys_socket+0x73/0xb0 net/socket.c:1647 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 14: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 kasan_set_track+0x25/0x30 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:518 ____kasan_slab_free mm/kasan/common.c:236 [inline] ____kasan_slab_free+0x13b/0x1a0 mm/kasan/common.c:200 kasan_slab_free include/linux/kasan.h:177 [inline] __cache_free mm/slab.c:3396 [inline] __do_kmem_cache_free mm/slab.c:3582 [inline] __kmem_cache_free+0xcd/0x3b0 mm/slab.c:3589 sk_prot_free net/core/sock.c:2074 [inline] __sk_destruct+0x5df/0x750 net/core/sock.c:2166 sk_destruct net/core/sock.c:2181 [inline] __sk_free+0x175/0x460 net/core/sock.c:2192 sk_free+0x7c/0xa0 net/core/sock.c:2203 sock_put include/net/sock.h:1991 [inline] nr_heartbeat_expiry+0x1d7/0x460 net/netrom/nr_timer.c:148 call_timer_fn+0x1da/0x7c0 kernel/time/timer.c:1700 expire_timers+0x2c6/0x5c0 kernel/time/timer.c:1751 __run_timers kernel/time/timer.c:2022 [inline] __run_timers kernel/time/timer.c:1995 [inline] run_timer_softirq+0x326/0x910 kernel/time/timer.c:2035 __do_softirq+0x1fb/0xadc kernel/softirq.c:571 Last potentially related work creation: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 __kasan_record_aux_stack+0x7b/0x90 mm/kasan/generic.c:488 __call_rcu_common.constprop.0+0x99/0x820 kernel/rcu/tree.c:2755 netlink_release+0xdcb/0x1e60 net/netlink/af_netlink.c:826 __sock_release+0xcd/0x280 net/socket.c:650 sock_close+0x1c/0x20 net/socket.c:1365 __fput+0x27c/0xa90 fs/file_table.c:320 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xaa8/0x2950 kernel/exit.c:867 do_group_exit+0xd4/0x2a0 kernel/exit.c:1012 __do_sys_exit_group kernel/exit.c:1023 [inline] __se_sys_exit_group kernel/exit.c:1021 [inline] __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:1021 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 Second to last potentially related work creation: kasan_save_stack+0x22/0x40 mm/kasan/common.c:45 __kasan_record_aux_stack+0x7b/0x90 mm/kasan/generic.c:488 insert_work+0x48/0x350 kernel/workqueue.c:1358 __queue_work+0x693/0x13b0 kernel/workqueue.c:1517 queue_work_on+0xf2/0x110 kernel/workqueue.c:1545 queue_work include/linux/workqueue.h:503 [inline] schedule_work include/linux/workqueue.h:564 [inline] nsim_fib_event_schedule_work drivers/net/netdevsim/fib.c:1014 [inline] nsim_fib_event_nb+0x90b/0xe30 drivers/net/netdevsim/fib.c:1043 notifier_call_chain+0xb5/0x200 kernel/notifier.c:87 atomic_notifier_call_chain+0x74/0x180 kernel/notifier.c:225 call_fib_notifiers+0x11d/0x2a0 net/core/fib_notifier.c:35 call_fib_entry_notifiers net/ipv4/fib_trie.c:106 [inline] fib_notify_alias_delete+0x2b1/0x380 net/ipv4/fib_trie.c:1706 fib_table_delete+0x65a/0xa40 net/ipv4/fib_trie.c:1765 fib_magic+0x321/0x540 net/ipv4/fib_frontend.c:1103 fib_del_ifaddr+0xc9b/0x13c0 net/ipv4/fib_frontend.c:1314 fib_inetaddr_event+0xb8/0x2a0 net/ipv4/fib_frontend.c:1445 notifier_call_chain+0xb5/0x200 kernel/notifier.c:87 blocking_notifier_call_chain kernel/notifier.c:382 [inline] blocking_notifier_call_chain+0x6b/0xa0 kernel/notifier.c:370 __inet_del_ifa+0x415/0xf70 net/ipv4/devinet.c:432 inet_del_ifa net/ipv4/devinet.c:469 [inline] inetdev_destroy net/ipv4/devinet.c:322 [inline] inetdev_event+0x569/0x16c0 net/ipv4/devinet.c:1603 notifier_call_chain+0xb5/0x200 kernel/notifier.c:87 call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1944 call_netdevice_notifiers_extack net/core/dev.c:1982 [inline] call_netdevice_notifiers net/core/dev.c:1996 [inline] unregister_netdevice_many_notify+0xa2b/0x19e0 net/core/dev.c:10839 unregister_netdevice_many net/core/dev.c:10895 [inline] unregister_netdevice_queue+0x2e5/0x3c0 net/core/dev.c:10776 unregister_netdevice include/linux/netdevice.h:3059 [inline] __tun_detach+0x1065/0x13c0 drivers/net/tun.c:684 tun_detach drivers/net/tun.c:700 [inline] tun_chr_close+0xc8/0x230 drivers/net/tun.c:3468 __fput+0x27c/0xa90 fs/file_table.c:320 task_work_run+0x16f/0x270 kernel/task_work.c:179 exit_task_work include/linux/task_work.h:38 [inline] do_exit+0xaa8/0x2950 kernel/exit.c:867 do_group_exit+0xd4/0x2a0 kernel/exit.c:1012 get_signal+0x21c3/0x2450 kernel/signal.c:2859 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+0x15f/0x250 kernel/entry/common.c:203 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline] syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:296 ret_from_fork+0x15/0x30 arch/x86/entry/entry_64.S:301 The buggy address belongs to the object at ffff88807c8e7000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 128 bytes inside of 2048-byte region [ffff88807c8e7000, ffff88807c8e7800) The buggy address belongs to the physical page: page:ffffea0001f239c0 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7c8e7 flags: 0xfff00000000200(slab|node=0|zone=1|lastcpupid=0x7ff) raw: 00fff00000000200 ffff888012440800 ffffea0000959490 ffffea0001740a10 raw: 0000000000000000 ffff88807c8e7000 0000000100000001 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 0, migratetype Unmovable, gfp_mask 0x3420c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_COMP|__GFP_HARDWALL|__GFP_THISNODE), pid 11744, tgid 11744 (syz-executor.4), ts 741901349241, free_ts 741901287107 prep_new_page mm/page_alloc.c:2531 [inline] get_page_from_freelist+0x119c/0x2ce0 mm/page_alloc.c:4283 __alloc_pages+0x1cb/0x5b0 mm/page_alloc.c:5549 __alloc_pages_node include/linux/gfp.h:237 [inline] kmem_getpages mm/slab.c:1363 [inline] cache_grow_begin+0x94/0x390 mm/slab.c:2576 cache_alloc_refill+0x27f/0x380 mm/slab.c:2949 ____cache_alloc mm/slab.c:3025 [inline] ____cache_alloc mm/slab.c:3008 [inline] __do_cache_alloc mm/slab.c:3208 [inline] slab_alloc_node mm/slab.c:3256 [inline] __kmem_cache_alloc_node+0x44f/0x510 mm/slab.c:3546 kmalloc_trace+0x26/0x60 mm/slab_common.c:1062 kmalloc include/linux/slab.h:580 [inline] kzalloc include/linux/slab.h:720 [inline] nsim_fib_create+0xa2/0xc50 drivers/net/netdevsim/fib.c:1558 nsim_drv_probe+0xc21/0x1320 drivers/net/netdevsim/dev.c:1581 call_driver_probe drivers/base/dd.c:560 [inline] really_probe+0x249/0xb90 drivers/base/dd.c:639 __driver_probe_device+0x1df/0x4d0 drivers/base/dd.c:778 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:808 __device_attach_driver+0x1d4/0x2e0 drivers/base/dd.c:936 bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:427 __device_attach+0x1e4/0x530 drivers/base/dd.c:1008 bus_probe_device+0x1e8/0x2a0 drivers/base/bus.c:487 device_add+0xbd9/0x1e90 drivers/base/core.c:3479 page last free stack trace: reset_page_owner include/linux/page_owner.h:24 [inline] free_pages_prepare mm/page_alloc.c:1446 [inline] free_pcp_prepare+0x65c/0xc00 mm/page_alloc.c:1496 free_unref_page_prepare mm/page_alloc.c:3369 [inline] free_unref_page+0x1d/0x490 mm/page_alloc.c:3464 selinux_genfs_get_sid security/selinux/hooks.c:1303 [inline] inode_doinit_with_dentry+0xaef/0x12e0 security/selinux/hooks.c:1498 selinux_d_instantiate+0x27/0x30 security/selinux/hooks.c:6347 security_d_instantiate+0x54/0xe0 security/security.c:2138 d_instantiate fs/dcache.c:2034 [inline] d_instantiate+0x5e/0xa0 fs/dcache.c:2030 __debugfs_create_file+0x20f/0x540 fs/debugfs/inode.c:445 debugfs_create_mode_unsafe fs/debugfs/file.c:427 [inline] debugfs_create_u32+0x70/0xa0 fs/debugfs/file.c:533 nsim_dev_debugfs_init drivers/net/netdevsim/dev.c:356 [inline] nsim_drv_probe+0xc12/0x1320 drivers/net/netdevsim/dev.c:1577 call_driver_probe drivers/base/dd.c:560 [inline] really_probe+0x249/0xb90 drivers/base/dd.c:639 __driver_probe_device+0x1df/0x4d0 drivers/base/dd.c:778 driver_probe_device+0x4c/0x1a0 drivers/base/dd.c:808 __device_attach_driver+0x1d4/0x2e0 drivers/base/dd.c:936 bus_for_each_drv+0x163/0x1e0 drivers/base/bus.c:427 __device_attach+0x1e4/0x530 drivers/base/dd.c:1008 bus_probe_device+0x1e8/0x2a0 drivers/base/bus.c:487 Memory state around the buggy address: ffff88807c8e6f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88807c8e7000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff88807c8e7080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88807c8e7100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88807c8e7180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ==================================================================