syzbot


KASAN: invalid-free in bitmap_free

Status: fixed on 2022/03/05 17:38
Reported-by: syzbot+8253174b8b14d780789f@syzkaller.appspotmail.com
Fix commit: 7da349f07e45 net/packet: rx_owner_map depends on pg_vec
First crash: 1077d, last: 1077d
Cause bisection: failed (error log, bisect log)
  
Fix bisection: fixed by (bisect log) :
commit 7da349f07e457cad135df0920a3f670e423fb5e9
Author: Willem de Bruijn <willemb@google.com>
Date: Wed Dec 15 14:39:37 2021 +0000

  net/packet: rx_owner_map depends on pg_vec

  

Sample crash report:
==================================================================
BUG: KASAN: double-free or invalid-free in slab_free mm/slub.c:3204 [inline]
BUG: KASAN: double-free or invalid-free in kfree+0xd5/0x320 mm/slub.c:4192

CPU: 1 PID: 8660 Comm: syz-executor502 Not tainted 5.10.84-syzkaller-00439-ge2aed161fc26 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x8d/0x3d0 mm/kasan/report.c:233
 kasan_report_invalid_free+0x58/0x130 mm/kasan/report.c:358
 ____kasan_slab_free+0x14b/0x170 mm/kasan/common.c:362
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:1596 [inline]
 slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1622
 slab_free mm/slub.c:3204 [inline]
 kfree+0xd5/0x320 mm/slub.c:4192
 bitmap_free+0x15/0x20 lib/bitmap.c:1261
 packet_set_ring+0x17f1/0x25c0 net/packet/af_packet.c:4464
 packet_setsockopt+0x12f2/0x49d0 net/packet/af_packet.c:3750
 __sys_setsockopt+0x4e1/0x870 net/socket.c:2122
 __do_sys_setsockopt net/socket.c:2133 [inline]
 __se_sys_setsockopt net/socket.c:2130 [inline]
 __x64_sys_setsockopt+0xbf/0xd0 net/socket.c:2130
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7f4b276cba19
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 11 15 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:00007f4b2765c318 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
RAX: ffffffffffffffda RBX: 00007f4b277533f8 RCX: 00007f4b276cba19
RDX: 0000000000000005 RSI: 0000000000000107 RDI: 0000000000000003
RBP: 00007f4b277533f0 R08: 000000000000001c R09: 0000000000000000
R10: 00000000200000c0 R11: 0000000000000246 R12: 00007f4b27721074
R13: 00007fff8b9af4af R14: 00007f4b2765c400 R15: 0000000000022000

Allocated by task 8658:
 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:428 [inline]
 ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:507
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516
 kasan_kmalloc include/linux/kasan.h:269 [inline]
 __kmalloc+0x22a/0x3d0 mm/slub.c:4034
 kmalloc_array include/linux/slab.h:592 [inline]
 kcalloc include/linux/slab.h:603 [inline]
 alloc_pg_vec net/packet/af_packet.c:4286 [inline]
 packet_set_ring+0x6b9/0x25c0 net/packet/af_packet.c:4376
 packet_setsockopt+0x12f2/0x49d0 net/packet/af_packet.c:3750
 __sys_setsockopt+0x4e1/0x870 net/socket.c:2122
 __do_sys_setsockopt net/socket.c:2133 [inline]
 __se_sys_setsockopt net/socket.c:2130 [inline]
 __x64_sys_setsockopt+0xbf/0xd0 net/socket.c:2130
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 8658:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:46
 kasan_set_free_info+0x23/0x40 mm/kasan/generic.c:357
 ____kasan_slab_free+0x133/0x170 mm/kasan/common.c:360
 __kasan_slab_free+0x11/0x20 mm/kasan/common.c:368
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:1596 [inline]
 slab_free_freelist_hook+0xcc/0x1a0 mm/slub.c:1622
 slab_free mm/slub.c:3204 [inline]
 kfree+0xd5/0x320 mm/slub.c:4192
 free_pg_vec net/packet/af_packet.c:4252 [inline]
 packet_set_ring+0x191b/0x25c0 net/packet/af_packet.c:4466
 packet_setsockopt+0x12f2/0x49d0 net/packet/af_packet.c:3750
 __sys_setsockopt+0x4e1/0x870 net/socket.c:2122
 __do_sys_setsockopt net/socket.c:2133 [inline]
 __se_sys_setsockopt net/socket.c:2130 [inline]
 __x64_sys_setsockopt+0xbf/0xd0 net/socket.c:2130
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff88811a62de80
 which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes inside of
 64-byte region [ffff88811a62de80, ffff88811a62dec0)
The buggy address belongs to the page:
page:ffffea0004698b40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x11a62d
flags: 0x8000000000000200(slab)
raw: 8000000000000200 dead000000000100 dead000000000122 ffff888100043800
raw: 0000000000000000 0000000080200020 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 8619, ts 39135398155, free_ts 39131305737
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2385 [inline]
 prep_new_page mm/page_alloc.c:2391 [inline]
 get_page_from_freelist+0xa74/0xa90 mm/page_alloc.c:4063
 __alloc_pages_nodemask+0x3c8/0x820 mm/page_alloc.c:5106
 alloc_slab_page mm/slub.c:1807 [inline]
 allocate_slab+0x6b/0x350 mm/slub.c:1809
 new_slab mm/slub.c:1870 [inline]
 new_slab_objects mm/slub.c:2629 [inline]
 ___slab_alloc+0x143/0x2f0 mm/slub.c:2792
 __slab_alloc mm/slub.c:2832 [inline]
 slab_alloc_node mm/slub.c:2914 [inline]
 slab_alloc mm/slub.c:2956 [inline]
 __kmalloc+0x2af/0x3d0 mm/slub.c:4030
 __kmalloc_node include/linux/slab.h:418 [inline]
 kmalloc_node include/linux/slab.h:575 [inline]
 __vmalloc_area_node mm/vmalloc.c:2483 [inline]
 __vmalloc_node_range+0x28d/0x750 mm/vmalloc.c:2565
 alloc_thread_stack_node kernel/fork.c:250 [inline]
 dup_task_struct+0x6e6/0xde0 kernel/fork.c:899
 copy_process+0x665/0x5340 kernel/fork.c:1989
 kernel_clone+0x21f/0x9a0 kernel/fork.c:2510
 __do_sys_clone kernel/fork.c:2629 [inline]
 __se_sys_clone kernel/fork.c:2613 [inline]
 __x64_sys_clone+0x258/0x2d0 kernel/fork.c:2613
 do_syscall_64+0x31/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1331 [inline]
 free_pcp_prepare+0x18f/0x1c0 mm/page_alloc.c:1405
 free_unref_page_prepare mm/page_alloc.c:3291 [inline]
 free_unref_page mm/page_alloc.c:3341 [inline]
 free_the_page mm/page_alloc.c:5165 [inline]
 __free_pages+0x2e3/0x4a0 mm/page_alloc.c:5173
 __vunmap+0x856/0x980 mm/vmalloc.c:2275
 free_work+0x66/0x90 mm/vmalloc.c:68
 process_one_work+0x6b4/0xfb0 kernel/workqueue.c:2289
 worker_thread+0xb15/0x1600 kernel/workqueue.c:2435
 kthread+0x371/0x390 kernel/kthread.c:313
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:296

Memory state around the buggy address:
 ffff88811a62dd80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88811a62de00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff88811a62de80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
                   ^
 ffff88811a62df00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88811a62df80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/12/12 11:34 android12-5.10-lts e2aed161fc26 49ca1f59 .config console log report syz C ci2-android-5-10 KASAN: invalid-free in bitmap_free
* Struck through repros no longer work on HEAD.