From: Kris Van Hees Date: Mon, 27 Feb 2017 15:39:07 +0000 (-0500) Subject: dtrace: ensure DTrace can use get_user_pages safely X-Git-Tag: v4.1.12-98.0.20170517_2143~41^2~3 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d35f166d01a32ae3579b9c44b6cb62bdff0b257b;p=users%2Fjedix%2Flinux-maple.git dtrace: ensure DTrace can use get_user_pages safely The processing of the DTrace-specific FOLL_IMMED flag was not robust enough. We could still get into a situation where cond_resched() was called (which is bad) or where the VMA area would get extended (which is also bad). The only code that passes this flag is DTrace support code, and when the flag is not passed, the execution flow is not at all affected. Orabug: 25640153 Signed-off-by: Kris Van Hees Reviewed-by: Chuck Anderson Reviewed-by: Nick Alcock Reviewed-by: Tomas Jedlicka --- diff --git a/mm/gup.c b/mm/gup.c index 50f624a0d5e6..6f937dd4e98c 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -458,7 +458,12 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, /* first iteration or cross vma bound */ if (!vma || start >= vma->vm_end) { - vma = find_extend_vma(mm, start); + /* Do not extend stack in no-fault mode. */ + if (gup_flags & FOLL_IMMED) + vma = find_vma(mm, start); + else + vma = find_extend_vma(mm, start); + if (!vma && in_gate_area(mm, start)) { int ret; ret = get_gate_page(mm, start & PAGE_MASK, @@ -486,7 +491,8 @@ retry: */ if (unlikely(fatal_signal_pending(current))) return i ? i : -ERESTARTSYS; - cond_resched(); + if (likely(!(foll_flags & FOLL_IMMED))) + cond_resched(); page = follow_page_mask(vma, start, foll_flags, &page_mask); if (!page) { int ret;