syzbot


KASAN: use-after-free Read in mptcp_pm_nl_rm_addr_or_subflow

Status: upstream: reported on 2024/09/26 03:12
Reported-by: syzbot+5dc118a14eb58c6036d0@syzkaller.appspotmail.com
First crash: 78d, last: 63d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-use-after-free Read in mptcp_pm_nl_rm_addr_or_subflow mptcp 1 60d 59d 28/28 fixed on 2024/11/12 23:31

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in mptcp_pm_nl_rm_addr_or_subflow+0x6b8/0xcf0 net/mptcp/pm_netlink.c:792
Read of size 4 at addr ffff888063835050 by task syz.3.81/4112

CPU: 0 PID: 4112 Comm: syz.3.81 Not tainted 5.15.167-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
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
 mptcp_pm_nl_rm_addr_or_subflow+0x6b8/0xcf0 net/mptcp/pm_netlink.c:792
 mptcp_pm_nl_rm_subflow_received net/mptcp/pm_netlink.c:823 [inline]
 mptcp_nl_remove_id_zero_address net/mptcp/pm_netlink.c:1453 [inline]
 mptcp_nl_cmd_del_addr+0x85a/0x17e0 net/mptcp/pm_netlink.c:1483
 genl_family_rcv_msg_doit net/netlink/genetlink.c:731 [inline]
 genl_family_rcv_msg net/netlink/genetlink.c:775 [inline]
 genl_rcv_msg+0xfbd/0x14a0 net/netlink/genetlink.c:792
 netlink_rcv_skb+0x1cf/0x410 net/netlink/af_netlink.c:2503
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:803
 netlink_unicast_kernel net/netlink/af_netlink.c:1326 [inline]
 netlink_unicast+0x7b6/0x980 net/netlink/af_netlink.c:1352
 netlink_sendmsg+0xa30/0xd60 net/netlink/af_netlink.c:1920
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2431
 ___sys_sendmsg+0x252/0x2e0 net/socket.c:2485
 __sys_sendmsg net/socket.c:2514 [inline]
 __do_sys_sendmsg net/socket.c:2523 [inline]
 __se_sys_sendmsg+0x19a/0x260 net/socket.c:2521
 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
RIP: 0033:0x7f2d9be03ff9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f2d9a27c038 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f2d9bfbbf80 RCX: 00007f2d9be03ff9
RDX: 0000000000000000 RSI: 0000000020000140 RDI: 0000000000000005
RBP: 00007f2d9be76296 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f2d9bfbbf80 R15: 00007ffd9b9e1e58
 </TASK>

Allocated by task 4112:
 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]
 kmem_cache_alloc_trace+0x143/0x290 mm/slub.c:3247
 kmalloc include/linux/slab.h:591 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 subflow_create_ctx net/mptcp/subflow.c:1607 [inline]
 subflow_ulp_init+0x8f/0x470 net/mptcp/subflow.c:1690
 __tcp_set_ulp net/ipv4/tcp_ulp.c:143 [inline]
 tcp_set_ulp+0x498/0x550 net/ipv4/tcp_ulp.c:164
 mptcp_subflow_create_socket+0x64f/0xc10 net/mptcp/subflow.c:1572
 __mptcp_socket_create net/mptcp/protocol.c:108 [inline]
 mptcp_init_sock+0x114/0x790 net/mptcp/protocol.c:2579
 inet_create+0xa35/0xd40 net/ipv4/af_inet.c:383
 __sock_create+0x460/0x8d0 net/socket.c:1486
 sock_create net/socket.c:1537 [inline]
 __sys_socket+0x132/0x370 net/socket.c:1579
 __do_sys_socket net/socket.c:1588 [inline]
 __se_sys_socket net/socket.c:1586 [inline]
 __x64_sys_socket+0x76/0x80 net/socket.c:1586
 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 21:
 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]
 kmem_cache_free_bulk+0x28f/0x4c0 mm/slub.c:3640
 kfree_bulk include/linux/slab.h:448 [inline]
 kfree_rcu_work+0x332/0x7a0 kernel/rcu/tree.c:3295
 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

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
 tcp_cleanup_ulp+0x6d/0xe0 net/ipv4/tcp_ulp.c:124
 tcp_v4_destroy_sock+0x184/0x700 net/ipv4/tcp_ipv4.c:2297
 inet_csk_destroy_sock+0x153/0x370 net/ipv4/inet_connection_sock.c:1040
 __tcp_close+0x890/0xec0 net/ipv4/tcp.c:2881
 __mptcp_close_ssk+0x1ff/0x470 net/mptcp/protocol.c:2314
 mptcp_pm_nl_rm_addr_or_subflow+0x4b4/0xcf0 net/mptcp/pm_netlink.c:789
 mptcp_pm_nl_rm_subflow_received net/mptcp/pm_netlink.c:823 [inline]
 mptcp_nl_remove_id_zero_address net/mptcp/pm_netlink.c:1453 [inline]
 mptcp_nl_cmd_del_addr+0x85a/0x17e0 net/mptcp/pm_netlink.c:1483
 genl_family_rcv_msg_doit net/netlink/genetlink.c:731 [inline]
 genl_family_rcv_msg net/netlink/genetlink.c:775 [inline]
 genl_rcv_msg+0xfbd/0x14a0 net/netlink/genetlink.c:792
 netlink_rcv_skb+0x1cf/0x410 net/netlink/af_netlink.c:2503
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:803
 netlink_unicast_kernel net/netlink/af_netlink.c:1326 [inline]
 netlink_unicast+0x7b6/0x980 net/netlink/af_netlink.c:1352
 netlink_sendmsg+0xa30/0xd60 net/netlink/af_netlink.c:1920
 sock_sendmsg_nosec net/socket.c:704 [inline]
 __sock_sendmsg net/socket.c:716 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2431
 ___sys_sendmsg+0x252/0x2e0 net/socket.c:2485
 __sys_sendmsg net/socket.c:2514 [inline]
 __do_sys_sendmsg net/socket.c:2523 [inline]
 __se_sys_sendmsg+0x19a/0x260 net/socket.c:2521
 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

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
 drop_sysctl_table+0x317/0x460 fs/proc/proc_sysctl.c:1678
 drop_sysctl_table+0x329/0x460 fs/proc/proc_sysctl.c:1681
 unregister_sysctl_table+0x88/0x130 fs/proc/proc_sysctl.c:1716
 mpls_dev_sysctl_unregister+0x86/0xc0 net/mpls/af_mpls.c:1445
 mpls_dev_notify+0x54b/0x780 net/mpls/af_mpls.c:1663
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:391
 call_netdevice_notifiers_info net/core/dev.c:2018 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2030 [inline]
 call_netdevice_notifiers net/core/dev.c:2044 [inline]
 unregister_netdevice_many+0xf1b/0x18f0 net/core/dev.c:11094
 ip6gre_exit_batch_net+0x415/0x460 net/ipv6/ip6_gre.c:1650
 ops_exit_list net/core/net_namespace.c:177 [inline]
 cleanup_net+0x763/0xb60 net/core/net_namespace.c:599
 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

The buggy address belongs to the object at ffff888063835000
 which belongs to the cache kmalloc-256 of size 256
The buggy address is located 80 bytes inside of
 256-byte region [ffff888063835000, ffff888063835100)
The buggy address belongs to the page:
page:ffffea00018e0d00 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x63834
head:ffffea00018e0d00 order:1 compound_mapcount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 dead000000000100 dead000000000122 ffff888017041b40
raw: 0000000000000000 0000000000100010 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 1, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 3572, ts 46817469744, free_ts 11787754807
 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]
 slab_alloc mm/slub.c:3228 [inline]
 __kmalloc+0x1c9/0x300 mm/slub.c:4403
 kmalloc include/linux/slab.h:596 [inline]
 kzalloc include/linux/slab.h:721 [inline]
 new_dir fs/proc/proc_sysctl.c:952 [inline]
 get_subdir fs/proc/proc_sysctl.c:997 [inline]
 __register_sysctl_table+0x9f1/0x1220 fs/proc/proc_sysctl.c:1346
 __devinet_sysctl_register+0x1d3/0x2a0 net/ipv4/devinet.c:2590
 devinet_sysctl_register+0x13a/0x1a0 net/ipv4/devinet.c:2630
 inetdev_init+0x257/0x470 net/ipv4/devinet.c:276
 inetdev_event+0x29b/0x1490 net/ipv4/devinet.c:1530
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:391
 call_netdevice_notifiers_info net/core/dev.c:2018 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2030 [inline]
 call_netdevice_notifiers+0x145/0x1b0 net/core/dev.c:2044
 register_netdevice+0x12e8/0x1720 net/core/dev.c:10388
 register_netdev+0x37/0x50 net/core/dev.c:10481
 ip6_tnl_init_net+0x22c/0x2e0 net/ipv6/ip6_tunnel.c:2301
 ops_init+0x35d/0x610 net/core/net_namespace.c:138
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
 free_contig_range+0x95/0xf0 mm/page_alloc.c:9342
 destroy_args+0xfe/0x980 mm/debug_vm_pgtable.c:1018
 debug_vm_pgtable+0x40d/0x470 mm/debug_vm_pgtable.c:1331
 do_one_initcall+0x22b/0x7a0 init/main.c:1302
 do_initcall_level+0x157/0x210 init/main.c:1375
 do_initcalls+0x49/0x90 init/main.c:1391
 kernel_init_freeable+0x425/0x5c0 init/main.c:1615
 kernel_init+0x19/0x290 init/main.c:1506
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:287

Memory state around the buggy address:
 ffff888063834f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff888063834f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff888063835000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                 ^
 ffff888063835080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff888063835100: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/10/10 21:33 linux-5.15.y 3a5928702e71 8fbfc0c8 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in mptcp_pm_nl_rm_addr_or_subflow
2024/10/05 23:04 linux-5.15.y 3a5928702e71 d7906eff .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in mptcp_pm_nl_rm_addr_or_subflow
2024/09/29 01:11 linux-5.15.y 3a5928702e71 ba29ff75 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in mptcp_pm_nl_rm_addr_or_subflow
2024/09/26 03:11 linux-5.15.y 3a5928702e71 0d19f247 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan KASAN: use-after-free Read in mptcp_pm_nl_rm_addr_or_subflow
* Struck through repros no longer work on HEAD.