[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACT4Y+ZFNG+aRsVVdEOg-ZiFQf6WzvDVwLnQj_aJzMv3-z5ZEQ@mail.gmail.com>
Date: Sat, 4 Mar 2017 17:24:13 +0100
From: Dmitry Vyukov <dvyukov@...gle.com>
To: Paolo Bonzini <pbonzini@...hat.com>,
Radim Krčmář <rkrcmar@...hat.com>,
KVM list <kvm@...r.kernel.org>,
LKML <linux-kernel@...r.kernel.org>,
Steve Rutherford <srutherford@...gle.com>,
James Mattson <jmattson@...gle.com>,
Xiao Guangrong <guangrong.xiao@...ux.intel.com>,
Haozhong Zhang <haozhong.zhang@...el.com>,
Wanpeng Li <kernellwp@...il.com>
Cc: syzkaller <syzkaller@...glegroups.com>
Subject: Re: kvm: use-after-free in irq_bypass_register_consumer
On Fri, Jan 27, 2017 at 10:26 PM, Dmitry Vyukov <dvyukov@...gle.com> wrote:
> Hello,
>
> The following program triggers use-after-free in irq_bypass_register_consumer:
> https://bit.googleplex.com/raw/5875575541465088/5629499534213120/
>
> BUG: KASAN: use-after-free in irq_bypass_register_consumer+0x48c/0x4c0
> virt/lib/irqbypass.c:198 at addr ffff88006b74b438
> Read of size 8 by task a.out/24723
> CPU: 1 PID: 24723 Comm: a.out Not tainted 4.10.0-rc5+ #201
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
> Call Trace:
> __dump_stack lib/dump_stack.c:15 [inline]
> dump_stack+0x2ee/0x3ef lib/dump_stack.c:51
> kasan_object_err+0x1c/0x70 mm/kasan/report.c:165
> print_address_description mm/kasan/report.c:203 [inline]
> kasan_report_error+0x17b/0x430 mm/kasan/report.c:287
> kasan_report mm/kasan/report.c:307 [inline]
> __asan_report_load8_noabort+0x3e/0x40 mm/kasan/report.c:328
> irq_bypass_register_consumer+0x48c/0x4c0 virt/lib/irqbypass.c:198
> kvm_irqfd_assign arch/x86/kvm/../../../virt/kvm/eventfd.c:417 [inline]
> kvm_irqfd+0x130e/0x1e30 arch/x86/kvm/../../../virt/kvm/eventfd.c:578
> kvm_vm_ioctl+0x107a/0x1d10 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3007
> vfs_ioctl fs/ioctl.c:43 [inline]
> do_vfs_ioctl+0x1bf/0x1790 fs/ioctl.c:683
> SYSC_ioctl fs/ioctl.c:698 [inline]
> SyS_ioctl+0x8f/0xc0 fs/ioctl.c:689
> entry_SYSCALL_64_fastpath+0x1f/0xc2
> RIP: 0033:0x4402b9
> RSP: 002b:00007f7f07514d98 EFLAGS: 00000297 ORIG_RAX: 0000000000000010
> RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00000000004402b9
> RDX: 0000000020ae3000 RSI: 000000004020ae76 RDI: 0000000000000007
> RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000297 R12: 0000000000000000
> R13: 0000000000000000 R14: 00007f7f075159c0 R15: 00007f7f07515700
> Object at ffff88006b74b2c0, in cache kmalloc-512 size: 512
> Allocated:
> PID = 24723
> [<ffffffff812b1506>] save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
> [<ffffffff81a0cdd3>] save_stack+0x43/0xd0 mm/kasan/kasan.c:502
> [<ffffffff81a0d09a>] set_track mm/kasan/kasan.c:514 [inline]
> [<ffffffff81a0d09a>] kasan_kmalloc+0xaa/0xd0 mm/kasan/kasan.c:605
> [<ffffffff81a098eb>] kmem_cache_alloc_trace+0x10b/0x670 mm/slab.c:3629
> [<ffffffff8108b95f>] kmalloc include/linux/slab.h:490 [inline]
> [<ffffffff8108b95f>] kzalloc include/linux/slab.h:636 [inline]
> [<ffffffff8108b95f>] kvm_irqfd_assign
> arch/x86/kvm/../../../virt/kvm/eventfd.c:296 [inline]
> [<ffffffff8108b95f>] kvm_irqfd+0x16f/0x1e30
> arch/x86/kvm/../../../virt/kvm/eventfd.c:578
> [<ffffffff81081b4a>] kvm_vm_ioctl+0x107a/0x1d10
> arch/x86/kvm/../../../virt/kvm/kvm_main.c:3007
> [<ffffffff81aa41cf>] vfs_ioctl fs/ioctl.c:43 [inline]
> [<ffffffff81aa41cf>] do_vfs_ioctl+0x1bf/0x1790 fs/ioctl.c:683
> [<ffffffff81aa582f>] SYSC_ioctl fs/ioctl.c:698 [inline]
> [<ffffffff81aa582f>] SyS_ioctl+0x8f/0xc0 fs/ioctl.c:689
> [<ffffffff841c9c81>] entry_SYSCALL_64_fastpath+0x1f/0xc2
> Freed:
> PID = 1556
> [<ffffffff812b1506>] save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:57
> [<ffffffff81a0cdd3>] save_stack+0x43/0xd0 mm/kasan/kasan.c:502
> [<ffffffff81a0d70f>] set_track mm/kasan/kasan.c:514 [inline]
> [<ffffffff81a0d70f>] kasan_slab_free+0x6f/0xb0 mm/kasan/kasan.c:578
> [<ffffffff81a0b5c3>] __cache_free mm/slab.c:3505 [inline]
> [<ffffffff81a0b5c3>] kfree+0xd3/0x250 mm/slab.c:3822
> [<ffffffff8108b4f0>] irqfd_shutdown+0x150/0x1c0
> arch/x86/kvm/../../../virt/kvm/eventfd.c:148
> [<ffffffff814b4920>] process_one_work+0xbd0/0x1c10 kernel/workqueue.c:2098
> [<ffffffff814b5b83>] worker_thread+0x223/0x1990 kernel/workqueue.c:2232
> [<ffffffff814ce546>] kthread+0x326/0x3f0 kernel/kthread.c:227
> [<ffffffff841c9ef1>] ret_from_fork+0x31/0x40 arch/x86/entry/entry_64.S:430
>
> On commit fd694aaa46c7ed811b72eb47d5eb11ce7ab3f7f1.
Still happens on commit 0710f3ff91ecc4a715db6e4d0690472b13c4dac6:
BUG: KASAN: use-after-free in irq_bypass_register_consumer+0x4cb/0x4e0
virt/lib/irqbypass.c:198 at addr ffff88006777ddf8
Read of size 8 by task a.out/15766
CPU: 2 PID: 15766 Comm: a.out Not tainted 4.10.0+ #285
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:16 [inline]
dump_stack+0x2fb/0x3fd lib/dump_stack.c:52
kasan_object_err+0x1c/0x70 mm/kasan/report.c:166
print_address_description mm/kasan/report.c:204 [inline]
kasan_report_error mm/kasan/report.c:288 [inline]
kasan_report.part.2+0x1b0/0x460 mm/kasan/report.c:310
kasan_report mm/kasan/report.c:331 [inline]
__asan_report_load8_noabort+0x29/0x30 mm/kasan/report.c:331
irq_bypass_register_consumer+0x4cb/0x4e0 virt/lib/irqbypass.c:198
kvm_irqfd_assign arch/x86/kvm/../../../virt/kvm/eventfd.c:417 [inline]
kvm_irqfd+0x137d/0x1e20 arch/x86/kvm/../../../virt/kvm/eventfd.c:578
kvm_vm_ioctl+0x108c/0x1d70 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3011
vfs_ioctl fs/ioctl.c:45 [inline]
do_vfs_ioctl+0x1bf/0x1790 fs/ioctl.c:685
SYSC_ioctl fs/ioctl.c:700 [inline]
SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691
entry_SYSCALL_64_fastpath+0x1f/0xc2
RIP: 0033:0x4402b9
RSP: 002b:00007fb73c4f9d98 EFLAGS: 00000297 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00000000004402b9
RDX: 0000000020ae3000 RSI: 000000004020ae76 RDI: 0000000000000008
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000297 R12: 0000000000000000
R13: 0000000000000000 R14: 00007fb73c4fa9c0 R15: 00007fb73c4fa700
Object at ffff88006777dc80, in cache kmalloc-512 size: 512
Allocated:
PID = 15766
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
save_stack+0x43/0xd0 mm/kasan/kasan.c:513
set_track mm/kasan/kasan.c:525 [inline]
kasan_kmalloc+0xaa/0xd0 mm/kasan/kasan.c:616
kmem_cache_alloc_trace+0x10b/0x6e0 mm/slab.c:3638
kmalloc include/linux/slab.h:490 [inline]
kzalloc include/linux/slab.h:663 [inline]
kvm_irqfd_assign arch/x86/kvm/../../../virt/kvm/eventfd.c:296 [inline]
kvm_irqfd+0x16f/0x1e20 arch/x86/kvm/../../../virt/kvm/eventfd.c:578
kvm_vm_ioctl+0x108c/0x1d70 arch/x86/kvm/../../../virt/kvm/kvm_main.c:3011
vfs_ioctl fs/ioctl.c:45 [inline]
do_vfs_ioctl+0x1bf/0x1790 fs/ioctl.c:685
SYSC_ioctl fs/ioctl.c:700 [inline]
SyS_ioctl+0x8f/0xc0 fs/ioctl.c:691
entry_SYSCALL_64_fastpath+0x1f/0xc2
Freed:
PID = 670
save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
save_stack+0x43/0xd0 mm/kasan/kasan.c:513
set_track mm/kasan/kasan.c:525 [inline]
kasan_slab_free+0x6f/0xb0 mm/kasan/kasan.c:589
__cache_free mm/slab.c:3514 [inline]
kfree+0xd3/0x250 mm/slab.c:3831
irqfd_shutdown+0x150/0x1c0 arch/x86/kvm/../../../virt/kvm/eventfd.c:148
process_one_work+0xc06/0x1c40 kernel/workqueue.c:2096
worker_thread+0x223/0x19f0 kernel/workqueue.c:2230
kthread+0x334/0x400 kernel/kthread.c:229
ret_from_fork+0x31/0x40 arch/x86/entry/entry_64.S:430
Memory state around the buggy address:
ffff88006777dc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88006777dd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88006777dd80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88006777de00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88006777de80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
Here is correct link for reproducer program:
https://gist.githubusercontent.com/dvyukov/34114444518fa22baff19ae204cc46a6/raw/7826cbcd1cbc472dfa4972fe56371df3c94b70c7/gistfile1.txt
Powered by blists - more mailing lists