diff -druNp --no-dereference linux-libre-3.16.37-gnu/include/linux/mm.h linux-libre-3.16.38-gnu/include/linux/mm.h
--- linux-libre-3.16.37-gnu/include/linux/mm.h	2016-08-22 17:38:32.000000000 -0400
+++ linux-libre-3.16.38-gnu/include/linux/mm.h	2016-10-20 18:41:13.000000000 -0400
@@ -2007,6 +2007,7 @@ static inline struct page *follow_page(s
 #define FOLL_HWPOISON	0x100	/* check page is hwpoisoned */
 #define FOLL_NUMA	0x200	/* force NUMA hinting page fault */
 #define FOLL_MIGRATION	0x400	/* wait for page to replace migration entry */
+#define FOLL_COW	0x4000	/* internal GUP flag */
 
 typedef int (*pte_fn_t)(pte_t *pte, pgtable_t token, unsigned long addr,
 			void *data);
diff -druNp --no-dereference linux-libre-3.16.37-gnu/Makefile linux-libre-3.16.38-gnu/Makefile
--- linux-libre-3.16.37-gnu/Makefile	2016-08-23 14:34:43.000000000 -0400
+++ linux-libre-3.16.38-gnu/Makefile	2016-10-21 06:15:52.000000000 -0400
@@ -1,6 +1,6 @@
 VERSION = 3
 PATCHLEVEL = 16
-SUBLEVEL = 37
+SUBLEVEL = 38
 EXTRAVERSION =-gnu
 NAME = Museum of Fishiegoodies
 
diff -druNp --no-dereference linux-libre-3.16.37-gnu/mm/gup.c linux-libre-3.16.38-gnu/mm/gup.c
--- linux-libre-3.16.37-gnu/mm/gup.c	2016-08-22 17:38:32.000000000 -0400
+++ linux-libre-3.16.38-gnu/mm/gup.c	2016-10-20 18:41:13.000000000 -0400
@@ -28,6 +28,16 @@ static struct page *no_page_table(struct
 	return NULL;
 }
 
+/*
+ * FOLL_FORCE can write to even unwritable pte's, but only
+ * after we've gone through a COW cycle and they are dirty.
+ */
+static inline bool can_follow_write_pte(pte_t pte, unsigned int flags)
+{
+	return pte_write(pte) ||
+		((flags & FOLL_FORCE) && (flags & FOLL_COW) && pte_dirty(pte));
+}
+
 static struct page *follow_page_pte(struct vm_area_struct *vma,
 		unsigned long address, pmd_t *pmd, unsigned int flags)
 {
@@ -62,7 +72,7 @@ retry:
 	}
 	if ((flags & FOLL_NUMA) && pte_numa(pte))
 		goto no_page;
-	if ((flags & FOLL_WRITE) && !pte_write(pte)) {
+	if ((flags & FOLL_WRITE) && !can_follow_write_pte(pte, flags)) {
 		pte_unmap_unlock(ptep, ptl);
 		return NULL;
 	}
@@ -302,7 +312,7 @@ static int faultin_page(struct task_stru
 	 * reCOWed by userspace write).
 	 */
 	if ((ret & VM_FAULT_WRITE) && !(vma->vm_flags & VM_WRITE))
-		*flags &= ~FOLL_WRITE;
+	        *flags |= FOLL_COW;
 	return 0;
 }
 
