syzbot


KASAN: slab-out-of-bounds Read in __htab_map_lookup_and_delete_batch

Status: auto-obsoleted due to no activity on 2023/03/13 22:30
Reported-by: syzbot+97f13609a08fd7b595b1@syzkaller.appspotmail.com
First crash: 728d, last: 728d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: slab-out-of-bounds Read in __htab_map_lookup_and_delete_batch bpf C unreliable done 121 821d 1388d 0/28 closed as invalid on 2022/11/15 21:09

Sample crash report:
==================================================================
BUG: KASAN: slab-out-of-bounds in instrument_copy_to_user include/linux/instrumented.h:118 [inline]
BUG: KASAN: slab-out-of-bounds in _copy_to_user+0x6b/0x90 lib/usercopy.c:32
Read of size 6 at addr ffff888142dc58c0 by task syz-executor.4/21414

CPU: 0 PID: 21414 Comm: syz-executor.4 Not tainted 5.15.74-syzkaller-00001-g4ec71a9ec769 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
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/0x3d0 mm/kasan/report.c:256
 __kasan_report mm/kasan/report.c:435 [inline]
 kasan_report+0x1a6/0x1f0 mm/kasan/report.c:452
 kasan_check_range+0x2aa/0x2e0 mm/kasan/generic.c:189
 __kasan_check_read+0x11/0x20 mm/kasan/shadow.c:31
 instrument_copy_to_user include/linux/instrumented.h:118 [inline]
 _copy_to_user+0x6b/0x90 lib/usercopy.c:32
 copy_to_user include/linux/uaccess.h:200 [inline]
 __htab_map_lookup_and_delete_batch+0x1b2d/0x20f0 kernel/bpf/hashtab.c:1764
 htab_lru_percpu_map_lookup_batch+0x33/0x40 kernel/bpf/hashtab.c:1835
 bpf_map_do_batch+0x2d2/0x620 kernel/bpf/syscall.c:4198
 __sys_bpf+0x5e2/0x750
 __do_sys_bpf kernel/bpf/syscall.c:4722 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:4720 [inline]
 __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:4720
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fe3d7309109
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fe3d603a168 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007fe3d7429120 RCX: 00007fe3d7309109
RDX: 0000000000000038 RSI: 0000000020004300 RDI: 0000000000000018
RBP: 00007fe3d7364ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc187e8e8f R14: 00007fe3d603a300 R15: 0000000000022000
 </TASK>

Allocated by task 21414:
 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+0xdc/0x110 mm/kasan/common.c:512
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:521
 kasan_kmalloc include/linux/kasan.h:254 [inline]
 __kmalloc+0x203/0x350 mm/slub.c:4423
 __kmalloc_node include/linux/slab.h:457 [inline]
 kmalloc_node include/linux/slab.h:614 [inline]
 kvmalloc_node+0x82/0x130 mm/util.c:623
 kvmalloc include/linux/mm.h:844 [inline]
 kvmalloc_array include/linux/mm.h:862 [inline]
 __htab_map_lookup_and_delete_batch+0x4f2/0x20f0 kernel/bpf/hashtab.c:1643
 htab_lru_percpu_map_lookup_batch+0x33/0x40 kernel/bpf/hashtab.c:1835
 bpf_map_do_batch+0x2d2/0x620 kernel/bpf/syscall.c:4198
 __sys_bpf+0x5e2/0x750
 __do_sys_bpf kernel/bpf/syscall.c:4722 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:4720 [inline]
 __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:4720
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

The buggy address belongs to the object at ffff888142dc58c0
 which belongs to the cache kmalloc-8 of size 8
The buggy address is located 0 bytes inside of
 8-byte region [ffff888142dc58c0, ffff888142dc58c8)
The buggy address belongs to the page:
page:ffffea00050b7140 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff888142dc55a0 pfn:0x142dc5
flags: 0x4000000000000200(slab|zone=1)
raw: 4000000000000200 ffffea00044c5280 0000000900000009 ffff888100042300
raw: ffff888142dc55a0 0000000080660060 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x112cc0(GFP_USER|__GFP_NOWARN|__GFP_NORETRY), pid 17875, ts 314297497797, free_ts 314290158728
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0x1ab/0x1b0 mm/page_alloc.c:2495
 prep_new_page mm/page_alloc.c:2501 [inline]
 get_page_from_freelist+0x38b/0x400 mm/page_alloc.c:4281
 __alloc_pages+0x3a8/0x7c0 mm/page_alloc.c:5548
 allocate_slab+0x62/0x580 mm/slub.c:1928
 new_slab mm/slub.c:1991 [inline]
 ___slab_alloc+0x2e2/0x6f0 mm/slub.c:3024
 __slab_alloc+0x4a/0x90 mm/slub.c:3111
 slab_alloc_node mm/slub.c:3202 [inline]
 slab_alloc mm/slub.c:3244 [inline]
 __kmalloc_track_caller+0x25a/0x350 mm/slub.c:4941
 __do_krealloc mm/slab_common.c:1220 [inline]
 krealloc+0x5f/0xf0 mm/slab_common.c:1253
 push_jmp_history kernel/bpf/verifier.c:2094 [inline]
 is_state_visited kernel/bpf/verifier.c:10781 [inline]
 do_check+0x2a23/0xdfe0 kernel/bpf/verifier.c:10917
 do_check_common+0x8b0/0x1820 kernel/bpf/verifier.c:13183
 do_check_main kernel/bpf/verifier.c:13246 [inline]
 bpf_check+0x288a/0x12790 kernel/bpf/verifier.c:13813
 bpf_prog_load+0x12c6/0x1b60 kernel/bpf/syscall.c:2329
 __sys_bpf+0x4c2/0x750 kernel/bpf/syscall.c:4618
 __do_sys_bpf kernel/bpf/syscall.c:4722 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:4720 [inline]
 __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:4720
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 free_pages_prepare mm/page_alloc.c:1364 [inline]
 free_pcp_prepare+0x448/0x450 mm/page_alloc.c:1435
 free_unref_page_prepare mm/page_alloc.c:3433 [inline]
 free_unref_page+0x9c/0x370 mm/page_alloc.c:3513
 free_the_page mm/page_alloc.c:706 [inline]
 __free_pages+0xd8/0x100 mm/page_alloc.c:5621
 free_pages+0x7c/0x90 mm/page_alloc.c:5632
 tlb_batch_list_free mm/mmu_gather.c:61 [inline]
 tlb_finish_mmu+0x123/0x1f0 mm/mmu_gather.c:343
 exit_mmap+0x46e/0x7a0 mm/mmap.c:3199
 __mmput+0x95/0x300 kernel/fork.c:1162
 mmput+0x50/0x60 kernel/fork.c:1184
 exit_mm+0x50d/0x760 kernel/exit.c:504
 do_exit+0x63c/0x24d0 kernel/exit.c:815
 do_group_exit+0x13a/0x300 kernel/exit.c:925
 __do_sys_exit_group kernel/exit.c:936 [inline]
 __se_sys_exit_group kernel/exit.c:934 [inline]
 __x64_sys_exit_group+0x3f/0x40 kernel/exit.c:934
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x61/0xcb

Memory state around the buggy address:
 ffff888142dc5780: fa fc fc fc fc fb fc fc fc fc fa fc fc fc fc fa
 ffff888142dc5800: fc fc fc fc fa fc fc fc fc fb fc fc fc fc fa fc
>ffff888142dc5880: fc fc fc fa fc fc fc fc 05 fc fc fc fc fa fc fc
                                           ^
 ffff888142dc5900: fc fc fa fc fc fc fc fa fc fc fc fc fa fc fc fc
 ffff888142dc5980: fc fa fc fc fc fc fb fc fc fc fc fb fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/11/24 02:41 android13-5.15-lts 4ec71a9ec769 52fdf57a .config console log report info ci2-android-5-15-perf KASAN: slab-out-of-bounds Read in __htab_map_lookup_and_delete_batch
* Struck through repros no longer work on HEAD.