================================================================== 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 ffff888130740008 by task kworker/u4:0/8 CPU: 1 PID: 8 Comm: kworker/u4:0 Not tainted 6.1.99-syzkaller-00014-g4d8187d2c8fa #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 446: 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 10: 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 ffff888130740000 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 8 bytes inside of 512-byte region [ffff888130740000, ffff888130740200) The buggy address belongs to the physical page: page:ffffea0004c1d000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x130740 head:ffffea0004c1d000 order:2 compound_mapcount:0 compound_pincount:0 flags: 0x4000000000010200(slab|head|zone=1) raw: 4000000000010200 0000000000000000 dead000000000122 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 0x1d20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC|__GFP_HARDWALL), pid 412, tgid 410 (syz.1.18), ts 46783201179, 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] alloc_skb_with_frags+0xa6/0x680 net/core/skbuff.c:6168 sock_alloc_send_pskb+0x915/0xa50 net/core/sock.c:2753 sock_alloc_send_skb include/net/sock.h:1931 [inline] __ip_append_data+0x2622/0x3930 net/ipv4/ip_output.c:1120 ip_make_skb+0x1a2/0x420 net/ipv4/ip_output.c:1662 udp_sendmsg+0x1cf1/0x2af0 net/ipv4/udp.c:1274 page_owner free stack trace missing Memory state around the buggy address: ffff88813073ff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88813073ff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff888130740000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff888130740080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff888130740100: 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: 0 PID: 8 at lib/refcount.c:28 refcount_warn_saturate+0x158/0x1a0 lib/refcount.c:28 Modules linked in: CPU: 0 PID: 8 Comm: kworker/u4:0 Tainted: G B 6.1.99-syzkaller-00014-g4d8187d2c8fa #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 40 a5 e9 85 e8 b4 97 cd fe 0f 0b eb 8b e8 8b 9f fe fe c6 05 0b 73 18 05 01 48 c7 c7 a0 a5 e9 85 e8 98 97 cd fe <0f> 0b e9 6c ff ff ff e8 6c 9f fe fe c6 05 ed 72 18 05 01 48 c7 c7 RSP: 0018:ffffc90000087c18 EFLAGS: 00010246 RAX: fcf70b361ee77700 RBX: 0000000000000003 RCX: ffff88810039d100 RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000000 RBP: ffffc90000087c28 R08: ffffffff81449dee R09: fffff52000010edd R10: 0000000000000000 R11: dffffc0000000001 R12: ffff888130740080 R13: ffff888130740000 R14: 0000000000000003 R15: ffff888130740088 FS: 0000000000000000(0000) GS:ffff8881f6e00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f0bbaf95ed8 CR3: 000000010efe0000 CR4: 00000000003506b0 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 ]---