linux/fs/proc
Peter Feiner 64e455079e mm: softdirty: enable write notifications on VMAs after VM_SOFTDIRTY cleared
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 unnecessary faults, write notifications
are disabled when VM_SOFTDIRTY is set.

As a side effect of enabling and disabling write notifications with
care, this patch fixes a bug in mprotect where vm_page_prot bits set by
drivers were zapped on mprotect.  An analogous bug was fixed in mmap by
commit c9d0bf2414 ("mm: uncached vma support with writenotify").

Signed-off-by: Peter Feiner <pfeiner@google.com>
Reported-by: Peter Feiner <pfeiner@google.com>
Suggested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: Pavel Emelyanov <xemul@parallels.com>
Cc: Jamie Liu <jamieliu@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-10-14 02:18:28 +02:00
..
Kconfig
Makefile proc: Implement /proc/thread-self to point at the directory of the current thread 2014-08-04 10:07:11 -07:00
array.c Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security 2014-08-06 08:06:39 -07:00
base.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2014-10-13 11:28:42 +02:00
cmdline.c
consoles.c
cpuinfo.c
devices.c
fd.c vfs: Remove d_drop calls from d_revalidate implementations 2014-10-09 02:38:58 -04:00
fd.h
generic.c proc: make proc_subdir_lock static 2014-08-08 15:57:22 -07:00
inode.c proc: Implement /proc/thread-self to point at the directory of the current thread 2014-08-04 10:07:11 -07:00
internal.h proc/maps: replace proc_maps_private->pid with "struct inode *inode" 2014-10-09 22:25:50 -04:00
interrupts.c
kcore.c fs/proc/kcore.c: don't add modules range to kcore if it's equal to vmcore range 2014-10-09 22:25:50 -04:00
kmsg.c
loadavg.c
meminfo.c mm: export NR_SHMEM via sysinfo(2) / si_meminfo() interfaces 2014-08-06 18:01:19 -07:00
namespaces.c
nommu.c
page.c mm/balloon_compaction: add vmstat counters and kpageflags bit 2014-10-09 22:26:01 -04:00
proc_net.c Revert "proc: Point /proc/{mounts,net} at /proc/thread-self/{mounts,net} instead of /proc/self/{mounts,net}" 2014-08-10 21:24:59 -07:00
proc_sysctl.c sysctl: remove typedef ctl_table 2014-08-08 15:57:24 -07:00
proc_tty.c proc: remove proc_tty_ldisc variable 2014-08-08 15:57:22 -07:00
root.c Revert "proc: Point /proc/{mounts,net} at /proc/thread-self/{mounts,net} instead of /proc/self/{mounts,net}" 2014-08-10 21:24:59 -07:00
self.c
softirqs.c
stat.c /proc/stat: convert to single_open_size() 2014-07-03 09:21:54 -07:00
task_mmu.c mm: softdirty: enable write notifications on VMAs after VM_SOFTDIRTY cleared 2014-10-14 02:18:28 +02:00
task_nommu.c proc/maps: make vm_is_stack() logic namespace-friendly 2014-10-09 22:25:50 -04:00
thread_self.c proc: Implement /proc/thread-self to point at the directory of the current thread 2014-08-04 10:07:11 -07:00
uptime.c
version.c
vmcore.c fs/proc/vmcore.c:mmap_vmcore: skip non-ram pages reported by hypervisors 2014-08-08 15:57:23 -07:00