syzbot


KASAN: use-after-free Read in cma_netevent_callback

Status: auto-obsoleted due to no activity on 2024/04/26 15:53
Reported-by: syzbot+807001718bb4082c096d@syzkaller.appspotmail.com
First crash: 308d, last: 308d

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in compare_netdev_and_ip drivers/infiniband/core/cma.c:473 [inline]
BUG: KASAN: use-after-free in node_from_ndev_ip drivers/infiniband/core/cma.c:550 [inline]
BUG: KASAN: use-after-free in cma_netevent_callback+0x47c/0x7e4 drivers/infiniband/core/cma.c:5168
Read of size 4 at addr ffff0000d1e7f184 by task syz-executor.0/4258

CPU: 1 PID: 4258 Comm: syz-executor.0 Not tainted 6.1.73-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x174/0x4c0 mm/kasan/report.c:395
 kasan_report+0xd4/0x130 mm/kasan/report.c:495
 __asan_report_load4_noabort+0x2c/0x38 mm/kasan/report_generic.c:350
 compare_netdev_and_ip drivers/infiniband/core/cma.c:473 [inline]
 node_from_ndev_ip drivers/infiniband/core/cma.c:550 [inline]
 cma_netevent_callback+0x47c/0x7e4 drivers/infiniband/core/cma.c:5168
 notifier_call_chain kernel/notifier.c:87 [inline]
 atomic_notifier_call_chain+0x174/0x2a0 kernel/notifier.c:225
 call_netevent_notifiers+0x30/0x40 net/core/netevent.c:61
 neigh_update_notify net/core/neighbour.c:2649 [inline]
 neigh_timer_handler+0x750/0xe88 net/core/neighbour.c:1157
 call_timer_fn+0x1c0/0xa1c kernel/time/timer.c:1474
 expire_timers kernel/time/timer.c:1519 [inline]
 __run_timers+0x554/0x718 kernel/time/timer.c:1790
 run_timer_softirq+0x7c/0x114 kernel/time/timer.c:1803
 __do_softirq+0x314/0xe38 kernel/softirq.c:571
 ____do_softirq+0x14/0x20 arch/arm64/kernel/irq.c:79
 call_on_irq_stack+0x24/0x4c arch/arm64/kernel/entry.S:893
 do_softirq_own_stack+0x20/0x2c arch/arm64/kernel/irq.c:84
 invoke_softirq kernel/softirq.c:452 [inline]
 __irq_exit_rcu+0x264/0x4d4 kernel/softirq.c:650
 irq_exit_rcu+0x14/0x84 kernel/softirq.c:662
 __el1_irq arch/arm64/kernel/entry-common.c:472 [inline]
 el1_interrupt+0x38/0x68 arch/arm64/kernel/entry-common.c:486
 el1h_64_irq_handler+0x18/0x24 arch/arm64/kernel/entry-common.c:491
 el1h_64_irq+0x64/0x68 arch/arm64/kernel/entry.S:581
 arch_local_irq_restore arch/arm64/include/asm/irqflags.h:122 [inline]
 __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:151 [inline]
 _raw_spin_unlock_irqrestore+0x58/0xac kernel/locking/spinlock.c:194
 debug_object_free+0x27c/0x440 lib/debugobjects.c:889
 destroy_hrtimer_on_stack kernel/time/hrtimer.c:452 [inline]
 hrtimer_nanosleep+0x2d4/0x384 kernel/time/hrtimer.c:2112
 common_nsleep+0xa8/0xc0 kernel/time/posix-timers.c:1267
 __do_sys_clock_nanosleep kernel/time/posix-timers.c:1308 [inline]
 __se_sys_clock_nanosleep kernel/time/posix-timers.c:1285 [inline]
 __arm64_sys_clock_nanosleep+0x350/0x38c kernel/time/posix-timers.c:1285
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

Allocated by task 31831:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
 kasan_save_alloc_info+0x24/0x30 mm/kasan/generic.c:505
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:383
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 kmalloc_trace+0x7c/0x94 mm/slab_common.c:1050
 kmalloc include/linux/slab.h:553 [inline]
 kzalloc include/linux/slab.h:689 [inline]
 __rdma_create_id+0x74/0x478 drivers/infiniband/core/cma.c:972
 rdma_create_user_id+0x88/0xc8 drivers/infiniband/core/cma.c:1028
 ucma_create_id+0x2cc/0x5dc drivers/infiniband/core/ucma.c:464
 ucma_write+0x324/0x47c drivers/infiniband/core/ucma.c:1744
 vfs_write+0x2a4/0x914 fs/read_write.c:582
 ksys_write+0x15c/0x26c fs/read_write.c:637
 __do_sys_write fs/read_write.c:649 [inline]
 __se_sys_write fs/read_write.c:646 [inline]
 __arm64_sys_write+0x7c/0x90 fs/read_write.c:646
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

Freed by task 31830:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
 kasan_save_free_info+0x38/0x5c mm/kasan/generic.c:516
 ____kasan_slab_free+0x144/0x1c0 mm/kasan/common.c:236
 __kasan_slab_free+0x18/0x28 mm/kasan/common.c:244
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0x2c0/0x4b4 mm/slub.c:3674
 kfree+0xcc/0x1b8 mm/slab_common.c:1007
 _destroy_id+0xc2c/0xf08 drivers/infiniband/core/cma.c:2039
 destroy_id_handler_unlock+0xe0/0x17c drivers/infiniband/core/cma.c:2066
 rdma_destroy_id+0x2c/0x3c drivers/infiniband/core/cma.c:2075
 ucma_close_id+0xac/0x10c drivers/infiniband/core/ucma.c:187
 ucma_destroy_private_ctx+0xd0/0x940 drivers/infiniband/core/ucma.c:579
 ucma_close+0xfc/0x16c drivers/infiniband/core/ucma.c:1809
 __fput+0x30c/0x7bc fs/file_table.c:320
 ____fput+0x20/0x30 fs/file_table.c:348
 task_work_run+0x240/0x2f0 kernel/task_work.c:179
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 do_notify_resume+0x2148/0x3474 arch/arm64/kernel/signal.c:1132
 prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline]
 exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline]
 el0_svc+0x9c/0x168 arch/arm64/kernel/entry-common.c:638
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

Last potentially related work creation:
 kasan_save_stack+0x40/0x70 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xcc/0xe8 mm/kasan/generic.c:486
 kasan_record_aux_stack_noalloc+0x14/0x20 mm/kasan/generic.c:496
 call_rcu+0xfc/0xa40 kernel/rcu/tree.c:2812
 netlink_release+0x11d0/0x16e0 net/netlink/af_netlink.c:815
 __sock_release net/socket.c:654 [inline]
 sock_close+0xb8/0x1fc net/socket.c:1400
 __fput+0x30c/0x7bc fs/file_table.c:320
 ____fput+0x20/0x30 fs/file_table.c:348
 task_work_run+0x240/0x2f0 kernel/task_work.c:179
 resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
 do_notify_resume+0x2148/0x3474 arch/arm64/kernel/signal.c:1132
 prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline]
 exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline]
 el0_svc+0x9c/0x168 arch/arm64/kernel/entry-common.c:638
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

Second to last potentially related work creation:
 kasan_save_stack+0x40/0x70 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xcc/0xe8 mm/kasan/generic.c:486
 kasan_record_aux_stack_noalloc+0x14/0x20 mm/kasan/generic.c:496
 call_rcu+0xfc/0xa40 kernel/rcu/tree.c:2812
 netlink_release+0x11d0/0x16e0 net/netlink/af_netlink.c:815
 __sock_release net/socket.c:654 [inline]
 sock_close+0xb8/0x1fc net/socket.c:1400
 __fput+0x30c/0x7bc fs/file_table.c:320
 ____fput+0x20/0x30 fs/file_table.c:348
 task_work_run+0x240/0x2f0 kernel/task_work.c:179
 exit_task_work include/linux/task_work.h:38 [inline]
 do_exit+0x554/0x1a88 kernel/exit.c:869
 do_group_exit+0x194/0x22c kernel/exit.c:1019
 get_signal+0x14a0/0x158c kernel/signal.c:2862
 do_signal arch/arm64/kernel/signal.c:1076 [inline]
 do_notify_resume+0x3ac/0x3474 arch/arm64/kernel/signal.c:1129
 prepare_exit_to_user_mode arch/arm64/kernel/entry-common.c:137 [inline]
 exit_to_user_mode arch/arm64/kernel/entry-common.c:142 [inline]
 el0_svc+0x9c/0x168 arch/arm64/kernel/entry-common.c:638
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:585

The buggy address belongs to the object at ffff0000d1e7f000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 388 bytes inside of
 2048-byte region [ffff0000d1e7f000, ffff0000d1e7f800)

The buggy address belongs to the physical page:
page:000000002e085708 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x111e78
head:000000002e085708 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x5ffc00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000010200 fffffc0004833e00 dead000000000002 ffff0000c0002900
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff0000d1e7f080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff0000d1e7f100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff0000d1e7f180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff0000d1e7f200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff0000d1e7f280: 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/01/17 15:52 linux-6.1.y fec3b1451d5f c9a1c95b .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in cma_netevent_callback
* Struck through repros no longer work on HEAD.