Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp2117605pxb; Wed, 9 Feb 2022 11:11:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/Fk65h8rhpLh3tYGd6qYixiDnmszH+fP5zMYGC2e9UX18BBQbdn4ubTWfM+1rEAps+ZZy X-Received: by 2002:a63:2cd1:: with SMTP id s200mr3092514pgs.529.1644433916411; Wed, 09 Feb 2022 11:11:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644433916; cv=none; d=google.com; s=arc-20160816; b=GijVf55qu+61OFG28k7Vhh+Q8QCOCKl3OoHVSsUZWskgxjO+iQFTMFoGeYNDBKwMI9 43dhZn+UJV934AUW7yJkXxVBwISjerpMEmt3Myyb3abVWpTA4abEjLfZFOA8RYxYR9Ef ZWMwqjekqrox9xWsyu9CzrQRz3B8TH7PAhJiqWpWH6lkg4HfoQ/CBU1zTzGyI2wAhn6q e86ZnU8/ZcFWNIZlsknpr9VirXz2YzWc4Ox/PAblG3IW2aGzibVyTDn6Tth/6hBVDXsA 2V6uSE/ea+yHhMUmHxYGdLW51n3LHzT+6Bh2x3ON4ZsSkyhrX1hGNj8CgQ+ZebLP7NK1 MkHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fZIUln5prMWPKDJM3hoJG1ZFa53meIsAdYHTNLyA4Gc=; b=kswjf6bZkG32726pmIARAIBq1bXPjj7igC5ZR4rJY6JY4QgsQohR3V6/YHrKRHCZ0c cdMxIPwtwJd+KwqN0cOnQjeh2M+V8irC0UM50OcEiJf7wZL5jB4zkMBMl3rD0cUhbnd9 ITO6bhm3IgpUbz42Er2f2gkq+2H+6LoKwLjiLCs14aXveaXmuaTpeTvYIghh97yfMje2 LJS1Kn1IQHxH48f7fwJNK+TnVqIDAgAzN3yytt3NYkkKviogeY8dLef8gHJ472yUw/WN X+Q3e8pvUtJFOLuM8gTxKf5QMYn+9JYa/VfYxZLgNUBtC+eSYok+cKLKr5eJc50cBmDY 7oJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UwHowb0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 189si16867752pgc.346.2022.02.09.11.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 11:11:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UwHowb0C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C391CC0219A9; Wed, 9 Feb 2022 11:11:13 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237734AbiBIRA7 (ORCPT + 99 others); Wed, 9 Feb 2022 12:00:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237677AbiBIRAw (ORCPT ); Wed, 9 Feb 2022 12:00:52 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B25E9C0613C9 for ; Wed, 9 Feb 2022 09:00:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644426054; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fZIUln5prMWPKDJM3hoJG1ZFa53meIsAdYHTNLyA4Gc=; b=UwHowb0C6gR9Ri/qEs89whxFq63b3Yx3qTZpRmJnMRzcecCLsGI1WPTHk5Kavs2lrmQOl4 ghi8RViHB+UALnwJkkX9T1p3VhZfmg/chDZS3y7/9br1u9kR4jpBKCL0gtoL3gxmrYjwTi i2nz7f49mwqgvvwIrtJ1EvakLGr++Dc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-qEOHYrzmNhq2Tq5dTVLzIw-1; Wed, 09 Feb 2022 12:00:53 -0500 X-MC-Unique: qEOHYrzmNhq2Tq5dTVLzIw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21088101F7A6; Wed, 9 Feb 2022 17:00:51 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99B9D7CD66; Wed, 9 Feb 2022 17:00:50 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: vkuznets@redhat.com, mlevitsk@redhat.com, dmatlack@google.com, seanjc@google.com Subject: [PATCH 05/12] KVM: MMU: avoid NULL-pointer dereference on page freeing bugs Date: Wed, 9 Feb 2022 12:00:13 -0500 Message-Id: <20220209170020.1775368-6-pbonzini@redhat.com> In-Reply-To: <20220209170020.1775368-1-pbonzini@redhat.com> References: <20220209170020.1775368-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If kvm_mmu_free_roots encounters a PAE page table where a 64-bit page table is expected, the result is a NULL pointer dereference. Instead just WARN and exit. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/mmu/mmu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 7b5765ced928..d0f2077bd798 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3201,6 +3201,8 @@ static void mmu_free_root_page(struct kvm *kvm, hpa_t *root_hpa, return; sp = to_shadow_page(*root_hpa & PT64_BASE_ADDR_MASK); + if (WARN_ON(!sp)) + return; if (is_tdp_mmu_page(sp)) kvm_tdp_mmu_put_root(kvm, sp, false); -- 2.31.1