From patchwork Tue Jan 17 16:00:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Vyukov X-Patchwork-Id: 9521441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 14665601C3 for ; Tue, 17 Jan 2017 16:01:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03D54285A8 for ; Tue, 17 Jan 2017 16:01:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB404285CD; Tue, 17 Jan 2017 16:01:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B81E285A8 for ; Tue, 17 Jan 2017 16:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751220AbdAQQAt (ORCPT ); Tue, 17 Jan 2017 11:00:49 -0500 Received: from mail-lf0-f52.google.com ([209.85.215.52]:36414 "EHLO mail-lf0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751192AbdAQQAr (ORCPT ); Tue, 17 Jan 2017 11:00:47 -0500 Received: by mail-lf0-f52.google.com with SMTP id z134so108162117lff.3 for ; Tue, 17 Jan 2017 08:00:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=WmR/WkVnldubsLVcei0R5G+RjvLqhNvxET5v7GbtLes=; b=iVwzpIFrortqvuQ8nsDjvv1GH+kKb03wlX3/OWxAjXjvDsaP6blXrpk6RXnwxqEQzy 4GkADrJA64X9060xSDHTcTi2IIdT12imsyNfHUxrYy5TrShlYt8bcrRS8t9csx1uDabM CpsdNeWwf8No4xoMU/leIKmi8Bu+yTTpOJQUTUzYKZz4KKzcPr4UkfQRpfFJqii7s7XK WzVnhj29XIF/4RaBnP8MdMP+Ka8r5z/FxP4SmfYqvYi5gbfVHjoIJfRDMvwQGqq/81KG Yu87kr3vYZeA/WNtQVGs7viGVbHMjO/7NxYrQyIzNreQQUJ3yfit7jwjwTirsUg6wi96 wIeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=WmR/WkVnldubsLVcei0R5G+RjvLqhNvxET5v7GbtLes=; b=kYh39KC/hD8/jDpnTufk+8/Q9VNkZCHxGjCs4FbAuhdqZoahZOAy/fZRtLBxCSjRMV OwjSbTWFMA6w6kJofwVDE93lywT3REuSR13csF+qeiccsLV+EUEN+doymDcYGhVTonfD 9a6+pinVNkfs7kxB89J7J0/yQyIMzGbpe2B7YyPH60aq1tGlZKEnKnBjD73KNbeHuYeH ELfxCNMZC1NfRQx7BpItbTBU6pfg0fRxEwTgHm+X6aClWMGBFvTcid7R8cIlyVFz8ogq ZDWcz8ex9HmNfn7GnOA/0ETRA/dJE0y6rVjoZTqZxmWbXWDKRZ38OqPRSde26LX2xOq5 xnAQ== X-Gm-Message-State: AIkVDXL1ArOJ1dogdoaDYApOJnVwhq0GvwWPLCkWxFSlPyOoFLieoyn8iit7HZMfogzakdOgR3Ua17Drs+r112vG X-Received: by 10.46.33.75 with SMTP id h72mr15367093ljh.37.1484668844658; Tue, 17 Jan 2017 08:00:44 -0800 (PST) MIME-Version: 1.0 Received: by 10.114.184.204 with HTTP; Tue, 17 Jan 2017 08:00:23 -0800 (PST) In-Reply-To: <3e72461c-7197-e941-1d35-1aca34df2f8e@redhat.com> References: <3e72461c-7197-e941-1d35-1aca34df2f8e@redhat.com> From: Dmitry Vyukov Date: Tue, 17 Jan 2017 17:00:23 +0100 Message-ID: Subject: Re: kvm: WARNING in mmu_spte_clear_track_bits To: Paolo Bonzini Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "x86@kernel.org" , KVM list , LKML , Alan Stern , Steve Rutherford , Xiao Guangrong , haozhong.zhang@intel.com, syzkaller Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Jan 17, 2017 at 4:20 PM, Paolo Bonzini wrote: > > > On 13/01/2017 12:15, Dmitry Vyukov wrote: >> >> I've commented out the WARNING for now, but I am seeing lots of >> use-after-free's and rcu stalls involving mmu_spte_clear_track_bits: >> >> >> BUG: KASAN: use-after-free in mmu_spte_clear_track_bits+0x186/0x190 >> arch/x86/kvm/mmu.c:597 at addr ffff880068ae2008 >> Read of size 8 by task syz-executor2/16715 >> page:ffffea00016e6170 count:0 mapcount:0 mapping: (null) index:0x0 >> flags: 0x500000000000000() >> raw: 0500000000000000 0000000000000000 0000000000000000 00000000ffffffff >> raw: ffffea00017ec5a0 ffffea0001783d48 ffff88006aec5d98 >> page dumped because: kasan: bad access detected >> CPU: 2 PID: 16715 Comm: syz-executor2 Not tainted 4.10.0-rc3+ #163 >> 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+0x292/0x3a2 lib/dump_stack.c:51 >> kasan_report_error mm/kasan/report.c:213 [inline] >> kasan_report+0x42d/0x460 mm/kasan/report.c:307 >> __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:333 >> mmu_spte_clear_track_bits+0x186/0x190 arch/x86/kvm/mmu.c:597 >> drop_spte+0x24/0x280 arch/x86/kvm/mmu.c:1182 >> kvm_zap_rmapp+0x119/0x260 arch/x86/kvm/mmu.c:1401 >> kvm_unmap_rmapp+0x1d/0x30 arch/x86/kvm/mmu.c:1412 >> kvm_handle_hva_range+0x54a/0x7d0 arch/x86/kvm/mmu.c:1565 >> kvm_unmap_hva_range+0x2e/0x40 arch/x86/kvm/mmu.c:1591 >> kvm_mmu_notifier_invalidate_range_start+0xae/0x140 >> arch/x86/kvm/../../../virt/kvm/kvm_main.c:360 >> __mmu_notifier_invalidate_range_start+0x1f8/0x300 mm/mmu_notifier.c:199 >> mmu_notifier_invalidate_range_start include/linux/mmu_notifier.h:282 [inline] >> unmap_vmas+0x14b/0x1b0 mm/memory.c:1368 >> unmap_region+0x2f8/0x560 mm/mmap.c:2460 >> do_munmap+0x7b8/0xfa0 mm/mmap.c:2657 >> mmap_region+0x68f/0x18e0 mm/mmap.c:1612 >> do_mmap+0x6a2/0xd40 mm/mmap.c:1450 >> do_mmap_pgoff include/linux/mm.h:2031 [inline] >> vm_mmap_pgoff+0x1a9/0x200 mm/util.c:305 >> SYSC_mmap_pgoff mm/mmap.c:1500 [inline] >> SyS_mmap_pgoff+0x22c/0x5d0 mm/mmap.c:1458 >> SYSC_mmap arch/x86/kernel/sys_x86_64.c:95 [inline] >> SyS_mmap+0x16/0x20 arch/x86/kernel/sys_x86_64.c:86 >> entry_SYSCALL_64_fastpath+0x1f/0xc2 >> RIP: 0033:0x445329 >> RSP: 002b:00007fb33933cb58 EFLAGS: 00000282 ORIG_RAX: 0000000000000009 >> RAX: ffffffffffffffda RBX: 0000000020000000 RCX: 0000000000445329 >> RDX: 0000000000000003 RSI: 0000000000af1000 RDI: 0000000020000000 >> RBP: 00000000006dfe90 R08: ffffffffffffffff R09: 0000000000000000 >> R10: 0000000000000032 R11: 0000000000000282 R12: 0000000000700000 >> R13: 0000000000000006 R14: ffffffffffffffff R15: 0000000020001000 >> Memory state around the buggy address: >> ffff880068ae1f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >> ffff880068ae1f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >>> ffff880068ae2000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >> ^ >> ffff880068ae2080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >> ffff880068ae2100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff >> ================================================================== > > This could be related to the gfn_to_rmap issues. Humm... That's possible. Potentially I am not seeing any more of spte-related crashes after I applied the following patch: --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -968,8 +968,7 @@ int __kvm_set_memory_region(struct kvm *kvm, /* Check for overlaps */ r = -EEXIST; kvm_for_each_memslot(slot, __kvm_memslots(kvm, as_id)) { - if ((slot->id >= KVM_USER_MEM_SLOTS) || - (slot->id == id)) + if (slot->id == id) continue; if (!((base_gfn + npages <= slot->base_gfn) || (base_gfn >= slot->base_gfn + slot->npages)))