* + rmap-fix-null-pointer-dereference-on-thp-munlocking.patch added to -mm tree
@ 2017-03-03 22:23 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2017-03-03 22:23 UTC (permalink / raw)
To: kirill.shutemov, aarcange, mm-commits
The patch titled
Subject: rmap: fix NULL-pointer dereference on THP munlocking
has been added to the -mm tree. Its filename is
rmap-fix-null-pointer-dereference-on-thp-munlocking.patch
This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/rmap-fix-null-pointer-dereference-on-thp-munlocking.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/rmap-fix-null-pointer-dereference-on-thp-munlocking.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: rmap: fix NULL-pointer dereference on THP munlocking
The following test case triggers NULL-pointer derefernce in
try_to_unmap_one():
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
int main(int argc, char *argv[])
{
int fd;
system("mount -t tmpfs -o huge=always none /mnt");
fd = open("/mnt/test", O_CREAT | O_RDWR);
ftruncate(fd, 2UL << 20);
mmap(NULL, 2UL << 20, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_FIXED | MAP_LOCKED, fd, 0);
mmap(NULL, 2UL << 20, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_LOCKED, fd, 0);
munlockall();
return 0;
}
Apparently, there's a case when we call try_to_unmap() on huge PMDs:
it's TTU_MUNLOCK.
Let's handle this case correctly.
Fixes: c7ab0d2fdc84 ("mm: convert try_to_unmap_one() to use page_vma_mapped_walk()")
Link: http://lkml.kernel.org/r/20170302151159.30592-1-kirill.shutemov@linux.intel.com
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
mm/rmap.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff -puN mm/rmap.c~rmap-fix-null-pointer-dereference-on-thp-munlocking mm/rmap.c
--- a/mm/rmap.c~rmap-fix-null-pointer-dereference-on-thp-munlocking
+++ a/mm/rmap.c
@@ -1316,12 +1316,6 @@ static int try_to_unmap_one(struct page
}
while (page_vma_mapped_walk(&pvmw)) {
- subpage = page - page_to_pfn(page) + pte_pfn(*pvmw.pte);
- address = pvmw.address;
-
- /* Unexpected PMD-mapped THP? */
- VM_BUG_ON_PAGE(!pvmw.pte, page);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-03-03 22:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 22:23 + rmap-fix-null-pointer-dereference-on-thp-munlocking.patch added to -mm tree akpm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).