Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2519319imm; Mon, 28 May 2018 09:37:00 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIQPMD0gR/Amo+jmFUl5W7y2T8E6b958oo/V/uW/ZjAHefTe3Ol7dEwSJtpFXGkf2e1mBLT X-Received: by 2002:a62:48cd:: with SMTP id q74-v6mr2838909pfi.153.1527525420147; Mon, 28 May 2018 09:37:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527525420; cv=none; d=google.com; s=arc-20160816; b=xEgCRL7/AsFyjOyP35oPQTCa2CZqhmdMMHHVtalzFwvh9od3YEXCx1jak5k0szhrGz nQ/hxLpIWOzJJIK0EwpP0xiky91XuDXGMIJmJcyVtdeVOzpfYiFhNk1f1UZufCjatnrc 8+YqESnwxJEnVUjaN7X3IFTfV0PQkHtV4N4pbWi7/9K/t3CTHGMrivFxF34ol/7iNRB/ GupHqC7It6THc4DHvo9Kfc/mO7kEgwXE2252wdGgYEA9MGZDIEd41410nWhAcWGV2LKs tDu9tSBQm8kfULa2LSvpph48DZItkbaN8Dk7BqtjpDwaFEA3B35yggH3+kHMTVhd8cEc ddaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=Q4drYEzT9y5cdLD6Ksp5O76P9vPuTRZeBgCXmv1JWM8=; b=PM56oeMrW2pWwdCx2vwaq9hmPBdz6j+k4hrZimJ9rvKSgXxOgFWL6pZ0xbt6SrFpzG I1Y+hoiwHlEpAoZUaq7yHhVqwdF57EY9S9TawNItn1MNVDWyKAp1AQGdIcTcQO8oSlj7 N9Lndw4tTYy5FXuYQIgrkEK6GQO3ZtVlM9AUhQzJxYf/vIney5MKXU+vL3plCCeIRzvi rEP2sE1KynTDu4ImbMHD7N5Lz15ggVBzvBCG53eD2DrfbFzaFgdn9l+iN2/jggD3Kwo5 xDdgY0d2QztyiVrVIKhBi3UuCmfbn68dLwGg+QSJGbnYlbMbm9LN8/IOoTFRQ+KgGGVs hvKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J23clqYt; 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 y10-v6si24588937pgq.258.2018.05.28.09.36.45; Mon, 28 May 2018 09:37:00 -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=J23clqYt; 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 S940226AbeE1Qfy (ORCPT + 99 others); Mon, 28 May 2018 12:35:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:56586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934707AbeE1KIa (ORCPT ); Mon, 28 May 2018 06:08:30 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 8F093208A6; Mon, 28 May 2018 10:08:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502110; bh=n+aWxgs3VPTyBacR0qLEJOGqA1vf61q6oWH4kgzIXSQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J23clqYtHYt1j9JZ5ON34l5IOcESbRjZnthaeGV0zPBvYf2ISWxd4TcS8FypWs7Hi 6PLJXoOMNu2JIvt5lEntpJzVlwjEpK5/DfheAOjeEfEfKzUo6SuxK61SoWxX5tkmwL 2X1bzCuKas/uuqsObR7VhjSQOwIOODumR2KnzSIo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ross Lagerwall , Boris Ostrovsky , Juergen Gross , Sasha Levin Subject: [PATCH 3.18 038/185] xen/grant-table: Use put_page instead of free_page Date: Mon, 28 May 2018 12:01:19 +0200 Message-Id: <20180528100053.826648641@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ross Lagerwall [ Upstream commit 3ac7292a25db1c607a50752055a18aba32ac2176 ] The page given to gnttab_end_foreign_access() to free could be a compound page so use put_page() instead of free_page() since it can handle both compound and single pages correctly. This bug was discovered when migrating a Xen VM with several VIFs and CONFIG_DEBUG_VM enabled. It hits a BUG usually after fewer than 10 iterations. All netfront devices disconnect from the backend during a suspend/resume and this will call gnttab_end_foreign_access() if a netfront queue has an outstanding skb. The mismatch between calling get_page() and free_page() on a compound page causes a reference counting error which is detected when DEBUG_VM is enabled. Signed-off-by: Ross Lagerwall Reviewed-by: Boris Ostrovsky Signed-off-by: Juergen Gross Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/xen/grant-table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -322,7 +322,7 @@ static void gnttab_handle_deferred(unsig if (entry->page) { pr_debug("freeing g.e. %#x (pfn %#lx)\n", entry->ref, page_to_pfn(entry->page)); - __free_page(entry->page); + put_page(entry->page); } else pr_info("freeing g.e. %#x\n", entry->ref); kfree(entry); @@ -378,7 +378,7 @@ void gnttab_end_foreign_access(grant_ref if (gnttab_end_foreign_access_ref(ref, readonly)) { put_free_entry(ref); if (page != 0) - free_page(page); + put_page(virt_to_page(page)); } else gnttab_add_deferred(ref, readonly, page ? virt_to_page(page) : NULL);