Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp728494pxb; Tue, 5 Apr 2022 20:38:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGAHDST2jgeNBlD3/DhuzD2tNc9REjQbchUljYrqyPkFsrFmQRb+MtwVl4SeztysUUvXa5 X-Received: by 2002:a17:902:b189:b0:14d:6f87:7c25 with SMTP id s9-20020a170902b18900b0014d6f877c25mr6769734plr.31.1649216325834; Tue, 05 Apr 2022 20:38:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649216325; cv=none; d=google.com; s=arc-20160816; b=0qPyAKr7dIXUaZlHztpXEs8gApbx+GA3kJwYSR7C2Gjc8bsh6QL9QEhR4OpWcOH21o bi6ZtargN5ixcTgp4AeYYTSKmL6eJUcmtzQVYhizQh0TkzApohdt2Oey0zTXAKQdNQtm WiyhdocylpY8AxB2AvQVChgR9e9/omUN3OGgxJX+YPraYiPvr+iFaVH2/3bbZgTD452K S24HgnI3Akny4wctFud7QnsDONa9UiKJOD1cvzfmOW3S64YLw5kJk4RO4/weInI6b0dD iW/XfdPBTlthSWKQRFo+VCZJnEU8oUYf9MeNKBxtJBFT9WrH8AnuP2+F4GcneSxZF2j/ J8Gg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pthvqjqFv+jiB1NSdQay3jR5OcgLguLBwZQAQxQ/vx8=; b=SM8/SGpUGBIltFdiRD/oFGqQcEDv4kVjGQh2gv3xGDZBle6RCO4epJ7JooA9iOyOyd ePDAH3A5+a8hcdcbD6tJ+Ma31xU1bgl6fLJ/kaf07Z+EbIqFGzBX3/9fLa0ECn0s7guG zGzr3n4BwYQbV13bwjYHfWEm9/DvfTIQvcBkyrc56Glh53NjT3NnDS6Sfe+dy73x3maU k0/Oe/cU5hfiszVNZMaB/yDBSuzDzN8YQpU3yYBkI9OTk1JF70yF5jH75QjL33EFK2s9 3jZTeF0GopdtTanVlK+slGBL+BsLpLItNxgZRaduNFYZQ+IK7IhkmQz7qUrZpiWm4O64 TsXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ORavolQs; 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=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r16-20020aa79890000000b004fa599bcf9bsi13737997pfl.271.2022.04.05.20.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 20:38:45 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=ORavolQs; 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=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6365D326011; Tue, 5 Apr 2022 20:05:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353631AbiDEKIm (ORCPT + 99 others); Tue, 5 Apr 2022 06:08:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241006AbiDEIcn (ORCPT ); Tue, 5 Apr 2022 04:32:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82927AFAE2; Tue, 5 Apr 2022 01:25:53 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D870560FF7; Tue, 5 Apr 2022 08:25:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFC68C385A1; Tue, 5 Apr 2022 08:25:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649147152; bh=tKl8Rar6xGkNX+SNXpGptpyUaVGPaBj0bQ16qgQWdwk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ORavolQsCDkkbMNOMxauUiG24WSoBinzUqnlBSYymlXvQe8t7TghPBF/UGzKxHmxc YcSXNAaz6RB1lGhlhWudrC3fteXtpyqULzkgIbdos+UGsqw1HdXmqzTaHSOU9jooj8 ypnGIOHfpJg5eHHZAvjVn7GAEJWV2cQSi5Y6ie7k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Woodhouse , Paolo Bonzini Subject: [PATCH 5.17 1003/1126] KVM: avoid double put_page with gfn-to-pfn cache Date: Tue, 5 Apr 2022 09:29:10 +0200 Message-Id: <20220405070436.931601245@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 From: David Woodhouse commit 79593c086eb95eb2886f36ee6f78a1d6845e1bdf upstream. If the cache's user host virtual address becomes invalid, there is still a path from kvm_gfn_to_pfn_cache_refresh() where __release_gpc() could release the pfn but the gpc->pfn field has not been overwritten with an error value. If this happens, kvm_gfn_to_pfn_cache_unmap will call put_page again on the same page. Cc: stable@vger.kernel.org Fixes: 982ed0de4753 ("KVM: Reinstate gfn_to_pfn_cache with invalidation support") Signed-off-by: David Woodhouse Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- virt/kvm/pfncache.c | 1 + 1 file changed, 1 insertion(+) --- a/virt/kvm/pfncache.c +++ b/virt/kvm/pfncache.c @@ -191,6 +191,7 @@ int kvm_gfn_to_pfn_cache_refresh(struct gpc->uhva = gfn_to_hva_memslot(gpc->memslot, gfn); if (kvm_is_error_hva(gpc->uhva)) { + gpc->pfn = KVM_PFN_ERR_FAULT; ret = -EFAULT; goto out; }