On Sunday 13 February 2005 08:51 pm, Athul Acharya wrote: > On Sun, 13 Feb 2005 08:21:52 -0500, Arjan van de Ven > > <arjan@xxxxxxxxxxxxx> wrote: > > you are supposed to *KNOW* that. with access_ok() you can verify if it's > > a valid userspace address. That does not guarantee that it wouldn't also > > be a valid kernel space address as well.... > > OK. I may not be understanding you completely here, because I still > don't understand how when I have a syscall with the following > signature: > > asmlinkage long foo(struct bar *bar1) > > I could "know" that *bar1 points to a memory location that the user > can definitely access. Is it acceptable to just use access_ok() and > hope for the best? Or am I upposed to allocate my own struct bar* and > use copy_to_user() when I'm done? > The latter is correct. copy_to_user/copy_from_user will return a non-zero value if an invalid access is detected, and usually you will then exit the system call with -EFAULT, doing any necessary cleanups first. For more information, see http://www.xml.com/ldd/chapter/book/ch03.html#t8 tavi -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/