Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8efc390 authored by Kirill A. Shutemov's avatar Kirill A. Shutemov Committed by Linus Torvalds
Browse files

mm, rmap: fix false positive VM_BUG() in page_add_file_rmap()

PageTransCompound() doesn't distinguish THP from from any other type of
compound pages.  This can lead to false-positive VM_BUG_ON() in
page_add_file_rmap() if called on compound page from a driver[1].

I think we can exclude such cases by checking if the page belong to a
mapping.

The VM_BUG_ON_PAGE() is downgraded to VM_WARN_ON_ONCE().  This path
should not cause any harm to non-THP page, but good to know if we step
on anything else.

[1] http://lkml.kernel.org/r/c711e067-0bff-a6cb-3c37-04dfe77d2db1@redhat.com

Link: http://lkml.kernel.org/r/20160810161345.GA67522@black.fi.intel.com


Signed-off-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: default avatarLaura Abbott <labbott@redhat.com>
Tested-by: default avatarLaura Abbott <labbott@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6423aa81
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -1284,8 +1284,9 @@ void page_add_file_rmap(struct page *page, bool compound)
		VM_BUG_ON_PAGE(!PageSwapBacked(page), page);
		VM_BUG_ON_PAGE(!PageSwapBacked(page), page);
		__inc_node_page_state(page, NR_SHMEM_PMDMAPPED);
		__inc_node_page_state(page, NR_SHMEM_PMDMAPPED);
	} else {
	} else {
		if (PageTransCompound(page)) {
		if (PageTransCompound(page) && page_mapping(page)) {
			VM_BUG_ON_PAGE(!PageLocked(page), page);
			VM_WARN_ON_ONCE(!PageLocked(page));

			SetPageDoubleMap(compound_head(page));
			SetPageDoubleMap(compound_head(page));
			if (PageMlocked(page))
			if (PageMlocked(page))
				clear_page_mlock(compound_head(page));
				clear_page_mlock(compound_head(page));