Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4131359imu; Mon, 14 Jan 2019 15:49:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN4pnlZ5dGnFZeS5ldRTlbs8qVj3sz3jSsjv9HEDtYmxqL/puu0ayd6L75NLm6XTbez5aX0M X-Received: by 2002:a65:5286:: with SMTP id y6mr960304pgp.439.1547509761133; Mon, 14 Jan 2019 15:49:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547509761; cv=none; d=google.com; s=arc-20160816; b=NtOkr8l+dimCZyihHnuGesZmCHxO31S8kv1yIlTiuvnMDO41DPml4i2Dgmzt25iEMB 80sowl6EN19JduG09oun5Js85wsRT535gbvXD7hc/np+Kh7/LmBXC4TohimSzfzh8rJi 2z9fRRw4NxCNgowVXAwf1cpGz/qczwfSRhRR9sOHVN8B+l/4hParZA7RI2TsjUlA7q8g jYP39X4awSUYig8vNxG+wUGsfHtDp8AF16pFsB2C94NKw+R4otZFAFcA9syhR+3f9aI1 1jqFnw2pxC2Y62rEdTeDeqCohskUi1iEWKa7CoLBFoGg1nEQ/KXJGg6M3rvx8tjfZX0H lN9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=DyNHNOpRHYfQX03BEElWerg7y93ICKkIGunjZWqODLk=; b=x2vFBqEeaBQj44rU3FUn1CggH+ivyxq/F4YNqBdxpT2CZEmQZGIuyazHbi8vomFc3d CzMTpGCBG8V3dZDRcSZIWZ5Aa8ZVzLXRejvHAz1t3yf/QXlIBKrchxKsWDUex0KBfWhy R3OEpJeLtV9Fy1BjSt9uDQSXCFVqhg/McJSw6alYQybGaRXlYNBAYdvIJkUE3ZechL6W izqKnJcg808KPjT+00EkbP+9/vaueMd+s39veXbvarl6aOPI29ELF/BKcw0uYaZNU0RA kOmSM7svx7/Jp0e76LnLhrfLK4tBetrCoFtL9dIXI9ZrAcqoJkm2xhcScDFjSpesw2zC oKIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YtwFxkQA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 133si1610557pfc.61.2019.01.14.15.49.05; Mon, 14 Jan 2019 15:49:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YtwFxkQA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727247AbfANXrx (ORCPT + 99 others); Mon, 14 Jan 2019 18:47:53 -0500 Received: from mail-yw1-f74.google.com ([209.85.161.74]:48460 "EHLO mail-yw1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726776AbfANXrw (ORCPT ); Mon, 14 Jan 2019 18:47:52 -0500 Received: by mail-yw1-f74.google.com with SMTP id v187so424322ywv.15 for ; Mon, 14 Jan 2019 15:47:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=DyNHNOpRHYfQX03BEElWerg7y93ICKkIGunjZWqODLk=; b=YtwFxkQAHpEln7Dk8lAkmFX6APkMcrh10F2T5DwAGqfmHb6uFdVirV/IH50YxJ/hrx 0pte13PufAUwllS2nNSwytCTQ7ligoAhrIn1WmXqKW+IPyyCUwJzN3ES19OkEn/RiDUq xhWtYcP2nL6TMtwf1o4Oa0tkBhHjDsd5MKmwtZCGUL1S9CvqDVbP5ZwRAD+BJLl6HiuF pIhNTnF1LZet5NRf4suJOOXNfrmchqZxQJdwvW+uURfMZ21ySJoXYr2qdCcFmohNHIg1 cLu3YAlBUlvN3QdtnrBNgH+EyXtEbXgR1H8JbrEheLe9U6v0xbej35y7Qm9ajnYHw32W qN/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=DyNHNOpRHYfQX03BEElWerg7y93ICKkIGunjZWqODLk=; b=qkf+Hjx1FjPcuIMxvaDEwElScGqlzfEzjarpxaCW0TwuAKkDFjLIIUC5Ukzj5lI/LO AfpQ88RQPFw4ZMbPfzvqMZSroAnDgH4i9a87icxEcA3nP6gY6lDbSO2ytZbLvKl4KzOJ hi4rjLHytDNBY0Xq4uG+KfLzRCI97qks4agjz9aFCkv7esmRo5C84VhIUldZ7zq9O3Zb u0bSSmVAKRrQAwKErdV1kyxjGpGuMAoHLZSq6FNE5I2U76OaO4oX5nX3V7N5vCgGMh8G jiK/5xuNBkTziSYcuD+RF9eFpHlRn+hFK9r5cSyzWpX8OeCRwylXTOTuJBjmftmhLAcZ BoBg== X-Gm-Message-State: AJcUukezxxW1pnSCWXe+Vj5cxbYCRytlmdO2IjETrW/EDFRozHIrIqVv 7ngDCjC7KWr4Bdf2i/eLxcjsWsu+jx2+rg== X-Received: by 2002:a25:c64e:: with SMTP id k75mr261925ybf.90.1547509671676; Mon, 14 Jan 2019 15:47:51 -0800 (PST) Date: Mon, 14 Jan 2019 15:47:28 -0800 In-Reply-To: <6f79d9be-fa76-3a06-2612-f44f3a18ece7@redhat.com> Message-Id: <20190114234728.49239-1-tmroeder@google.com> Mime-Version: 1.0 References: <6f79d9be-fa76-3a06-2612-f44f3a18ece7@redhat.com> X-Mailer: git-send-email 2.20.1.97.g81188d93c3-goog Subject: [RFC PATCH] kvm: x86/vmx: Use kzalloc for cached_vmcs12 From: Tom Roeder To: Paolo Bonzini , "=?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?=" 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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