Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9979630ybi; Wed, 24 Jul 2019 13:27:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzD3dBCS257aByQgfydsB7Tbx10+5idNbQK2O3EUzy/6SEuT3Ag2fx1i6rdahQcSN3tZI78 X-Received: by 2002:a17:902:29c3:: with SMTP id h61mr44127033plb.37.1564000023975; Wed, 24 Jul 2019 13:27:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000023; cv=none; d=google.com; s=arc-20160816; b=Ej9+dLx7kcTAZqytHIBHgxw+6U4JJmj9vA23ZthHtTgA5LnrLPb8ZwdLrX1WCLvGGw aOZsxe13bd6T0ZqAlUVi5J+Gqnu322by/L6gcOJihvyCuqKh+yrrG0aV28I+YcE36bh1 nYOfuj7d6RCpVMkEp1E+TAsx5gMHRLbMoNZePw6nPpHQwmtvZY0sU7eyGn519cWrHRc1 I3aj4wpr47+XMYA55BzCvhkPR5Pye7+7KceyxgwqXI3keG7XhaBITWNShlx8ZOAYA4Pz s4lQCOacZnA/fg9wL5eiZGj2y3LWPSsUmcMocHd+DwT307JyozbtZUDWjjit7hQkRx4h faLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8WlD89kpipegHgaYhGVCD5a4UMGiUhNf0LjVF+fTJy4=; b=VUvmIGSTEfICLhyJ2U2J+uPiOf2n4Tl4OwtlFXQBbdygtTvHe51UbCOjGhPb388jBa hbb+KLUURwK2E8lHeZrKiOYVelgvd+3QAEJ10pYfXh5Ss2NDMh5OiCNioZrFiWrvZVAd PSMmbG9MQUFyd8RLEjpXOJ+kLs+AGytbSOd04eeWMaS5AizS4RZfS6O/3kYwqFoGfSSF TA8OvzAGMxGinam/7BkfUoPuOijJcAu3C52lPrWKWVDqRUPvHHJal5MNyMIywLnql/Dq 9jbnNcNeVlhiWEix5t9ovqcIeXCSwogEB0vx11HzHJQkf4boByY3/1Y4sA+6dOiWq4s8 TWeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GhD7qR69; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c35si6098730pgm.51.2019.07.24.13.26.49; Wed, 24 Jul 2019 13:27:03 -0700 (PDT) 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=@kernel.org header.s=default header.b=GhD7qR69; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389814AbfGXTi6 (ORCPT + 99 others); Wed, 24 Jul 2019 15:38:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:39748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389801AbfGXTiy (ORCPT ); Wed, 24 Jul 2019 15:38:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9874C217D4; Wed, 24 Jul 2019 19:38:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563997134; bh=Z6+ShQJG+hOKLklCzcB3DfvNdkX2JB1PAfPefi98eWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GhD7qR69EqBRLx1loewvCSVo2V5ONu979sG25gp2fe5sIop2NTMlxzvVP7+wMn0GC UR/KWmnFoXIejILeueXVp31CTPOb9uZEBtQUFsBvtgp6WLUILpFEz/PA/zmWdW/7Kf K8exAp6UtGdfRtJv1zG15Z+1XSfxF/xMAEw9HOPY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, KarimAllah Ahmed , Paolo Bonzini Subject: [PATCH 5.2 331/413] KVM: Properly check if "page" is valid in kvm_vcpu_unmap Date: Wed, 24 Jul 2019 21:20:22 +0200 Message-Id: <20190724191759.523869258@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: KarimAllah Ahmed commit b614c6027896ff9ad6757122e84760d938cab15e upstream. The field "page" is initialized to KVM_UNMAPPED_PAGE when it is not used (i.e. when the memory lives outside kernel control). So this check will always end up using kunmap even for memremap regions. Fixes: e45adf665a53 ("KVM: Introduce a new guest mapping API") Cc: stable@vger.kernel.org Signed-off-by: KarimAllah Ahmed Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- virt/kvm/kvm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1790,7 +1790,7 @@ void kvm_vcpu_unmap(struct kvm_vcpu *vcp if (!map->hva) return; - if (map->page) + if (map->page != KVM_UNMAPPED_PAGE) kunmap(map->page); #ifdef CONFIG_HAS_IOMEM else