xen/grant-table: Use put_page instead of free_page
authorRoss Lagerwall <ross.lagerwall@citrix.com>
Thu, 11 Jan 2018 09:36:37 +0000 (09:36 +0000)
committerJuergen Gross <jgross@suse.com>
Tue, 6 Feb 2018 08:55:37 +0000 (09:55 +0100)
commit3ac7292a25db1c607a50752055a18aba32ac2176
treefc61e3f29d937cff55bb19eb953cb64f8190e018
parent4f277295e54c5b7340e48efea3fc5cc21a2872b7
xen/grant-table: Use put_page instead of free_page

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 <ross.lagerwall@citrix.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
drivers/xen/grant-table.c