================================================================== BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:102 [inline] BUG: KASAN: use-after-free in test_and_set_bit include/asm-generic/bitops/instrumented-atomic.h:71 [inline] BUG: KASAN: use-after-free in l2tp_session_delete+0x27/0x520 net/l2tp/l2tp_core.c:1550 Write of size 8 at addr ffff88812d345c08 by task kworker/u4:0/8 CPU: 0 PID: 8 Comm: kworker/u4:0 Not tainted 6.1.99-syzkaller-00109-g0e8b65e41ffd #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Workqueue: l2tp l2tp_tunnel_del_work Call Trace: __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106 print_address_description mm/kasan/report.c:316 [inline] print_report+0x158/0x4e0 mm/kasan/report.c:427 kasan_report+0x13c/0x170 mm/kasan/report.c:531 kasan_check_range+0x294/0x2a0 mm/kasan/generic.c:189 __kasan_check_write+0x14/0x20 mm/kasan/shadow.c:37 instrument_atomic_read_write include/linux/instrumented.h:102 [inline] test_and_set_bit include/asm-generic/bitops/instrumented-atomic.h:71 [inline] l2tp_session_delete+0x27/0x520 net/l2tp/l2tp_core.c:1550 l2tp_tunnel_closeall net/l2tp/l2tp_core.c:1205 [inline] l2tp_tunnel_del_work+0x1f8/0x400 net/l2tp/l2tp_core.c:1245 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446 kthread+0x26d/0x300 kernel/kthread.c:386 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 Allocated by task 926: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_alloc_info+0x1f/0x30 mm/kasan/generic.c:505 ____kasan_kmalloc mm/kasan/common.c:379 [inline] __kasan_kmalloc+0x9c/0xb0 mm/kasan/common.c:388 kasan_kmalloc include/linux/kasan.h:212 [inline] __do_kmalloc_node mm/slab_common.c:957 [inline] __kmalloc+0xb4/0x1e0 mm/slab_common.c:970 kmalloc include/linux/slab.h:561 [inline] kzalloc include/linux/slab.h:692 [inline] l2tp_session_create+0x38/0xbe0 net/l2tp/l2tp_core.c:1586 pppol2tp_connect+0xc5d/0x1690 net/l2tp/l2tp_ppp.c:781 __sys_connect_file net/socket.c:1996 [inline] __sys_connect+0x2c9/0x300 net/socket.c:2013 __do_sys_connect net/socket.c:2023 [inline] __se_sys_connect net/socket.c:2020 [inline] __x64_sys_connect+0x7a/0x90 net/socket.c:2020 x64_sys_call+0x14e/0x9a0 arch/x86/include/generated/asm/syscalls_64.h:43 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 928: kasan_save_stack mm/kasan/common.c:45 [inline] kasan_set_track+0x4b/0x70 mm/kasan/common.c:52 kasan_save_free_info+0x2b/0x40 mm/kasan/generic.c:516 ____kasan_slab_free+0x131/0x180 mm/kasan/common.c:241 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:249 kasan_slab_free include/linux/kasan.h:178 [inline] slab_free_hook mm/slub.c:1745 [inline] slab_free_freelist_hook mm/slub.c:1771 [inline] slab_free mm/slub.c:3684 [inline] __kmem_cache_free+0x218/0x3b0 mm/slub.c:3697 kfree+0x7a/0xf0 mm/slab_common.c:1009 l2tp_session_free net/l2tp/l2tp_core.c:163 [inline] l2tp_session_dec_refcount+0xa9/0x1b0 net/l2tp/l2tp_core.c:200 pppol2tp_session_destruct+0xaf/0xf0 net/l2tp/l2tp_ppp.c:418 __sk_destruct+0x56/0x5c0 net/core/sock.c:2145 sk_destruct net/core/sock.c:2190 [inline] __sk_free+0x36c/0x470 net/core/sock.c:2201 sk_free+0x51/0x80 net/core/sock.c:2212 sock_put include/net/sock.h:2041 [inline] pppol2tp_put_sk+0x77/0xb0 net/l2tp/l2tp_ppp.c:401 rcu_do_batch+0x534/0xb80 kernel/rcu/tree.c:2296 rcu_core+0x4ee/0xf10 kernel/rcu/tree.c:2556 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2573 handle_softirqs+0x1db/0x650 kernel/softirq.c:617 __do_softirq kernel/softirq.c:655 [inline] invoke_softirq kernel/softirq.c:472 [inline] __irq_exit_rcu+0x52/0xf0 kernel/softirq.c:704 irq_exit_rcu+0x9/0x10 kernel/softirq.c:716 sysvec_apic_timer_interrupt+0x9a/0xc0 arch/x86/kernel/apic/apic.c:1106 asm_sysvec_apic_timer_interrupt+0x1b/0x20 arch/x86/include/asm/idtentry.h:653 Last potentially related work creation: kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45 __kasan_record_aux_stack+0xb4/0xc0 mm/kasan/generic.c:486 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:496 __call_rcu_common kernel/rcu/tree.c:2806 [inline] call_rcu+0xee/0x1340 kernel/rcu/tree.c:2925 pppol2tp_release+0x20f/0x2d0 net/l2tp/l2tp_ppp.c:457 __sock_release net/socket.c:652 [inline] sock_close+0xdf/0x270 net/socket.c:1390 __fput+0x1e5/0x870 fs/file_table.c:320 ____fput+0x15/0x20 fs/file_table.c:348 task_work_run+0x24d/0x2e0 kernel/task_work.c:179 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline] exit_to_user_mode_loop+0x94/0xa0 kernel/entry/common.c:177 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:210 __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline] syscall_exit_to_user_mode+0x26/0x130 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 ffff88812d345c00 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 8 bytes inside of 512-byte region [ffff88812d345c00, ffff88812d345e00) The buggy address belongs to the physical page: page:ffffea0004b4d100 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x12d344 head:ffffea0004b4d100 order:2 compound_mapcount:0 compound_pincount:0 flags: 0x4000000000010200(slab|head|zone=1) raw: 4000000000010200 0000000000000000 dead000000000001 ffff888100042f00 raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected page_owner tracks the page as allocated page last allocated via order 2, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 293, tgid 293 (syz-executor), ts 21825412695, free_ts 0 set_page_owner include/linux/page_owner.h:33 [inline] post_alloc_hook+0x213/0x220 mm/page_alloc.c:2590 prep_new_page+0x1b/0x110 mm/page_alloc.c:2597 get_page_from_freelist+0x27ea/0x2870 mm/page_alloc.c:4425 __alloc_pages+0x3a1/0x780 mm/page_alloc.c:5714 alloc_slab_page+0x6c/0xf0 allocate_slab mm/slub.c:1962 [inline] new_slab+0x90/0x3e0 mm/slub.c:2015 ___slab_alloc+0x6f9/0xb80 mm/slub.c:3203 __slab_alloc+0x5d/0xa0 mm/slub.c:3302 slab_alloc_node mm/slub.c:3387 [inline] __kmem_cache_alloc_node+0x1af/0x250 mm/slub.c:3460 __do_kmalloc_node mm/slab_common.c:956 [inline] __kmalloc_node_track_caller+0xa2/0x1e0 mm/slab_common.c:977 kmalloc_reserve net/core/skbuff.c:446 [inline] __alloc_skb+0x125/0x2d0 net/core/skbuff.c:515 alloc_skb include/linux/skbuff.h:1290 [inline] nlmsg_new include/net/netlink.h:991 [inline] netlink_ack+0x392/0x12a0 net/netlink/af_netlink.c:2455 netlink_rcv_skb+0x24a/0x410 net/netlink/af_netlink.c:2524 rtnetlink_rcv+0x1c/0x20 net/core/rtnetlink.c:6139 netlink_unicast_kernel net/netlink/af_netlink.c:1327 [inline] netlink_unicast+0x906/0xab0 net/netlink/af_netlink.c:1353 netlink_sendmsg+0xa15/0xd30 net/netlink/af_netlink.c:1875 page_owner free stack trace missing Memory state around the buggy address: ffff88812d345b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88812d345b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88812d345c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff88812d345c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff88812d345d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ================================================================== ------------[ cut here ]------------ refcount_t: underflow; use-after-free. WARNING: CPU: 1 PID: 8 at lib/refcount.c:28 refcount_warn_saturate+0x158/0x1a0 lib/refcount.c:28 Modules linked in: CPU: 1 PID: 8 Comm: kworker/u4:0 Tainted: G B 6.1.99-syzkaller-00109-g0e8b65e41ffd #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024 Workqueue: l2tp l2tp_tunnel_del_work RIP: 0010:refcount_warn_saturate+0x158/0x1a0 lib/refcount.c:28 Code: 05 01 48 c7 c7 c0 a2 e9 85 e8 04 98 cd fe 0f 0b eb 8b e8 db 9f fe fe c6 05 db 72 18 05 01 48 c7 c7 20 a3 e9 85 e8 e8 97 cd fe <0f> 0b e9 6c ff ff ff e8 bc 9f fe fe c6 05 bd 72 18 05 01 48 c7 c7 RSP: 0018:ffffc90000087c18 EFLAGS: 00010246 RAX: 8c6eaa5c0f1c5400 RBX: 0000000000000003 RCX: ffff88810039e540 RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000 RBP: ffffc90000087c28 R08: ffffffff81449dee R09: fffff52000010edd R10: 0000000000000000 R11: dffffc0000000001 R12: ffff88812d345c80 R13: ffff88812d345c00 R14: 0000000000000003 R15: ffff88812d345c88 FS: 0000000000000000(0000) GS:ffff8881f6f00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000110c316497 CR3: 000000011488c000 CR4: 00000000003506a0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: __refcount_sub_and_test include/linux/refcount.h:283 [inline] __refcount_dec_and_test include/linux/refcount.h:315 [inline] refcount_dec_and_test include/linux/refcount.h:333 [inline] l2tp_session_dec_refcount+0xc4/0x1b0 net/l2tp/l2tp_core.c:199 l2tp_session_delete+0x407/0x520 net/l2tp/l2tp_core.c:1559 l2tp_tunnel_closeall net/l2tp/l2tp_core.c:1205 [inline] l2tp_tunnel_del_work+0x1f8/0x400 net/l2tp/l2tp_core.c:1245 process_one_work+0x73d/0xcb0 kernel/workqueue.c:2299 worker_thread+0xa60/0x1260 kernel/workqueue.c:2446 kthread+0x26d/0x300 kernel/kthread.c:386 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308 ---[ end trace 0000000000000000 ]---