syzbot


KASAN: use-after-free Write in l2tp_session_delete (2)

Status: upstream: reported on 2024/09/19 22:43
Reported-by: syzbot+6136f4c545c0e002a305@syzkaller.appspotmail.com
First crash: 1d02h, last: 1d02h
Similar bugs (4)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 KASAN: use-after-free Write in l2tp_session_delete 2 21h39m 23d 0/3 upstream: reported on 2024/08/29 01:02
android-5-15 KASAN: use-after-free Write in l2tp_session_delete 2 85d 99d 0/2 premoderation: reported on 2024/06/13 19:33
linux-5.15 KASAN: use-after-free Write in l2tp_session_delete 2 418d 506d 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 67d 87d 27/28 fixed on 2024/08/14 03:44

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+0x21/0x540 net/l2tp/l2tp_core.c:1563
Write of size 8 at addr ffff888024544008 by task kworker/u4:2/154

CPU: 1 PID: 154 Comm: kworker/u4:2 Not tainted 5.15.167-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Workqueue: l2tp l2tp_tunnel_del_work
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106
 print_address_description+0x63/0x3b0 mm/kasan/report.c:248
 __kasan_report mm/kasan/report.c:434 [inline]
 kasan_report+0x16b/0x1c0 mm/kasan/report.c:451
 kasan_check_range+0x27e/0x290 mm/kasan/generic.c:189
 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+0x21/0x540 net/l2tp/l2tp_core.c:1563
 l2tp_tunnel_closeall net/l2tp/l2tp_core.c:1218 [inline]
 l2tp_tunnel_del_work+0x1a2/0x340 net/l2tp/l2tp_core.c:1258
 process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
 worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287
 </TASK>

Allocated by task 4161:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:434 [inline]
 ____kasan_kmalloc+0xba/0xf0 mm/kasan/common.c:513
 kasan_kmalloc include/linux/kasan.h:264 [inline]
 __kmalloc+0x168/0x300 mm/slub.c:4407
 kmalloc include/linux/slab.h:596 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 l2tp_session_create+0x37/0xb30 net/l2tp/l2tp_core.c:1599
 pppol2tp_connect+0xc3d/0x1720 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+0x76/0x80 net/socket.c:1942
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Freed by task 20:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4b/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:360
 ____kasan_slab_free+0xd8/0x120 mm/kasan/common.c:366
 kasan_slab_free include/linux/kasan.h:230 [inline]
 slab_free_hook mm/slub.c:1705 [inline]
 slab_free_freelist_hook+0xdd/0x160 mm/slub.c:1731
 slab_free mm/slub.c:3499 [inline]
 kfree+0xf1/0x270 mm/slub.c:4559
 __sk_destruct+0x54/0x840 net/core/sock.c:1955
 rcu_do_batch kernel/rcu/tree.c:2523 [inline]
 rcu_core+0xa15/0x1650 kernel/rcu/tree.c:2763
 handle_softirqs+0x3a7/0x930 kernel/softirq.c:558
 run_ksoftirqd+0xc6/0x120 kernel/softirq.c:925
 smpboot_thread_fn+0x51b/0x9d0 kernel/smpboot.c:164
 kthread+0x3f6/0x4f0 kernel/kthread.c:334
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

Last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
 __call_rcu kernel/rcu/tree.c:3007 [inline]
 call_rcu+0x1c4/0xa70 kernel/rcu/tree.c:3087
 pppol2tp_release+0x247/0x340 net/l2tp/l2tp_ppp.c:458
 __sock_release net/socket.c:649 [inline]
 sock_close+0xcd/0x230 net/socket.c:1336
 __fput+0x3fe/0x8e0 fs/file_table.c:280
 task_work_run+0x129/0x1a0 kernel/task_work.c:188
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:181
 exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214
 __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
 syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x66/0xd0

Second to last potentially related work creation:
 kasan_save_stack+0x36/0x60 mm/kasan/common.c:38
 kasan_record_aux_stack+0xba/0x100 mm/kasan/generic.c:348
 kvfree_call_rcu+0x118/0x8a0 kernel/rcu/tree.c:3596
 neigh_del net/core/neighbour.c:197 [inline]
 neigh_remove_one+0x4b1/0x5c0 net/core/neighbour.c:218
 neigh_forced_gc net/core/neighbour.c:251 [inline]
 neigh_alloc net/core/neighbour.c:429 [inline]
 ___neigh_create+0x45a/0x2220 net/core/neighbour.c:591
 ip6_finish_output2+0x11c5/0x15a0 net/ipv6/ip6_output.c:127
 ip6_send_skb+0x1aa/0x390 net/ipv6/ip6_output.c:1952
 icmp6_send+0x1732/0x21e0 net/ipv6/icmp.c:630
 __icmpv6_send include/linux/icmpv6.h:28 [inline]
 icmpv6_send include/linux/icmpv6.h:49 [inline]
 ip6_link_failure+0x37/0x4a0 net/ipv6/route.c:2794
 dst_link_failure include/net/dst.h:422 [inline]
 ndisc_error_report+0x112/0x160 net/ipv6/ndisc.c:715
 neigh_invalidate+0x240/0x460 net/core/neighbour.c:1001
 neigh_timer_handler+0x8a1/0xf90 net/core/neighbour.c:1088
 call_timer_fn+0x16d/0x560 kernel/time/timer.c:1451
 expire_timers kernel/time/timer.c:1496 [inline]
 __run_timers+0x67c/0x890 kernel/time/timer.c:1767
 run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1780
 handle_softirqs+0x3a7/0x930 kernel/softirq.c:558
 __do_softirq kernel/softirq.c:592 [inline]
 invoke_softirq kernel/softirq.c:432 [inline]
 __irq_exit_rcu+0x157/0x240 kernel/softirq.c:641
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:653
 sysvec_apic_timer_interrupt+0x91/0xb0 arch/x86/kernel/apic/apic.c:1096
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:638

The buggy address belongs to the object at ffff888024544000
 which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 8 bytes inside of
 1024-byte region [ffff888024544000, ffff888024544400)
The buggy address belongs to the page:
page:ffffea0000915000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x24540
head:ffffea0000915000 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888017041dc0
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2a20(GFP_ATOMIC|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3570, ts 58289178159, free_ts 58078190903
 prep_new_page mm/page_alloc.c:2426 [inline]
 get_page_from_freelist+0x322a/0x33c0 mm/page_alloc.c:4159
 __alloc_pages+0x272/0x700 mm/page_alloc.c:5423
 alloc_slab_page mm/slub.c:1775 [inline]
 allocate_slab mm/slub.c:1912 [inline]
 new_slab+0xbb/0x4b0 mm/slub.c:1975
 ___slab_alloc+0x6f6/0xe10 mm/slub.c:3008
 __slab_alloc mm/slub.c:3095 [inline]
 slab_alloc_node mm/slub.c:3186 [inline]
 __kmalloc_node_track_caller+0x1f6/0x390 mm/slub.c:4958
 kmalloc_reserve net/core/skbuff.c:356 [inline]
 __alloc_skb+0x12c/0x590 net/core/skbuff.c:427
 alloc_skb include/linux/skbuff.h:1167 [inline]
 nlmsg_new include/net/netlink.h:953 [inline]
 inet6_rt_notify+0xdc/0x280 net/ipv6/route.c:6185
 fib6_add_rt2node net/ipv6/ip6_fib.c:1255 [inline]
 fib6_add+0x1db2/0x3c80 net/ipv6/ip6_fib.c:1484
 __ip6_ins_rt net/ipv6/route.c:1305 [inline]
 ip6_route_add+0x84/0x120 net/ipv6/route.c:3873
 addrconf_add_mroute net/ipv6/addrconf.c:2511 [inline]
 addrconf_add_dev+0x34c/0x520 net/ipv6/addrconf.c:2529
 addrconf_dev_config net/ipv6/addrconf.c:3409 [inline]
 addrconf_init_auto_addrs+0x879/0xe90 net/ipv6/addrconf.c:3496
 addrconf_notify+0xa90/0xf30 net/ipv6/addrconf.c:3665
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:391
 __dev_notify_flags+0x304/0x610
 dev_change_flags+0xe7/0x190 net/core/dev.c:8889
 do_setlink+0xc21/0x3d80 net/core/rtnetlink.c:2747
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1340 [inline]
 free_pcp_prepare mm/page_alloc.c:1391 [inline]
 free_unref_page_prepare+0xc34/0xcf0 mm/page_alloc.c:3317
 free_unref_page+0x95/0x2d0 mm/page_alloc.c:3396
 do_slab_free mm/slub.c:3487 [inline]
 ___cache_free+0xe3/0x100 mm/slub.c:3506
 qlist_free_all+0x36/0x90 mm/kasan/quarantine.c:176
 kasan_quarantine_reduce+0x162/0x180 mm/kasan/quarantine.c:283
 __kasan_slab_alloc+0x2f/0xc0 mm/kasan/common.c:444
 kasan_slab_alloc include/linux/kasan.h:254 [inline]
 slab_post_alloc_hook+0x53/0x380 mm/slab.h:519
 slab_alloc_node mm/slub.c:3220 [inline]
 slab_alloc mm/slub.c:3228 [inline]
 kmem_cache_alloc_trace+0xfb/0x290 mm/slub.c:3245
 kmalloc include/linux/slab.h:591 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 ipv6_add_addr+0x419/0xd80 net/ipv6/addrconf.c:1117
 add_addr+0x18c/0x460 net/ipv6/addrconf.c:3131
 add_v4_addrs+0x8c9/0x1180 net/ipv6/addrconf.c:3196
 addrconf_gre_config net/ipv6/addrconf.c:3470 [inline]
 addrconf_init_auto_addrs+0x204/0xe90 net/ipv6/addrconf.c:3488
 addrconf_notify+0xa90/0xf30 net/ipv6/addrconf.c:3665
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:391
 __dev_notify_flags+0x304/0x610
 dev_change_flags+0xe7/0x190 net/core/dev.c:8889

Memory state around the buggy address:
 ffff888024543f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888024543f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888024544000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                      ^
 ffff888024544080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888024544100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/09/19 22:43 linux-5.15.y 3a5928702e71 6f888b75 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Write in l2tp_session_delete
* Struck through repros no longer work on HEAD.