From: Nick Piggin <npiggin@suse.de>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>,
Hugh Dickins <hugh@veritas.com>,
Linux Memory Management <linux-mm@kvack.org>,
Andrew Morton <akpm@osdl.org>, Jes Sorensen <jes@sgi.com>,
Linux Kernel <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: ptrace and pfn mappings
Date: Tue, 10 Oct 2006 05:46:06 +0200 [thread overview]
Message-ID: <20061010034606.GJ15822@wotan.suse.de> (raw)
In-Reply-To: <1160451656.32237.83.camel@localhost.localdomain>
On Tue, Oct 10, 2006 at 01:40:56PM +1000, Benjamin Herrenschmidt wrote:
> On Tue, 2006-10-10 at 04:58 +0200, Nick Piggin wrote:
> > On Tue, Oct 10, 2006 at 12:47:46PM +1000, Benjamin Herrenschmidt wrote:
> > >
> > > > Switch the mm and do a copy_from_user? (rather than the GUP).
> > > > Sounds pretty ugly :P
> > > >
> > > > Can you do a get_user_pfns, and do a copy_from_user on the pfn
> > > > addresses? In other words, is the memory / mmio at the end of a
> > > > given address the same from the perspective of any process? It
> > > > is for physical memory of course, which is why get_user_pages
> > > > works...
> > >
> > > Doesn't help with the racyness.
> >
> > I don't understand what the racyness is that you can solve by accessing
> > it from the target process's mm?
>
> You get a struct page or a pfn, you race with the migration, and access
> something that isn't the "current" one. Doing an actual access goes
> through the normal mmu path which guarantees that after the migration
> has finished its unmap_mapping_ranges(), no access via those old PTEs is
> possible (tlbs have been flushed etc...). We don't get such guarantee if
> we get a struct page or a pfn and go peek at it.
OK, so it is a matter of preventing the migration while this is going on.
BTW. I think you need to disallow get_user_pages to this region entirely,
regardless of whether it is backed by a page or not: there is no guarantee
of when the caller will release the page.
> > > > What if you hold your per-object lock over the operation? (I guess
> > > > it would have to nest *inside* mmap_sem, but that should be OK).
> > >
> > > Over the ptrace operation ? how so ?
> >
> > You just have to hold it over access_process_vm, AFAIKS. Once it
> > is copied into the kernel buffer that's done. Maybe I misunderstood
> > what the race is?
>
> But since when ptrace knows about various private locks of objects that
> are backing vma's ?
Since we decided it would be better to make a new function or some arch
specfic hooks rather than switch mm's in the kernel? ;)
No, I don't know. Your idea might be reasonable, but I really haven't
thought about it much.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2006-10-10 3:46 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-09 16:12 [rfc] 2.6.19-rc1-git5: consolidation of file backed fault handlers Nick Piggin
2006-10-09 16:12 ` [patch 1/5] mm: fault vs invalidate/truncate check Nick Piggin
2006-10-09 16:12 ` [patch 2/5] mm: fault vs invalidate/truncate race fix Nick Piggin
2006-10-09 21:10 ` Mark Fasheh
2006-10-10 1:10 ` Nick Piggin
2006-10-11 18:34 ` Mark Fasheh
2006-10-12 3:28 ` Nick Piggin
2006-10-09 16:12 ` [patch 3/5] mm: fault handler to replace nopage and populate Nick Piggin
2006-10-09 16:12 ` [patch 4/5] mm: add vm_insert_pfn helpler Nick Piggin
2006-10-09 21:03 ` Benjamin Herrenschmidt
2006-10-10 0:42 ` Nick Piggin
2006-10-10 1:11 ` faults and signals Benjamin Herrenschmidt
2006-10-10 1:20 ` Nick Piggin
2006-10-10 1:58 ` Benjamin Herrenschmidt
2006-10-10 2:00 ` Benjamin Herrenschmidt
2006-10-10 2:04 ` Nick Piggin
2006-10-10 2:07 ` Benjamin Herrenschmidt
2006-10-10 1:16 ` ptrace and pfn mappings Benjamin Herrenschmidt
2006-10-10 2:23 ` Nick Piggin
2006-10-10 2:47 ` Benjamin Herrenschmidt
2006-10-10 2:56 ` Benjamin Herrenschmidt
2006-10-10 3:03 ` Nick Piggin
2006-10-10 3:42 ` Benjamin Herrenschmidt
2006-10-10 2:58 ` Nick Piggin
2006-10-10 3:40 ` Benjamin Herrenschmidt
2006-10-10 3:46 ` Nick Piggin [this message]
2006-10-10 4:58 ` Benjamin Herrenschmidt
2006-10-10 12:31 ` Christoph Hellwig
2006-10-10 12:42 ` Benjamin Herrenschmidt
2006-10-10 18:06 ` Hugh Dickins
2006-10-09 16:13 ` [patch 5/5] mm: merge nopfn with fault handler Nick Piggin
2006-10-09 20:57 ` [rfc] 2.6.19-rc1-git5: consolidation of file backed fault handlers Benjamin Herrenschmidt
2006-10-09 21:00 ` Benjamin Herrenschmidt
2006-10-10 0:53 ` Nick Piggin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20061010034606.GJ15822@wotan.suse.de \
--to=npiggin@suse.de \
--cc=akpm@osdl.org \
--cc=benh@kernel.crashing.org \
--cc=hugh@veritas.com \
--cc=jes@sgi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mingo@elte.hu \
--cc=nickpiggin@yahoo.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox