All of lore.kernel.org
 help / color / mirror / Atom feed
* get_user_pages question
@ 2009-11-09  6:50 Mark Veltzer
  2009-11-09  9:31 ` Andi Kleen
  0 siblings, 1 reply; 13+ messages in thread
From: Mark Veltzer @ 2009-11-09  6:50 UTC (permalink / raw)
  To: linux-kernel

Hello all!

I have searched the list for similar issues and have not found an answer so I 
am posting.

I am using 'get_user_pages' and friends to get a hold of user memory in kernel 
space. User space passes buffer to kernel, kernel does get_user_pages, holds 
them for some time while user space is doing something else, writes to the 
pages and then releases them (SetPageDirty and page_cache_release as per LDD 
3rd edition). So far so good. 

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.

My not so intelligent questions (they may well be off the mark):
- How can this be? (two views of the same page)
- Does not 'get_user_pages' pin the pages?
- Could this be due to stack protection of some sort?
- Do I need to do anything extra with the vm_area I receive for the stack 
pages EXCEPT 'get_user_pages' ?

I know this is not an orthodox method to write a driver and I better use mmap 
for these things but I have other constrains in this driver design that I do 
not want to bore you with. I am also awara that passing a buffer on stack and 
letting user space continue running is a very dangerous thing to do for user 
space (or kernel space) integrity. I wish I could do it another way...

The platform is x86 32 bit standad with standard kernels and headers 
distributed with ubuntu 9.04 and 9.10 which are 2.6.28 and 2.6.31.

Please reply to my email as well as I am not a subscriber.

Cheers,
	Mark

^ permalink raw reply	[flat|nested] 13+ messages in thread
* get_user_pages question
@ 2004-05-01 11:12 Eli Cohen
  2004-05-01 11:32 ` Arjan van de Ven
  0 siblings, 1 reply; 13+ messages in thread
From: Eli Cohen @ 2004-05-01 11:12 UTC (permalink / raw)
  To: linux-kernel

Hi,
I have been tryin to use get_user_pages() on malloced memory and get the 
list of pages but it does not work as
I expected:
1. malloc a buffer in user space
2. issue ioctl, invoke get_user_pages() and save the page descriptors I 
obtained.
3. at a later time, issue another ioctl, invoke get_user_pages() again 
and save another copy of the page descriptors.
4. Compare the two lists of page descriptors. They're not all the same.

Apparently some pages were discarded and the subsequent page fault 
brought a new page. I expected the original page to be in the swap cache 
and get the old page again. I repeated the experiment but before the 
first ioctl I wrote something to all the pages but got the same results. 
I used 2.4.21-4 (RH AS 3.0).

Can anyone clarify?
thanks
Eli

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-11-30 16:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-09  6:50 get_user_pages question Mark Veltzer
2009-11-09  9:31 ` Andi Kleen
2009-11-09 10:32   ` Hugh Dickins
2009-11-09 22:13     ` Mark Veltzer
2009-11-10 16:33       ` Hugh Dickins
2009-11-28 18:50         ` Andrea Arcangeli
2009-11-28 22:22           ` Mark Veltzer
2009-11-30 12:01             ` Nick Piggin
2009-11-30 16:12               ` Andrea Arcangeli
2009-11-30 11:54           ` Nick Piggin
  -- strict thread matches above, loose matches on Subject: below --
2004-05-01 11:12 Eli Cohen
2004-05-01 11:32 ` Arjan van de Ven
2004-05-01 11:41   ` Eli Cohen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.