+ mlock-operate-on-any-regions-with-protection-=-prot_none.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     mlock: operate on any regions with protection != PROT_NONE
has been added to the -mm tree.  Its filename is
     mlock-operate-on-any-regions-with-protection-=-prot_none.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 ***

See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
out what to do about this

The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/

------------------------------------------------------
Subject: mlock: operate on any regions with protection != PROT_NONE
From: Michel Lespinasse <walken@xxxxxxxxxx>

As Tao Ma noticed, 5ecfda0 ("mlock: avoid dirtying pages and triggering
writeback") breaks blktrace.  This is because blktrace mmaps a file with
PROT_WRITE permissions but without PROT_READ, so my attempt to not
unnecessarity break COW during mlock ended up causing mlock to fail with a
permission problem.

Let mlock ignore vma protection in all cases except PROT_NONE.  In
particular, mlock should not fail for PROT_WRITE regions (as in the
blktrace case, which broke at 5ecfda0) or for PROT_EXEC regions (which
seem to me like they were always broken).

Signed-off-by: Michel Lespinasse <walken@xxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Reported-by: Tao Ma <tm@xxxxxx>
Cc: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx>
Acked-by: Rik van Riel <riel@xxxxxxxxxx>
Cc: Hugh Dickins <hughd@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/mlock.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff -puN mm/mlock.c~mlock-operate-on-any-regions-with-protection-=-prot_none mm/mlock.c
--- a/mm/mlock.c~mlock-operate-on-any-regions-with-protection-=-prot_none
+++ a/mm/mlock.c
@@ -178,6 +178,13 @@ static long __mlock_vma_pages_range(stru
 	if ((vma->vm_flags & (VM_WRITE | VM_SHARED)) == VM_WRITE)
 		gup_flags |= FOLL_WRITE;
 
+	/*
+	 * We want mlock to succeed for regions that have any permissions
+	 * other than PROT_NONE.
+	 */
+	if (vma->vm_flags & (VM_READ | VM_WRITE | VM_EXEC))
+		gup_flags |= FOLL_FORCE;
+
 	if (vma->vm_flags & VM_LOCKED)
 		gup_flags |= FOLL_MLOCK;
 
_

Patches currently in -mm which might be from walken@xxxxxxxxxx are

mlock-operate-on-any-regions-with-protection-=-prot_none.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux