Path: csiph.com!1.us.feeder.erje.net!feeder.erje.net!2.eu.feeder.erje.net!news.szaf.org!news.unit0.net!news.panservice.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod From: Dmitry Vyukov Newsgroups: linux.kernel Subject: Re: NULL-ptr deref in kvm_arch_vcpu_ioctl under AMD CPUs Date: Sat, 10 Sep 2016 01:10:01 +0200 Message-ID: References: Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=w7mrb46Dyelzu+NYuu8mqayJDLkDKw1ozU7vSIq7j6M=; b=GZRdiITYX+0Duabyk0EPBTMqrTE8765MoW290Ddx7z9xoCdE1Mbv/jFIp9Xw/Udn4r zev9JhyHkoKHfyHp9KeFjVBrtxGTip68yK/X/fLzzaDK+2IPnUEpNmngKr2TOSVsr60I 8RrfOy87e5eKbeJBgRZtg8Ano8ky+LgcMOp2J3Ci2Kpyu294Aax1VKJ1meAtRf91SxL8 rOVFihloELeiUyw0X2W3xJfV3X+DiUOSnBuOsrUyNxYoNFxcuV4KUPsvlRX4Rgf5Rgz0 8/AWVPw21S7hcgA1Ad+T4685hqklkWpSu/xXl5KvQlY3r3Wz4r+yJQSQ0CaQXFJBGNeQ IoNQ== X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=w7mrb46Dyelzu+NYuu8mqayJDLkDKw1ozU7vSIq7j6M=; b=DcdjNE9NfDIdboaJ8jPsSxaXLe+o1yIvOyIpYGH+BdzNieZPOZU2UxbMSj0PY5dB29 IZS3FURik88DzJqg/LRkoObyjJuPkxxhggJxjEloGAJ628mzIuZ4W+jYsoKzUv1BHm1z hf+x+Mb+yNx34lg7A95i7BozeoHoVGIoPVCk2rgb/kOCaV0UE4rljBY9tcNudPt87YQO LhgpmqdHAure6K0K13adMjbgV3MirjVsrl0JqZrC6HOtIvHue02zv096XLBDN1+txy3p 5odClXin6BopVq8RpTGu2uFE8ZktH8M8vekP3StUMWuO3JCY14ZSK283ySX7/CceghIO KB/w== X-Gm-Message-State: AE9vXwPQwRQnUr6Zf8Nt74V5kDlGUnpb956aSPsIiajZYNImgnjMNMRRVQmaQ0YNyxcQtO8Ip3ylliKycNOlRdUV X-Received: by 10.25.148.8 with SMTP id w8mr2197820lfd.28.1473462228462; Fri, 09 Sep 2016 16:03:48 -0700 (PDT) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 49 Organization: linux.* mail to news gateway X-Original-Cc: =?UTF-8?B?Um9iZXJ0IMWad2nEmWNraQ==?= , LKML , Borislav Petkov X-Original-Date: Sat, 10 Sep 2016 01:03:28 +0200 X-Original-Message-ID: X-Original-References: <800588f1-32d0-a4cc-821d-d31eef8921e7@redhat.com> <7810f213-c6a5-b4b7-b95d-cd9dc2570641@redhat.com> <82607566-fc73-5671-b230-4e9627e16aa3@redhat.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1480432 On Tue, Aug 30, 2016 at 5:03 PM, Paolo Bonzini wrote: > > > On 30/08/2016 15:08, Dmitry Vyukov wrote: >>> > b21629da120 kvm: x86: avoid warning on repeated KVM_SET_TSS_ADDR >>> > 83676e92389 KVM: x86: avoid vmalloc(0) in the KVM_SET_CPUID >>> > 78e546c824f KVM: fail KVM_SET_VCPU_EVENTS with invalid exception number >>> > c622a3c21ed KVM: irqfd: fix NULL pointer dereference in kvm_irq_map_gsi >>> > f8c1b85b252 KVM: x86: avoid vmalloc(0) in the KVM_SET_CPUID >>> > d14bdb553f9 KVM: x86: fix OOPS after invalid KVM_SET_DEBUGREGS >>> > 250715a6171 KVM: x86: protect KVM_CREATE_PIT/KVM_CREATE_PIT2 with kvm->lock >>> > 4c5ea0a9cd0 locking/static_key: Fix concurrent static_key_slow_inc() >>> > >>> > The last one is responsible for most if not all of the OOPses with >>> > threads. >> >> I've started fuzzing kvm again. No crashes so far. > > Fingers crossed! :) Hi Paolo, I've noticed that KVM is not actually enabled on my machines. /dev/kvm is missing. If I mknod it manually, opens return ENODEV. After several hours of debugging I figured that it seems to be caused by: commit 91fa0f8e9e2937fd9360f326ad60d51908347afd Author: Paolo Bonzini Date: Wed Jun 15 20:55:08 2016 +0200 KVM: x86: always use "acknowledge interrupt on exit" If I move VM_EXIT_ACK_INTR_ON_EXIT from min back to opt. /dev/kvm become functional again (at least I can open it). To make it clear, it all happens inside of qemu instance. I've tried using different cpus in qemu, including "host" cpu which is pretty capable: model name : Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm vnmi ept fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid xsaveopt So why am I missing VM_EXIT_ACK_INTR_ON_EXIT feature? How does it work for other users? And how should I fix it in a proper way?