syzbot


KASAN: use-after-free Write in l2tp_session_delete

Status: premoderation: reported on 2024/06/13 19:33
Reported-by: syzbot+b4c97fa2d49329e53bca@syzkaller.appspotmail.com
First crash: 32d, last: 18d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Write in l2tp_session_delete 2 351d 439d 0/3 auto-obsoleted due to no activity on 2023/11/08 00:22
upstream KASAN: slab-use-after-free Write in l2tp_session_delete net C done 1286 22h06m 20d 4/27 upstream: reported C repro on 2024/06/25 13:25

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
BUG: KASAN: use-after-free in test_and_set_bit include/asm-generic/bitops/instrumented-atomic.h:70 [inline]
BUG: KASAN: use-after-free in l2tp_session_delete+0x24/0x4e0 net/l2tp/l2tp_core.c:1552
Write of size 8 at addr ffff88811066bc08 by task kworker/u4:4/442

CPU: 1 PID: 442 Comm: kworker/u4:4 Not tainted 5.15.150-syzkaller-00330-g9044d25b8ff5 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/2024
Workqueue: l2tp l2tp_tunnel_del_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x151/0x1b7 lib/dump_stack.c:106
 print_address_description+0x87/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:427 [inline]
 kasan_report+0x179/0x1c0 mm/kasan/report.c:444
 kasan_check_range+0x293/0x2a0 mm/kasan/generic.c:189
 __kasan_check_write+0x14/0x20 mm/kasan/shadow.c:37
 instrument_atomic_read_write include/linux/instrumented.h:101 [inline]
 test_and_set_bit include/asm-generic/bitops/instrumented-atomic.h:70 [inline]
 l2tp_session_delete+0x24/0x4e0 net/l2tp/l2tp_core.c:1552
 l2tp_tunnel_closeall net/l2tp/l2tp_core.c:1207 [inline]
 l2tp_tunnel_del_work+0x19d/0x380 net/l2tp/l2tp_core.c:1247
 process_one_work+0x6bb/0xc10 kernel/workqueue.c:2325
 worker_thread+0xad5/0x12a0 kernel/workqueue.c:2472
 kthread+0x421/0x510 kernel/kthread.c:337
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298
 </TASK>

Allocated by task 11415:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:45 [inline]
 set_alloc_info mm/kasan/common.c:433 [inline]
 ____kasan_kmalloc+0xdb/0x110 mm/kasan/common.c:512
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:521
 kasan_kmalloc include/linux/kasan.h:227 [inline]
 __kmalloc+0x13a/0x270 mm/slub.c:4427
 kmalloc include/linux/slab.h:608 [inline]
 kzalloc include/linux/slab.h:733 [inline]
 l2tp_session_create+0x38/0xb60 net/l2tp/l2tp_core.c:1588
 pppol2tp_connect+0xc5d/0x1690 net/l2tp/l2tp_ppp.c:782
 __sys_connect_file net/socket.c:1918 [inline]
 __sys_connect+0x38b/0x410 net/socket.c:1935
 __do_sys_connect net/socket.c:1945 [inline]
 __se_sys_connect net/socket.c:1942 [inline]
 __x64_sys_connect+0x7a/0x90 net/socket.c:1942
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Freed by task 11415:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:45
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:370
 ____kasan_slab_free+0x126/0x160 mm/kasan/common.c:365
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:373
 kasan_slab_free include/linux/kasan.h:193 [inline]
 slab_free_hook mm/slub.c:1723 [inline]
 slab_free_freelist_hook+0xbd/0x190 mm/slub.c:1749
 slab_free mm/slub.c:3519 [inline]
 kfree+0xc8/0x220 mm/slub.c:4579
 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:419
 __sk_destruct+0x56/0x5b0 net/core/sock.c:1950
 sk_destruct net/core/sock.c:1995 [inline]
 __sk_free+0x36c/0x470 net/core/sock.c:2006
 sk_free+0x51/0x80 net/core/sock.c:2017
 sock_put include/net/sock.h:1914 [inline]
 pppol2tp_put_sk+0x77/0xb0 net/l2tp/l2tp_ppp.c:402
 rcu_do_batch+0x57a/0xc10 kernel/rcu/tree.c:2523
 rcu_core+0x517/0x1020 kernel/rcu/tree.c:2763
 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2776
 __do_softirq+0x26d/0x5bf kernel/softirq.c:565

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0xf0 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 __call_rcu_common kernel/rcu/tree.c:3007 [inline]
 call_rcu+0x135/0x1310 kernel/rcu/tree.c:3125
 pppol2tp_release+0x20f/0x2d0 net/l2tp/l2tp_ppp.c:458
 __sock_release net/socket.c:649 [inline]
 sock_close+0xdf/0x270 net/socket.c:1336
 __fput+0x3fe/0x910 fs/file_table.c:280
 ____fput+0x15/0x20 fs/file_table.c:308
 task_work_run+0x129/0x190 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0xc4/0xe0 kernel/entry/common.c:175
 exit_to_user_mode_prepare+0x5a/0xa0 kernel/entry/common.c:208
 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
 syscall_exit_to_user_mode+0x26/0x160 kernel/entry/common.c:301
 do_syscall_64+0x49/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:38
 __kasan_record_aux_stack+0xd3/0xf0 mm/kasan/generic.c:348
 kasan_record_aux_stack_noalloc+0xb/0x10 mm/kasan/generic.c:358
 __call_rcu_common kernel/rcu/tree.c:3007 [inline]
 call_rcu+0x135/0x1310 kernel/rcu/tree.c:3125
 fib6_info_release include/net/ip6_fib.h:349 [inline]
 fib6_del_route net/ipv6/ip6_fib.c:1991 [inline]
 fib6_del+0xd30/0x1060 net/ipv6/ip6_fib.c:2024
 fib6_clean_node+0x2ed/0x550 net/ipv6/ip6_fib.c:2186
 fib6_walk_continue+0x52d/0x720 net/ipv6/ip6_fib.c:2108
 fib6_walk+0x172/0x2d0 net/ipv6/ip6_fib.c:2156
 fib6_clean_tree net/ipv6/ip6_fib.c:2236 [inline]
 __fib6_clean_all net/ipv6/ip6_fib.c:2252 [inline]
 fib6_clean_all+0x202/0x2c0 net/ipv6/ip6_fib.c:2263
 rt6_sync_down_dev net/ipv6/route.c:4892 [inline]
 rt6_disable_ip+0x153/0x730 net/ipv6/route.c:4897
 addrconf_ifdown+0x160/0x1ae0 net/ipv6/addrconf.c:3796
 addrconf_notify+0x37d/0xdd0
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0x8c/0xf0 kernel/notifier.c:391
 call_netdevice_notifiers_info net/core/dev.c:2025 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2037 [inline]
 call_netdevice_notifiers net/core/dev.c:2051 [inline]
 dev_close_many+0x37c/0x530 net/core/dev.c:1626
 unregister_netdevice_many+0x492/0x17c0 net/core/dev.c:11081
 default_device_exit_batch+0x38a/0x3f0 net/core/dev.c:11638
 ops_exit_list net/core/net_namespace.c:174 [inline]
 cleanup_net+0x6ce/0xc00 net/core/net_namespace.c:596
 process_one_work+0x6bb/0xc10 kernel/workqueue.c:2325
 worker_thread+0xad5/0x12a0 kernel/workqueue.c:2472
 kthread+0x421/0x510 kernel/kthread.c:337
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

The buggy address belongs to the object at ffff88811066bc00
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 8 bytes inside of
 512-byte region [ffff88811066bc00, ffff88811066be00)
The buggy address belongs to the page:
page:ffffea0004419a00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x110668
head:ffffea0004419a00 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 ffffea000485dd00 0000000300000003 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 0x152a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_HARDWALL), pid 6, ts 26451976125, free_ts 26243182438
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x1a3/0x1b0 mm/page_alloc.c:2604
 prep_new_page+0x1b/0x110 mm/page_alloc.c:2610
 get_page_from_freelist+0x3550/0x35d0 mm/page_alloc.c:4484
 __alloc_pages+0x27e/0x8f0 mm/page_alloc.c:5776
 allocate_slab mm/slub.c:1932 [inline]
 new_slab+0x9a/0x4e0 mm/slub.c:1995
 ___slab_alloc+0x39e/0x830 mm/slub.c:3028
 __slab_alloc+0x4a/0x90 mm/slub.c:3115
 slab_alloc_node mm/slub.c:3206 [inline]
 slab_alloc mm/slub.c:3248 [inline]
 __kmalloc+0x16d/0x270 mm/slub.c:4423
 kmalloc include/linux/slab.h:608 [inline]
 kzalloc include/linux/slab.h:733 [inline]
 neigh_alloc net/core/neighbour.c:438 [inline]
 ___neigh_create+0x6d0/0x1bd0 net/core/neighbour.c:591
 __neigh_create+0x32/0x40 net/core/neighbour.c:679
 ip6_finish_output2+0x9ee/0x16e0 net/ipv6/ip6_output.c:123
 __ip6_finish_output+0x60f/0x7c0 net/ipv6/ip6_output.c:197
 ip6_finish_output+0x31/0x210 net/ipv6/ip6_output.c:207
 NF_HOOK_COND include/linux/netfilter.h:294 [inline]
 ip6_output+0x1f7/0x4d0 net/ipv6/ip6_output.c:230
 dst_output include/net/dst.h:444 [inline]
 NF_HOOK include/linux/netfilter.h:305 [inline]
 mld_sendpack+0x662/0xbb0 net/ipv6/mcast.c:1820
 mld_send_cr net/ipv6/mcast.c:2121 [inline]
 mld_ifc_work+0x7dc/0xbb0 net/ipv6/mcast.c:2653
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1471 [inline]
 free_pcp_prepare mm/page_alloc.c:1543 [inline]
 free_unref_page_prepare+0x7c8/0x7d0 mm/page_alloc.c:3533
 free_unref_page+0xe8/0x750 mm/page_alloc.c:3615
 free_the_page mm/page_alloc.c:804 [inline]
 __free_pages+0x61/0xf0 mm/page_alloc.c:5852
 __free_slab+0xec/0x1d0 mm/slub.c:2020
 free_slab mm/slub.c:2035 [inline]
 discard_slab mm/slub.c:2041 [inline]
 __unfreeze_partials+0x165/0x1a0 mm/slub.c:2527
 put_cpu_partial+0xc4/0x120 mm/slub.c:2607
 __slab_free+0x1c8/0x290 mm/slub.c:3388
 do_slab_free mm/slub.c:3507 [inline]
 ___cache_free+0x109/0x120 mm/slub.c:3526
 qlink_free+0x4d/0x90 mm/kasan/quarantine.c:157
 qlist_free_all+0x44/0xb0 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x15a/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xe0 mm/kasan/common.c:443
 kasan_slab_alloc include/linux/kasan.h:217 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:550
 slab_alloc_node mm/slub.c:3240 [inline]
 slab_alloc mm/slub.c:3248 [inline]
 kmem_cache_alloc+0xf5/0x200 mm/slub.c:3253
 sock_alloc_inode+0x1b/0xb0 net/socket.c:303
 alloc_inode fs/inode.c:236 [inline]
 new_inode_pseudo+0x64/0x220 fs/inode.c:937

Memory state around the buggy address:
 ffff88811066bb00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88811066bb80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88811066bc00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff88811066bc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88811066bd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/06/27 04:59 android13-5.15-lts 9044d25b8ff5 c6d33a01 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Write in l2tp_session_delete
2024/06/13 19:33 android13-5.15-lts 19f346d27871 a9616ff5 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-5-15 KASAN: use-after-free Write in l2tp_session_delete
* Struck through repros no longer work on HEAD.