syzbot


KASAN: use-after-free Write in l2tp_session_delete

Status: premoderation: reported syz repro on 2024/10/08 10:15
Reported-by: syzbot+5d024d4d686f39096399@syzkaller.appspotmail.com
First crash: 44d, last: 10d
Bug presence (2)
Date Name Commit Repro Result
2024/11/16 lts (merge base) aa4cd140bba5 C Didn't crash
2024/11/16 upstream (ToT) b5a24181e461 C Didn't crash
Similar bugs (7)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-5-10 KASAN: use-after-free Write in l2tp_session_delete 2 30d 54d 0/2 premoderation: reported on 2024/09/28 01:24
linux-6.1 KASAN: use-after-free Write in l2tp_session_delete 2 62d 84d 0/3 upstream: reported on 2024/08/29 01:02
android-5-15 KASAN: use-after-free Write in l2tp_session_delete 2 147d 160d 0/2 auto-obsoleted due to no activity on 2024/09/25 05:09
android-5-15 KASAN: use-after-free Write in l2tp_session_delete (2) 2 1d10h 6d19h 0/2 premoderation: reported on 2024/11/14 20:24
linux-5.15 KASAN: use-after-free Write in l2tp_session_delete 2 479d 568d 0/3 auto-obsoleted due to no activity on 2023/11/08 00:22
linux-5.15 KASAN: use-after-free Write in l2tp_session_delete (2) 1 62d 62d 0/3 upstream: reported on 2024/09/19 22:43
upstream KASAN: slab-use-after-free Write in l2tp_session_delete net C done 1286 129d 149d 27/28 fixed on 2024/08/14 03:44

Sample crash report:
IPv6: ADDRCONF(NETDEV_CHANGE): veth1_macvtap: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth0_macvtap: link becomes ready
==================================================================
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:1561
Write of size 8 at addr ffff88811f0a7408 by task kworker/u4:2/43

CPU: 0 PID: 43 Comm: kworker/u4:2 Not tainted 6.1.112-syzkaller-00005-geef3d33656ce #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/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 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:1561
 l2tp_tunnel_closeall net/l2tp/l2tp_core.c:1216 [inline]
 l2tp_tunnel_del_work+0x1f8/0x400 net/l2tp/l2tp_core.c:1256
 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:295
 </TASK>

Allocated by task 19525:
 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:938 [inline]
 __kmalloc+0xb4/0x1e0 mm/slab_common.c:951
 kmalloc include/linux/slab.h:562 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 l2tp_session_create+0x38/0xbe0 net/l2tp/l2tp_core.c:1597
 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 23:
 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:990
 l2tp_session_free net/l2tp/l2tp_core.c:168 [inline]
 l2tp_session_dec_refcount+0xa9/0x1b0 net/l2tp/l2tp_core.c:205
 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+0x552/0xbe0 kernel/rcu/tree.c:2297
 rcu_core+0x4ee/0xf10 kernel/rcu/tree.c:2557
 rcu_core_si+0x9/0x10 kernel/rcu/tree.c:2574
 handle_softirqs+0x1db/0x650 kernel/softirq.c:617
 run_ksoftirqd+0x28/0x30 kernel/softirq.c:994
 smpboot_thread_fn+0x466/0x8d0 kernel/smpboot.c:164
 kthread+0x26d/0x300 kernel/kthread.c:386
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

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:2807 [inline]
 call_rcu+0xdc/0x10f0 kernel/rcu/tree.c:2926
 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:203
 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

Second to 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
 kvfree_call_rcu+0x9f/0x800 kernel/rcu/tree.c:3445
 neigh_destroy+0x429/0x560 net/core/neighbour.c:918
 neigh_release include/net/neighbour.h:455 [inline]
 neigh_cleanup_and_release+0x73/0x1b0 net/core/neighbour.c:103
 neigh_flush_dev+0x7b5/0x970 net/core/neighbour.c:429
 __neigh_ifdown+0x3d/0x410 net/core/neighbour.c:446
 neigh_ifdown+0x1f/0x30 net/core/neighbour.c:464
 rt6_disable_ip+0x97e/0x9e0 net/ipv6/route.c:4889
 addrconf_ifdown+0x15e/0x1ab0 net/ipv6/addrconf.c:3804
 addrconf_notify+0x32f/0xe10
 notifier_call_chain kernel/notifier.c:87 [inline]
 raw_notifier_call_chain+0x8c/0xf0 kernel/notifier.c:455
 call_netdevice_notifiers_info net/core/dev.c:1978 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2016 [inline]
 call_netdevice_notifiers net/core/dev.c:2030 [inline]
 dev_close_many+0x37c/0x530 net/core/dev.c:1578
 unregister_netdevice_many+0x4d1/0x1730 net/core/dev.c:10872
 default_device_exit_batch+0x975/0xa00 net/core/dev.c:11411
 ops_exit_list net/core/net_namespace.c:177 [inline]
 cleanup_net+0x6c9/0xbf0 net/core/net_namespace.c:604
 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:295

The buggy address belongs to the object at ffff88811f0a7400
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 8 bytes inside of
 512-byte region [ffff88811f0a7400, ffff88811f0a7600)

The buggy address belongs to the physical page:
page:ffffea00047c2900 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11f0a4
head:ffffea00047c2900 order:2 compound_mapcount:0 compound_pincount:0
flags: 0x4000000000010200(slab|head|zone=1)
raw: 4000000000010200 dead000000000100 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 653, tgid 653 (kworker/u4:5), ts 370836440173, free_ts 323952731058
 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+0x2980/0x2a10 mm/page_alloc.c:4439
 __alloc_pages+0x234/0x610 mm/page_alloc.c:5728
 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:937 [inline]
 __kmalloc+0xa3/0x1e0 mm/slab_common.c:951
 kmalloc include/linux/slab.h:562 [inline]
 kzalloc include/linux/slab.h:693 [inline]
 fib6_info_alloc+0x33/0xe0 net/ipv6/ip6_fib.c:156
 ip6_route_info_create+0x50b/0x14c0 net/ipv6/route.c:3757
 addrconf_f6i_alloc+0x215/0x4c0 net/ipv6/route.c:4559
 ipv6_add_addr+0x450/0xdf0 net/ipv6/addrconf.c:1123
 addrconf_add_linklocal+0x326/0x9e0 net/ipv6/addrconf.c:3264
 addrconf_addr_gen+0x57f/0xcf0 net/ipv6/addrconf.c:3395
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1498 [inline]
 free_pcp_prepare mm/page_alloc.c:1572 [inline]
 free_unref_page_prepare+0x83d/0x850 mm/page_alloc.c:3511
 free_unref_page+0xb2/0x5c0 mm/page_alloc.c:3607
 free_the_page mm/page_alloc.c:798 [inline]
 __free_pages+0x61/0xf0 mm/page_alloc.c:5817
 __free_slab+0xce/0x1a0 mm/slub.c:2039
 free_slab mm/slub.c:2054 [inline]
 discard_slab+0x29/0x40 mm/slub.c:2060
 __slab_free+0x205/0x280 mm/slub.c:3597
 do_slab_free mm/slub.c:3638 [inline]
 ___cache_free+0xc6/0xd0 mm/slub.c:3691
 qlink_free mm/kasan/quarantine.c:168 [inline]
 qlist_free_all+0xc5/0x140 mm/kasan/quarantine.c:187
 kasan_quarantine_reduce+0x15a/0x180 mm/kasan/quarantine.c:294
 __kasan_slab_alloc+0x24/0x80 mm/kasan/common.c:310
 kasan_slab_alloc include/linux/kasan.h:202 [inline]
 slab_post_alloc_hook+0x53/0x2c0 mm/slab.h:768
 slab_alloc_node mm/slub.c:3421 [inline]
 slab_alloc mm/slub.c:3429 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3436 [inline]
 kmem_cache_alloc+0x175/0x2c0 mm/slub.c:3445
 kmem_cache_zalloc include/linux/slab.h:683 [inline]
 lsm_file_alloc security/security.c:575 [inline]
 security_file_alloc+0x29/0x120 security/security.c:1543
 __alloc_file+0xb2/0x2a0 fs/file_table.c:143
 alloc_empty_file+0x95/0x180 fs/file_table.c:187
 path_openat+0xec/0x2d60 fs/namei.c:3770

Memory state around the buggy address:
 ffff88811f0a7300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff88811f0a7380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88811f0a7400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff88811f0a7480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88811f0a7500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
IPv6: ADDRCONF(NETDEV_CHANGE): veth1_to_batadv: link becomes ready
device bridge_slave_1 left promiscuous mode
bridge0: port 2(bridge_slave_1) entered disabled state
device bridge_slave_0 left promiscuous mode
bridge0: port 1(bridge_slave_0) entered disabled state
device veth1_macvtap left promiscuous mode
device veth0_vlan left promiscuous mode
IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready
bridge0: port 1(bridge_slave_0) entered disabled state
bridge0: port 2(bridge_slave_1) entered disabled state
IPv6: ADDRCONF(NETDEV_CHANGE): bridge_slave_0: link becomes ready
bridge0: port 1(bridge_slave_0) entered blocking state
bridge0: port 1(bridge_slave_0) entered forwarding state
IPv6: ADDRCONF(NETDEV_CHANGE): bridge_slave_1: link becomes ready
bridge0: port 2(bridge_slave_1) entered blocking state
bridge0: port 2(bridge_slave_1) entered forwarding state
IPv6: ADDRCONF(NETDEV_CHANGE): hsr_slave_0: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): hsr_slave_1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth0_virt_wifi: link becomes ready

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/11/11 00:55 android14-6.1 eef3d33656ce 6b856513 .config console log report syz / log [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in l2tp_session_delete
2024/10/15 00:26 android14-6.1 4d8187d2c8fa b01b6661 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in l2tp_session_delete
2024/10/09 19:14 android14-6.1 80e851bf0d46 56fb2cb7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in l2tp_session_delete
2024/10/08 10:14 android14-6.1 0e8b65e41ffd 402f1df0 .config console log report info [disk image] [vmlinux] [kernel image] ci2-android-6-1 KASAN: use-after-free Write in l2tp_session_delete
* Struck through repros no longer work on HEAD.