Received: by 10.192.165.148 with SMTP id m20csp540553imm; Wed, 25 Apr 2018 03:58:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx49lj9QYecgHkQSqfAjf/uEk/Cu5jQlFbIAyfl7cLtqzt7Y/io1Ej1zCJE6aEmy67lbKx/jM X-Received: by 10.98.11.3 with SMTP id t3mr27649250pfi.32.1524653927718; Wed, 25 Apr 2018 03:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524653927; cv=none; d=google.com; s=arc-20160816; b=ZZzgfn/hJ7//nFAMYk5xvdlMfKgMOF/6XySCbTQNNPcnNTk0536U+cdA/KlGY5x+FS bpCdPQ1QbMIrFgQe1B33SeCeLLuKKpr/e1P6G1KvwPqBLNcaIOWHQ+1QDMZtzEIz7fAw qRL5DbrYhpjf0iZy25n8s52XI4DoB7PJU7yIUZy0HWUfcQ//yAhxrc/LeUcgPvDMpQ6+ GYLvHy1QMxzC+51wfFHi9R6JcB/Bw/GWvYwFaXsgP/b2yQYfMZ3BeZy2lw1abrLdexXW kjiKsadsnCM8SqZK9ugY8t2ZbNEJ/N9oObRVftAYqia/co20TAzkgsEih1jlCTVIOFMt DWTQ== 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 :arc-authentication-results; bh=tyTqlYbChRG51IK8KnlabYLefUNASlXdJq8mbeK8Yrg=; b=JMZxLnyliI4OTXK7hBngQutqXTWowvhaUGVmVRw71Zi+X6Gx3POJm0hhvfVc66xniy Ic5b8AkOTDJYRFuIcRz0ptmx9snpPJ4/8CqWpBEPlz8Hu20no6iIZaAx31wUmdADJ8vb 0SxM49ajEnC71bnK43SVhkYceLB73cAL4twkGR0/oTLGt1VfNOrsnpBF1OOYJISjuel+ g5tLbr+gMOQvCkbUssM1Px09GfbFyqQ7ZQg/fmXkEeKxpiFDlmpXFREtXef4SPSuy2Hm cH449dtlQEXh4YJcVQsey+jzzlT9zo/fhlkv1OqBkY4t4FCn4osWiwe+8vp/4A8mLEOh t/fQ== ARC-Authentication-Results: i=1; mx.google.com; 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 f1si12828845pgq.462.2018.04.25.03.58.33; Wed, 25 Apr 2018 03:58:47 -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; 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 S1754165AbeDYK5g (ORCPT + 99 others); Wed, 25 Apr 2018 06:57:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52844 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754170AbeDYKnD (ORCPT ); Wed, 25 Apr 2018 06:43:03 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4C89F266; Wed, 25 Apr 2018 10:43:02 +0000 (UTC) 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 4.14 140/183] xen/grant-table: Use put_page instead of free_page Date: Wed, 25 Apr 2018 12:36:00 +0200 Message-Id: <20180425103248.173790853@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@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 4.14-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 @@ -328,7 +328,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); @@ -384,7 +384,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);