]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - mm/maccess.c
fs/ncpfs/dir.c: remove unnecessary new_valid_dev() check
[karo-tx-linux.git] / mm / maccess.c
index 34fe24759ed1f32cb58cd38d2245ae7b82dc7f37..d159b1c96e484d902f6edb34ebb5a83a3977bd57 100644 (file)
  *
  * Safely read from address @src to the buffer at @dst.  If a kernel fault
  * happens, handle that and return -EFAULT.
+ *
+ * We ensure that the copy_from_user is executed in atomic context so that
+ * do_page_fault() doesn't attempt to take mmap_sem.  This makes
+ * probe_kernel_read() suitable for use within regions where the caller
+ * already holds mmap_sem, or other locks which nest inside mmap_sem.
  */
 
 long __weak probe_kernel_read(void *dst, const void *src, size_t size)
@@ -99,5 +104,5 @@ long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count)
        pagefault_enable();
        set_fs(old_fs);
 
-       return ret < 0 ? ret : src - unsafe_addr;
+       return ret ? -EFAULT : src - unsafe_addr;
 }