Commit ce57094b authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[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: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 46ce6729
...@@ -739,19 +739,15 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm, ...@@ -739,19 +739,15 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
pte_t *pte; pte_t *pte;
if (write) /* user gate pages are read-only */ if (write) /* user gate pages are read-only */
return i ? : -EFAULT; return i ? : -EFAULT;
pgd = pgd_offset_gate(mm, pg); if (pg > TASK_SIZE)
if (!pgd) pgd = pgd_offset_k(pg);
return i ? : -EFAULT; else
pgd = pgd_offset_gate(mm, pg);
BUG_ON(pgd_none(*pgd));
pmd = pmd_offset(pgd, pg); pmd = pmd_offset(pgd, pg);
if (!pmd) BUG_ON(pmd_none(*pmd));
return i ? : -EFAULT;
pte = pte_offset_map(pmd, pg); pte = pte_offset_map(pmd, pg);
if (!pte) BUG_ON(pte_none(*pte));
return i ? : -EFAULT;
if (!pte_present(*pte)) {
pte_unmap(pte);
return i ? : -EFAULT;
}
if (pages) { if (pages) {
pages[i] = pte_page(*pte); pages[i] = pte_page(*pte);
get_page(pages[i]); get_page(pages[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment