+ mm-fix-pagecache-write-deadlocks-mm-pagecache-write-deadlocks-efault-fix.patch added to -mm tree

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

 



The patch titled

     mm: pagecache write deadlocks EFAULT fix

has been added to the -mm tree.  Its filename is

     mm-fix-pagecache-write-deadlocks-mm-pagecache-write-deadlocks-efault-fix.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: mm: pagecache write deadlocks EFAULT fix
From: Nick Piggin <npiggin@xxxxxxx>

Fix buffered writes to handle -EFAULT properly.

Also, pass 'seglen' rather than 'bytes' to fault_in_pages_readable in the
DEBUG_VM case, which matches !DEBUG_VM and is the correct thing to do.

Signed-off-by: Nick Piggin <npiggin@xxxxxxx>
Acked-by: Badari Pulavarty <pbadari@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 include/linux/pagemap.h |    5 +++--
 mm/filemap.c            |   12 ++++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff -puN include/linux/pagemap.h~mm-fix-pagecache-write-deadlocks-mm-pagecache-write-deadlocks-efault-fix include/linux/pagemap.h
--- a/include/linux/pagemap.h~mm-fix-pagecache-write-deadlocks-mm-pagecache-write-deadlocks-efault-fix
+++ a/include/linux/pagemap.h
@@ -213,7 +213,7 @@ static inline int fault_in_pages_writeab
 	return ret;
 }
 
-static inline void fault_in_pages_readable(const char __user *uaddr, int size)
+static inline int fault_in_pages_readable(const char __user *uaddr, int size)
 {
 	volatile char c;
 	int ret;
@@ -224,8 +224,9 @@ static inline void fault_in_pages_readab
 
 		if (((unsigned long)uaddr & PAGE_MASK) !=
 				((unsigned long)end & PAGE_MASK))
-		 	__get_user(c, end);
+		 	ret = __get_user(c, end);
 	}
+	return ret;
 }
 
 #endif /* _LINUX_PAGEMAP_H */
diff -puN mm/filemap.c~mm-fix-pagecache-write-deadlocks-mm-pagecache-write-deadlocks-efault-fix mm/filemap.c
--- a/mm/filemap.c~mm-fix-pagecache-write-deadlocks-mm-pagecache-write-deadlocks-efault-fix
+++ a/mm/filemap.c
@@ -2108,8 +2108,14 @@ retry_noprogress:
 		 * Bring in the user page that we will copy from _first_, this
 		 * minimises the chance we have to break into the slowpath
 		 * below.
+		 *
+		 * Must check for -EFAULT here, because an unhandled pagefault
+		 * from the atomic copy below may not actually be due to an
+		 * unmapped user region.
 		 */
-		fault_in_pages_readable(buf, seglen);
+		status = fault_in_pages_readable(buf, seglen);
+		if (unlikely(status))
+			break;
 #endif
 
 		page = __grab_cache_page(mapping,index,&cached_page,&lru_pvec);
@@ -2200,7 +2206,9 @@ retry_noprogress:
 			}
 		} else {
 #ifdef CONFIG_DEBUG_VM
-			fault_in_pages_readable(buf, bytes);
+			status = fault_in_pages_readable(buf, seglen);
+			if (unlikely(status))
+				break;
 #endif
 			/*
 			 * OK, we took a fault without making progress. Fall
_

Patches currently in -mm which might be from npiggin@xxxxxxx are

mm-comment-mmap_sem--lock_page-lockorder.patch
mm-only-mm-debug-write-deadlocks.patch
mm-fix-pagecache-write-deadlocks.patch
mm-fix-pagecache-write-deadlocks-comment.patch
mm-fix-pagecache-write-deadlocks-mm-pagecache-write-deadlocks-efault-fix.patch
fs-prepare_write-fixes.patch
fs-prepare_write-fixes-fuse-fix.patch
oom-dont-kill-unkillable-children-or-siblings.patch
oom-cleanup-messages.patch
oom-less-memdie.patch
mm-incorrect-vm_fault_oom-returns-from-drivers.patch
mm-add-arch_alloc_page.patch
radix-tree-rcu-lockless-readside.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