Skip to contentSkip to conversation

include/asm-x86_64/pgtable.h pgd_offset_gate()

PATCH John Blackwood 1 participant 1 message Dec 14, 2004 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Please ignore my previous posting.

It turns out that there is already a fix for this problem by Andi Kleen:

# ChangeSet
# 2004/11/15 19:53:40-08:00 [email protected]
# [PATCH] x86-64: Fix get_user_pages access to vsyscall page
#
# The current kernel oopses on x86-64 when gdb steps into the vsyscall page.
# This patch fixes it.
#

#   I also removed the bogus NULL checks of *_offset and replaced them with
#   proper _none checks.  I made them BUGs because vsyscall pages should be
#   always mapped.
#
#   Signed-off-by: Andi Kleen <[email protected]>
#   Signed-off-by: Andrew Morton <[email protected]>
#   Signed-off-by: Linus Torvalds <[email protected]>
#
# mm/memory.c
#   2004/11/15 19:29:06-08:00 [email protected] +7 -11
#   x86-64: Fix get_user_pages access to vsyscall page
#
diff -Nru a/mm/memory.c b/mm/memory.c
--- a/mm/memory.c       2004-12-14 05:20:10 -08:00
+++ b/mm/memory.c       2004-12-14 05:20:10 -08:00
@@ -739,19 +739,15 @@
                        pte_t *pte;
                        if (write) /* user gate pages are read-only */
                                return i ? : -EFAULT;
-                       pgd = pgd_offset_gate(mm, pg);
-                       if (!pgd)
-                               return i ? : -EFAULT;
+                       if (pg > TASK_SIZE)
+                               pgd = pgd_offset_k(pg);
+                       else
+                               pgd = pgd_offset_gate(mm, pg);
+                       BUG_ON(pgd_none(*pgd));
                        pmd = pmd_offset(pgd, pg);
-                       if (!pmd)
-                               return i ? : -EFAULT;
+                       BUG_ON(pmd_none(*pmd));
                        pte = pte_offset_map(pmd, pg);
-                       if (!pte)
-                               return i ? : -EFAULT;
-                       if (!pte_present(*pte)) {
-                               pte_unmap(pte);
-                               return i ? : -EFAULT;
-                       }
+                       BUG_ON(pte_none(*pte));
                        if (pages) {
                                pages[i] = pte_page(*pte);
                                get_page(pages[i]);