aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorHugh Dickins <hugh@veritas.com>2005-10-29 21:16:32 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 00:40:41 -0400
commitc34d1b4d165c67b966bca4aba026443d7ff161eb (patch)
tree27ffca9daba2a6b16d29bd508faf3e68bda2aad1 /mm
parentc0718806cf955d5eb51ea77bffb5b21d9bba4972 (diff)
[PATCH] mm: kill check_user_page_readable
check_user_page_readable is a problematic variant of follow_page. It's used only by oprofile's i386 and arm backtrace code, at interrupt time, to establish whether a userspace stackframe is currently readable. This is problematic, because we want to push the page_table_lock down inside follow_page, and later split it; whereas oprofile is doing a spin_trylock on it (in the i386 case, forgotten in the arm case), and needs that to pin perhaps two pages spanned by the stackframe (which might be covered by different locks when we split). I think oprofile is going about this in the wrong way: it doesn't need to know the area is readable (neither i386 nor arm uses read protection of user pages), it doesn't need to pin the memory, it should simply __copy_from_user_inatomic, and see if that succeeds or not. Sorry, but I've not got around to devising the sparse __user annotations for this. Then we can eliminate check_user_page_readable, and return to a single follow_page without the __follow_page variants. Signed-off-by: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/memory.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/mm/memory.c b/mm/memory.c
index 622a4ef5409f..51f7c0a220d4 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -809,8 +809,7 @@ unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address,
809 * Do a quick page-table lookup for a single page. 809 * Do a quick page-table lookup for a single page.
810 * mm->page_table_lock must be held. 810 * mm->page_table_lock must be held.
811 */ 811 */
812static struct page *__follow_page(struct mm_struct *mm, unsigned long address, 812struct page *follow_page(struct mm_struct *mm, unsigned long address, int write)
813 int read, int write, int accessed)
814{ 813{
815 pgd_t *pgd; 814 pgd_t *pgd;
816 pud_t *pud; 815 pud_t *pud;
@@ -846,16 +845,12 @@ static struct page *__follow_page(struct mm_struct *mm, unsigned long address,
846 if (pte_present(pte)) { 845 if (pte_present(pte)) {
847 if (write && !pte_write(pte)) 846 if (write && !pte_write(pte))
848 goto out; 847 goto out;
849 if (read && !pte_read(pte))
850 goto out;
851 pfn = pte_pfn(pte); 848 pfn = pte_pfn(pte);
852 if (pfn_valid(pfn)) { 849 if (pfn_valid(pfn)) {
853 page = pfn_to_page(pfn); 850 page = pfn_to_page(pfn);
854 if (accessed) { 851 if (write && !pte_dirty(pte) &&!PageDirty(page))
855 if (write && !pte_dirty(pte) &&!PageDirty(page)) 852 set_page_dirty(page);
856 set_page_dirty(page); 853 mark_page_accessed(page);
857 mark_page_accessed(page);
858 }
859 return page; 854 return page;
860 } 855 }
861 } 856 }
@@ -864,22 +859,6 @@ out:
864 return NULL; 859 return NULL;
865} 860}
866 861
867inline struct page *
868follow_page(struct mm_struct *mm, unsigned long address, int write)
869{
870 return __follow_page(mm, address, 0, write, 1);
871}
872
873/*
874 * check_user_page_readable() can be called frm niterrupt context by oprofile,
875 * so we need to avoid taking any non-irq-safe locks
876 */
877int check_user_page_readable(struct mm_struct *mm, unsigned long address)
878{
879 return __follow_page(mm, address, 1, 0, 0) != NULL;
880}
881EXPORT_SYMBOL(check_user_page_readable);
882
883static inline int 862static inline int
884untouched_anonymous_page(struct mm_struct* mm, struct vm_area_struct *vma, 863untouched_anonymous_page(struct mm_struct* mm, struct vm_area_struct *vma,
885 unsigned long address) 864 unsigned long address)