Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp894454ybt; Fri, 19 Jun 2020 17:15:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaky1cJMh9viln6hB97FL0xwUyMWTc24OOHqmBuP3yEP7QRZnzrmTiz4HNDfWm94+FEThl X-Received: by 2002:a17:906:abca:: with SMTP id kq10mr6151619ejb.390.1592612150090; Fri, 19 Jun 2020 17:15:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592612150; cv=none; d=google.com; s=arc-20160816; b=zZU6rjqDaNIZm8+IMIaqIBM8AXpDyds6vRUiPMhEvFHNoSk4C7m9p6FsVEF/BX12oU PrMlOL5d9QSbQ3BNarte8uaV/2tdx7Y7Rra1m3BvD31JQ5gcnUoANI8q08pkJTLb/QzY 1fsTSYwcownGfgtHfPH2/yQcS7QRpnRwHdDB8BJUUn+LEhI4MzBCWyL6R97s49W7LCJn EcoxmJnBP+qktd+46F5yiGF1lY6/HP8HtsXegmWh8D+hwspaoy6Ws5hMIMabpXgnw7wF noTUAuO92PGdsWJyecx6RQ6n7Oz51lpaxbWdHNXJ8FOk+eAD/Vveq3JL1x3oMWxet5Zz 35iQ== 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=SgptHT5KwAlE36fQuhR4AHhJwcqrfUey5IrexpIKjkU=; b=pP0nywQmpyuianelJLRf5yOv9d5bSWWtq12ML1aI2R/xD+hSi0ph7UhFbda26W4xUs OKJAiV9KigYEdiqCjSOa6gekROA+dR5iSWjvDIPmg3+QTMqb9rd5fu2+mv3Z6U/QWH6u +wJk/LCTjW4D65Eq1LPXZesgMbLqO8v8c0pDQqSI+Hp4EDDBqsmnLjY277lByHbXI/P+ Bb0RG6FT4c1YxmmyrgELkE05hle4uRgdcA1huc/0P+8HUnQ5VvY98Nowwvge3bW1qL88 WuLJpgBoVeqSD4suetv2p76U2w6dBPJHZc87Rm6tDZaCcIlw1Fv9/2Uas0cpZM73qWuW csEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ay9kEieB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jo13si4851578ejb.290.2020.06.19.17.15.27; Fri, 19 Jun 2020 17:15:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ay9kEieB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393748AbgFSPeX (ORCPT + 99 others); Fri, 19 Jun 2020 11:34:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:36676 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393908AbgFSPcj (ORCPT ); Fri, 19 Jun 2020 11:32:39 -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 CD36920786; Fri, 19 Jun 2020 15:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592580759; bh=V/FRNN+8zZs3+kt8tKPhVX53NnGRkYtabNRJro1vGqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ay9kEieB5xMBWvzAzhSm3Nd/XwlQkpzzBouFEIv64izhnQlqyq6LNb/c5CBlA6oj9 CA9hxivluvA+EcFILbe3UlyfU+tuEGPmgoex88f/O7Ixe7/lQSo8cOHoTboQtjv5iu y6bq7VY+70r+TP8wH8OKr/ie0/AEthGtsNankQeU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Hildenbrand , Alexander Duyck , "Michael S. Tsirkin" Subject: [PATCH 5.7 345/376] virtio-balloon: Disable free page reporting if page poison reporting is not enabled Date: Fri, 19 Jun 2020 16:34:23 +0200 Message-Id: <20200619141726.658495849@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@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: Alexander Duyck commit fb69c2c896fc8289b0d9e2c0791472e7cd398bca upstream. We should disable free page reporting if page poisoning is enabled but we cannot report it via the balloon interface. This way we can avoid the possibility of corrupting guest memory. Normally the page poisoning feature should always be present when free page reporting is enabled on the hypervisor, however this allows us to correctly handle a case of the virtio-balloon device being possibly misconfigured. Fixes: 5d757c8d518d ("virtio-balloon: add support for providing free page reports to host") Cc: stable@vger.kernel.org Acked-by: David Hildenbrand Signed-off-by: Alexander Duyck Link: https://lore.kernel.org/r/20200508173732.17877.85060.stgit@localhost.localdomain Signed-off-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman --- drivers/virtio/virtio_balloon.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -1107,11 +1107,18 @@ static int virtballoon_restore(struct vi static int virtballoon_validate(struct virtio_device *vdev) { - /* Tell the host whether we care about poisoned pages. */ + /* + * Inform the hypervisor that our pages are poisoned or + * initialized. If we cannot do that then we should disable + * page reporting as it could potentially change the contents + * of our free pages. + */ if (!want_init_on_free() && (IS_ENABLED(CONFIG_PAGE_POISONING_NO_SANITY) || !page_poisoning_enabled())) __virtio_clear_bit(vdev, VIRTIO_BALLOON_F_PAGE_POISON); + else if (!virtio_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON)) + __virtio_clear_bit(vdev, VIRTIO_BALLOON_F_REPORTING); __virtio_clear_bit(vdev, VIRTIO_F_IOMMU_PLATFORM); return 0;