Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1317142

Re: [PATCH] mm, gup: introduce concept of "foreign" get_user_pages()

From Oleg Nesterov <oleg@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH] mm, gup: introduce concept of "foreign" get_user_pages()
Date 2016-01-25 19:20 +0100
Message-ID <qUTU5-7YI-9@gated-at.bofh.it> (permalink)
References <qTOjM-7K8-7@gated-at.bofh.it> <qUPdM-4ol-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 01/25, Srikar Dronamraju wrote:
>
> > The uprobes is_trap_at_addr() location holds mmap_sem and
> > calls get_user_pages(current->mm) on an instruction address.  This
> > makes it a pretty unique gup caller.

Yes, in particular is_trap_at_addr() doesn't look really nice. But we need
to read the insn under mmap_sem to avoid the race with unregister + register
at the same address, so that we won't send the wrong SIGTRAP in this case.

> Changes for uprobes.c looks good to me.
> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>

Agreed, the changes in uprobes.c look fine.


> > @@ -1700,7 +1700,13 @@ static int is_trap_at_addr(struct mm_str
> >  	if (likely(result == 0))
> >  		goto out;
> >
> > -	result = get_user_pages(NULL, mm, vaddr, 1, 0, 1, &page, NULL);
> > +	/*
> > +	 * The NULL 'tsk' here ensures that any faults that occur here
> > +	 * will not be accounted to the task.  'mm' *is* current->mm,
> > +	 * but we treat this as a 'foreign' access since it is
> > +	 * essentially a kernel access to the memory.
> > +	 */
> > +	result = get_user_pages_foreign(NULL, mm, vaddr, 1, 0, 1, &page, NULL);
> >  	if (result < 0)
> >  		return result;

Yes, but perhaps we should simply remove this get_user_pages_foreign() and just
return -EFAULT if copy_from_user_inatomic() fails. This should be very unlikely
case, I think it would be fine to restart this insn and take another bp hit to
fault this page in.

Srikar what do you think? IIRC, this get_user_pages() was needed before, when
is_trap_at_addr() had other (non-restartable) callers with mm != current->mm.

But again, I think this patch is fine, we can do this later.

Oleg.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] mm, gup: introduce concept of "foreign" get_user_pages() Dave Hansen <dave@sr71.net> - 2016-01-22 19:10 +0100
  Re: [PATCH] mm, gup: introduce concept of "foreign" get_user_pages() Srikar Dronamraju <srikar@linux.vnet.ibm.com> - 2016-01-25 14:20 +0100
    Re: [PATCH] mm, gup: introduce concept of "foreign" get_user_pages() Oleg Nesterov <oleg@redhat.com> - 2016-01-25 19:20 +0100
  Re: [PATCH] mm, gup: introduce concept of "foreign" get_user_pages() Vlastimil Babka <vbabka@suse.cz> - 2016-01-27 12:40 +0100

csiph-web