Re: get_user_pages question

From: Hugh Dickins
Date: Mon Nov 09 2009 - 05:33:11 EST


On Mon, 9 Nov 2009, Andi Kleen wrote:
> Mark Veltzer <mark.veltzer@xxxxxxxxx> writes:
> >
> > I am testing this kernel module with several buffers from user space allocated
> > in several different ways. heap, data segment, static variable in function and
> > stack. All scenarious work EXCEPT the stack one. When passing the stack buffer
> > the kernel sees one thing while user space sees another.
>
> In theory it should work, stack is no different from any other pages.
> First thought was that you used some platform with incoherent caches,
> but that doesn't seem to be the case if it's standard x86.

It may be irrelevant to Mark's stack case, but it is worth mentioning
the fork problem: how a process does get_user_pages to pin down a buffer
somewhere in anonymous memory, a thread forks (write protecting anonymous
memory shared between parent and child), child userspace writes to a
location in the same page as that buffer, causing copy-on-write which
breaks the connection between the get_user_pages buffer and what child
userspace sees there afterwards.

Hugh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/