On Thu, Apr 5, 2018 at 7:17 AM, Michael S. Tsirkin <mst@xxxxxxxxxx> wrote: > > I wonder however whether all the following should be changed then: > > static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm, > > ... > > if (!vma || check_vma_flags(vma, gup_flags)) > return i ? : -EFAULT; > > is this a bug in __get_user_pages? Note the difference between "get_user_pages()", and "get_user_pages_fast()". It's the *fast* versions that just return the number of pages pinned. The non-fast ones will return an error code for various cases. Why? The non-fast cases actually *have* various error cases. They can block and get interrupted etc. The fast cases are basically "just get me the pages, dammit, and if you can't get some page, stop". At least that's one excuse for the difference in behavior. The real excuse is probably just "that's how it worked" - the fast case just walked the page tables and that was it. Linus