From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Roeder Subject: [RFC PATCH] kvm: x86/vmx: Use kzalloc for cached_vmcs12 Date: Mon, 14 Jan 2019 15:47:28 -0800 Message-ID: <20190114234728.49239-1-tmroeder@google.com> References: <6f79d9be-fa76-3a06-2612-f44f3a18ece7@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: Liran Alon , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Roeder , syzbot+ded1696f6b50b615b630@syzkaller.appspotmail.com To: Paolo Bonzini , "=?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?=" Return-path: In-Reply-To: <6f79d9be-fa76-3a06-2612-f44f3a18ece7@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org This changes the allocation of cached_vmcs12 to use kzalloc instead of kmalloc. This removes the information leak found by Syzkaller (see Reported-by) in this case and prevents similar leaks from happening based on cached_vmcs12. The email from Syszkaller led to a discussion about a patch in early November on the KVM list (I've made this a reply to that thread), but the current upstream kernel still has kmalloc instead of kzalloc for cached_vmcs12 and cached_shadow_vmcs12. This RFC proposes changing to kzalloc for defense in depth. Tested: rebuilt but not tested, since this is an RFC Reported-by: syzbot+ded1696f6b50b615b630@syzkaller.appspotmail.com Signed-off-by: Tom Roeder --- arch/x86/kvm/vmx/nested.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 2616bd2c7f2c7..ad46667042c7a 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -4140,11 +4140,11 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu) if (r < 0) goto out_vmcs02; - vmx->nested.cached_vmcs12 = kmalloc(VMCS12_SIZE, GFP_KERNEL); + vmx->nested.cached_vmcs12 = kzalloc(VMCS12_SIZE, GFP_KERNEL); if (!vmx->nested.cached_vmcs12) goto out_cached_vmcs12; - vmx->nested.cached_shadow_vmcs12 = kmalloc(VMCS12_SIZE, GFP_KERNEL); + vmx->nested.cached_shadow_vmcs12 = kzalloc(VMCS12_SIZE, GFP_KERNEL); if (!vmx->nested.cached_shadow_vmcs12) goto out_cached_shadow_vmcs12; -- 2.20.1.97.g81188d93c3-goog