[v6.1] KASAN: stack-out-of-bounds Read in profile_pc

14 views
Skip to first unread message

syzbot

unread,
May 14, 2023, 9:52:56 PM5/14/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: bf4ad6fa4e53 Linux 6.1.28
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=129dd04a280000
kernel config: https://syzkaller.appspot.com/x/.config?x=26fca33e75c97e43
dashboard link: https://syzkaller.appspot.com/bug?extid=7360dca9d8571a365f7e
compiler: Debian clang version 15.0.7, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15b268fc280000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15be0b01280000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/058ee41df9de/disk-bf4ad6fa.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/480706160d27/vmlinux-bf4ad6fa.xz
kernel image: https://storage.googleapis.com/syzbot-assets/e6a9f4f20a23/bzImage-bf4ad6fa.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+7360dc...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: stack-out-of-bounds in profile_pc+0xa4/0xe0 arch/x86/kernel/time.c:42
Read of size 8 at addr ffffc9000397f2a0 by task syz-executor575/3543

CPU: 0 PID: 3543 Comm: syz-executor575 Not tainted 6.1.28-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
print_address_description mm/kasan/report.c:284 [inline]
print_report+0x15f/0x4f0 mm/kasan/report.c:395
kasan_report+0x136/0x160 mm/kasan/report.c:495
profile_pc+0xa4/0xe0 arch/x86/kernel/time.c:42
profile_tick+0xee/0x170 kernel/profile.c:339
tick_sched_handle kernel/time/tick-sched.c:244 [inline]
tick_sched_timer+0x390/0x550 kernel/time/tick-sched.c:1490
__run_hrtimer kernel/time/hrtimer.c:1685 [inline]
__hrtimer_run_queues+0x5a7/0xe50 kernel/time/hrtimer.c:1749
hrtimer_interrupt+0x392/0x980 kernel/time/hrtimer.c:1811
local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1095 [inline]
__sysvec_apic_timer_interrupt+0x156/0x580 arch/x86/kernel/apic/apic.c:1112
sysvec_apic_timer_interrupt+0x8c/0xb0 arch/x86/kernel/apic/apic.c:1106
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:649
RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:152 [inline]
RIP: 0010:_raw_spin_unlock_irqrestore+0xd4/0x130 kernel/locking/spinlock.c:194
Code: 9c 8f 44 24 20 42 80 3c 23 00 74 08 4c 89 f7 e8 a2 89 54 f7 f6 44 24 21 02 75 4e 41 f7 c7 00 02 00 00 74 01 fb bf 01 00 00 00 <e8> 67 68 d2 f6 65 8b 05 18 e4 76 75 85 c0 74 3f 48 c7 04 24 0e 36
RSP: 0018:ffffc9000397f2a0 EFLAGS: 00000206
RAX: 7293405346c0d800 RBX: 1ffff9200072fe58 RCX: ffffffff816a3aca
RDX: dffffc0000000000 RSI: ffffffff8aebd020 RDI: 0000000000000001
RBP: ffffc9000397f330 R08: dffffc0000000000 R09: fffffbfff205065e
R10: 0000000000000000 R11: dffffc0000000001 R12: dffffc0000000000
R13: 1ffff9200072fe54 R14: ffffc9000397f2c0 R15: 0000000000000246
spin_unlock_irqrestore include/linux/spinlock.h:405 [inline]
rmqueue_pcplist mm/page_alloc.c:3805 [inline]
rmqueue mm/page_alloc.c:3847 [inline]
get_page_from_freelist+0x8db/0x3480 mm/page_alloc.c:4289
__alloc_pages+0x28d/0x770 mm/page_alloc.c:5559
__get_free_pages+0x8/0x30 mm/page_alloc.c:5609
kasan_populate_vmalloc_pte+0x35/0xf0 mm/kasan/shadow.c:271
apply_to_pte_range mm/memory.c:2635 [inline]
apply_to_pmd_range mm/memory.c:2679 [inline]
apply_to_pud_range mm/memory.c:2715 [inline]
apply_to_p4d_range mm/memory.c:2751 [inline]
__apply_to_page_range+0x9c5/0xcc0 mm/memory.c:2785
alloc_vmap_area+0x1977/0x1ac0 mm/vmalloc.c:1646
__get_vm_area_node+0x16c/0x360 mm/vmalloc.c:2505
__vmalloc_node_range+0x394/0x1460 mm/vmalloc.c:3179
__vmalloc_node mm/vmalloc.c:3284 [inline]
vzalloc+0x75/0x80 mm/vmalloc.c:3357
profile_init+0xfa/0x160 kernel/profile.c:131
profiling_store+0x5a/0xc0 kernel/ksysfs.c:79
kernfs_fop_write_iter+0x3a2/0x4f0 fs/kernfs/file.c:330
call_write_iter include/linux/fs.h:2205 [inline]
new_sync_write fs/read_write.c:491 [inline]
vfs_write+0x7ae/0xba0 fs/read_write.c:584
ksys_write+0x19c/0x2c0 fs/read_write.c:637
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f1511810289
Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe71c5f188 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f1511810289
RDX: 0000000000000012 RSI: 0000000020000040 RDI: 0000000000000003
RBP: 00007f15117d3fe0 R08: 0000000000000012 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f15117d4070
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
</TASK>

The buggy address belongs to stack of task syz-executor575/3543
and is located at offset 0 in frame:
_raw_spin_unlock_irqrestore+0x0/0x130 kernel/locking/spinlock.c:187

This frame has 1 object:
[32, 40) 'flags.i.i.i.i'

The buggy address belongs to the virtual mapping at
[ffffc90003978000, ffffc90003981000) created by:
copy_process+0x637/0x4020 kernel/fork.c:2090

The buggy address belongs to the physical page:
page:ffffea00007c3600 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1f0d8
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 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 0x2dc2(GFP_KERNEL|__GFP_HIGHMEM|__GFP_NOWARN|__GFP_ZERO), pid 3431, tgid 3431 (dhcpcd-run-hook), ts 50509167761, free_ts 50507695003
set_page_owner include/linux/page_owner.h:31 [inline]
post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2533
prep_new_page mm/page_alloc.c:2540 [inline]
get_page_from_freelist+0x32ed/0x3480 mm/page_alloc.c:4292
__alloc_pages+0x28d/0x770 mm/page_alloc.c:5559
vm_area_alloc_pages mm/vmalloc.c:2979 [inline]
__vmalloc_area_node mm/vmalloc.c:3047 [inline]
__vmalloc_node_range+0x96c/0x1460 mm/vmalloc.c:3219
alloc_thread_stack_node kernel/fork.c:311 [inline]
dup_task_struct+0x3e5/0x6d0 kernel/fork.c:980
copy_process+0x637/0x4020 kernel/fork.c:2090
kernel_clone+0x222/0x920 kernel/fork.c:2679
__do_sys_clone kernel/fork.c:2820 [inline]
__se_sys_clone kernel/fork.c:2804 [inline]
__x64_sys_clone+0x231/0x280 kernel/fork.c:2804
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
page last free stack trace:
reset_page_owner include/linux/page_owner.h:24 [inline]
free_pages_prepare mm/page_alloc.c:1460 [inline]
free_pcp_prepare mm/page_alloc.c:1510 [inline]
free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3388
free_unref_page_list+0x107/0x810 mm/page_alloc.c:3530
release_pages+0x2836/0x2b40 mm/swap.c:1055
tlb_batch_pages_flush mm/mmu_gather.c:59 [inline]
tlb_flush_mmu_free mm/mmu_gather.c:254 [inline]
tlb_flush_mmu+0xfc/0x210 mm/mmu_gather.c:261
tlb_finish_mmu+0xce/0x1f0 mm/mmu_gather.c:361
exit_mmap+0x3c3/0x9f0 mm/mmap.c:3139
__mmput+0x115/0x3c0 kernel/fork.c:1191
exit_mm+0x226/0x300 kernel/exit.c:563
do_exit+0x67e/0x2300 kernel/exit.c:856
do_group_exit+0x202/0x2b0 kernel/exit.c:1019
__do_sys_exit_group kernel/exit.c:1030 [inline]
__se_sys_exit_group kernel/exit.c:1028 [inline]
__x64_sys_exit_group+0x3b/0x40 kernel/exit.c:1028
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd

Memory state around the buggy address:
ffffc9000397f180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffc9000397f200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffffc9000397f280: 00 00 00 00 f1 f1 f1 f1 00 f3 f3 f3 00 00 00 00
^
ffffc9000397f300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffffc9000397f380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
==================================================================
----------------
Code disassembly (best guess):
0: 9c pushfq
1: 8f 44 24 20 popq 0x20(%rsp)
5: 42 80 3c 23 00 cmpb $0x0,(%rbx,%r12,1)
a: 74 08 je 0x14
c: 4c 89 f7 mov %r14,%rdi
f: e8 a2 89 54 f7 callq 0xf75489b6
14: f6 44 24 21 02 testb $0x2,0x21(%rsp)
19: 75 4e jne 0x69
1b: 41 f7 c7 00 02 00 00 test $0x200,%r15d
22: 74 01 je 0x25
24: fb sti
25: bf 01 00 00 00 mov $0x1,%edi
* 2a: e8 67 68 d2 f6 callq 0xf6d26896 <-- trapping instruction
2f: 65 8b 05 18 e4 76 75 mov %gs:0x7576e418(%rip),%eax # 0x7576e44e
36: 85 c0 test %eax,%eax
38: 74 3f je 0x79
3a: 48 rex.W
3b: c7 .byte 0xc7
3c: 04 24 add $0x24,%al
3e: 0e (bad)
3f: 36 ss


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the bug is already fixed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to change bug's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the bug is a duplicate of another bug, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages