Re: [PATCH 06/64] mm: teach pagefault paths about range locking

From: Davidlohr Bueso
Date: Tue Feb 06 2018 - 13:42:21 EST


On Mon, 05 Feb 2018, Laurent Dufour wrote:

--- a/drivers/misc/sgi-gru/grufault.c
+++ b/drivers/misc/sgi-gru/grufault.c
@@ -189,7 +189,8 @@ static void get_clear_fault_map(struct gru_state *gru,
*/
static int non_atomic_pte_lookup(struct vm_area_struct *vma,
unsigned long vaddr, int write,
- unsigned long *paddr, int *pageshift)
+ unsigned long *paddr, int *pageshift,
+ struct range_lock *mmrange)
{
struct page *page;

@@ -198,7 +199,8 @@ static int non_atomic_pte_lookup(struct vm_area_struct *vma,
#else
*pageshift = PAGE_SHIFT;
#endif
- if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0, &page, NULL) <= 0)
+ if (get_user_pages(vaddr, 1, write ? FOLL_WRITE : 0,
+ &page, NULL, mmrange) <= 0)

There is no need to pass down the range here since underlying called
__get_user_pages_locked() is told to not unlock the mmap_sem.
In general get_user_pages() doesn't need a range parameter.

Yeah, you're right. At least it was a productive exercise for auditing.

Thanks,
Davidlohr