lkml.org 
[lkml]   [2014]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/3] mm: softdirty: enable write notifications on VMAs after VM_SOFTDIRTY cleared
On Sun, Aug 24, 2014 at 02:00:11AM +0300, Kirill A. Shutemov wrote:
> On Sat, Aug 23, 2014 at 06:11:59PM -0400, Peter Feiner wrote:
> > For VMAs that don't want write notifications, PTEs created for read
> > faults have their write bit set. If the read fault happens after
> > VM_SOFTDIRTY is cleared, then the PTE's softdirty bit will remain
> > clear after subsequent writes.
> >
> > Here's a simple code snippet to demonstrate the bug:
> >
> > char* m = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE,
> > MAP_ANONYMOUS | MAP_SHARED, -1, 0);
> > system("echo 4 > /proc/$PPID/clear_refs"); /* clear VM_SOFTDIRTY */
> > assert(*m == '\0'); /* new PTE allows write access */
> > assert(!soft_dirty(x));
> > *m = 'x'; /* should dirty the page */
> > assert(soft_dirty(x)); /* fails */
> >
> > With this patch, write notifications are enabled when VM_SOFTDIRTY is
> > cleared. Furthermore, to avoid faults, write notifications are
> > disabled when VM_SOFTDIRTY is reset.
> >
> > Signed-off-by: Peter Feiner <pfeiner@google.com>

One more case to consider: mprotect() which doesn't trigger successful
vma_merge() will not set VM_SOFTDIRTY and will not enable write-protect on
the vma.

It's probably better to take VM_SOFTDIRTY into account in
vma_wants_writenotify() and re-think logic in other corners.

--
Kirill A. Shutemov


\
 
 \ /
  Last update: 2014-08-24 03:01    [W:0.058 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site