summaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-11-29 14:07:55 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-29 14:07:55 -0800
commit5d2a2dbbc1025dbf7998b9289574d9592b8f21cc (patch)
treeb4f3f45190b814b5196235c21f983fbc7878a47b /mm
parentc9cfcddfd65735437a4cb8563d6b66a6da8a5ed6 (diff)
downloadlinux-5d2a2dbbc1025dbf7998b9289574d9592b8f21cc.tar.gz
linux-5d2a2dbbc1025dbf7998b9289574d9592b8f21cc.tar.bz2
linux-5d2a2dbbc1025dbf7998b9289574d9592b8f21cc.zip
cow_user_page: fix page alignment
High Dickins points out that the user virtual address passed to the page fault handler isn't necessarily page-aligned. Also, add a comment on why the copy could fail for the user address case. Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memory.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/mm/memory.c b/mm/memory.c
index 74f95ae0510b..745b3482e6c2 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1394,8 +1394,15 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
*/
if (unlikely(!src)) {
void *kaddr = kmap_atomic(dst, KM_USER0);
- unsigned long left = __copy_from_user_inatomic(kaddr, (void __user *)va, PAGE_SIZE);
- if (left)
+ void __user *uaddr = (void __user *)(va & PAGE_MASK);
+
+ /*
+ * This really shouldn't fail, because the page is there
+ * in the page tables. But it might just be unreadable,
+ * in which case we just give up and fill the result with
+ * zeroes.
+ */
+ if (__copy_from_user_inatomic(kaddr, uaddr, PAGE_SIZE))
memset(kaddr, 0, PAGE_SIZE);
kunmap_atomic(kaddr, KM_USER0);
return;