X-Git-Url: https://git.kernelconcepts.de/?a=blobdiff_plain;f=mm%2Fmaccess.c;h=d159b1c96e484d902f6edb34ebb5a83a3977bd57;hb=2d4de05aac6be83cf69b7ec29244d10ec1dd8701;hp=34fe24759ed1f32cb58cd38d2245ae7b82dc7f37;hpb=ed14ee0eea8b6808025356cecc87a8007885263f;p=karo-tx-linux.git diff --git a/mm/maccess.c b/mm/maccess.c index 34fe24759ed1..d159b1c96e48 100644 --- a/mm/maccess.c +++ b/mm/maccess.c @@ -13,6 +13,11 @@ * * 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; }