https://github.com/torvalds/linux
Revision 655548bf6271b212cd1e4c259da9dbe616348d38 authored by Kirill A. Shutemov on 30 November 2016, 23:54:05 UTC, committed by Linus Torvalds on 01 December 2016, 00:32:52 UTC
The following program triggers BUG() in munlock_vma_pages_range():

	// autogenerated by syzkaller (http://github.com/google/syzkaller)
	#include <sys/mman.h>

	int main()
	{
	  mmap((void*)0x20105000ul, 0xc00000ul, 0x2ul, 0x2172ul, -1, 0);
	  mremap((void*)0x201fd000ul, 0x4000ul, 0xc00000ul, 0x3ul, 0x203f0000ul);
	  return 0;
	}

The test-case constructs the situation when munlock_vma_pages_range()
finds PTE-mapped THP-head in the middle of page table and, by mistake,
skips HPAGE_PMD_NR pages after that.

As result, on the next iteration it hits the middle of PMD-mapped THP
and gets upset seeing mlocked tail page.

The solution is only skip HPAGE_PMD_NR pages if the THP was mlocked
during munlock_vma_page().  It would guarantee that the page is
PMD-mapped as we never mlock PTE-mapeed THPs.

Fixes: e90309c9f772 ("thp: allow mlocked THP again")
Link: http://lkml.kernel.org/r/20161115132703.7s7rrgmwttegcdh4@black.fi.intel.com
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: syzkaller <syzkaller@googlegroups.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: <stable@vger.kernel.org>	[4.5+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e1465d1
History
Tip revision: 655548bf6271b212cd1e4c259da9dbe616348d38 authored by Kirill A. Shutemov on 30 November 2016, 23:54:05 UTC
thp: fix corner case of munlock() of PTE-mapped THPs
Tip revision: 655548b
File Mode Size
partitions
Kconfig -rw-r--r-- 3.8 KB
Kconfig.iosched -rw-r--r-- 1.6 KB
Makefile -rw-r--r-- 949 bytes
badblocks.c -rw-r--r-- 14.5 KB
bio-integrity.c -rw-r--r-- 14.2 KB
bio.c -rw-r--r-- 48.5 KB
blk-cgroup.c -rw-r--r-- 35.8 KB
blk-core.c -rw-r--r-- 93.3 KB
blk-exec.c -rw-r--r-- 3.2 KB
blk-flush.c -rw-r--r-- 16.3 KB
blk-integrity.c -rw-r--r-- 12.3 KB
blk-ioc.c -rw-r--r-- 10.2 KB
blk-lib.c -rw-r--r-- 7.3 KB
blk-map.c -rw-r--r-- 5.8 KB
blk-merge.c -rw-r--r-- 19.6 KB
blk-mq-cpumap.c -rw-r--r-- 2.3 KB
blk-mq-pci.c -rw-r--r-- 1.5 KB
blk-mq-sysfs.c -rw-r--r-- 11.7 KB
blk-mq-tag.c -rw-r--r-- 11.1 KB
blk-mq-tag.h -rw-r--r-- 2.2 KB
blk-mq.c -rw-r--r-- 56.5 KB
blk-mq.h -rw-r--r-- 2.7 KB
blk-settings.c -rw-r--r-- 27.0 KB
blk-softirq.c -rw-r--r-- 4.3 KB
blk-sysfs.c -rw-r--r-- 18.5 KB
blk-tag.c -rw-r--r-- 10.0 KB
blk-throttle.c -rw-r--r-- 42.7 KB
blk-timeout.c -rw-r--r-- 5.9 KB
blk.h -rw-r--r-- 9.0 KB
bounce.c -rw-r--r-- 5.8 KB
bsg-lib.c -rw-r--r-- 6.0 KB
bsg.c -rw-r--r-- 22.9 KB
cfq-iosched.c -rw-r--r-- 127.1 KB
cmdline-parser.c -rw-r--r-- 4.9 KB
compat_ioctl.c -rw-r--r-- 20.8 KB
deadline-iosched.c -rw-r--r-- 11.3 KB
elevator.c -rw-r--r-- 23.8 KB
genhd.c -rw-r--r-- 45.0 KB
ioctl.c -rw-r--r-- 14.8 KB
ioprio.c -rw-r--r-- 5.1 KB
noop-iosched.c -rw-r--r-- 2.6 KB
partition-generic.c -rw-r--r-- 14.7 KB
scsi_ioctl.c -rw-r--r-- 19.4 KB
t10-pi.c -rw-r--r-- 4.8 KB

back to top