lkml.org 
[lkml]   [1999]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Problem with get_user(), put_user() functions...
From
Date
bishop@sekure.org (Augusto Cesar Radtke) writes:

> On Wed, 7 Jul 1999, Grigory Lyahovitsky wrote:
>
> > Hello!
> >
> > I have taken the example code of interaction (data transfering) between user
> > and kernel space through /proc filesystem at:
> >
> > http://metalab.unc.edu/LDP/LDP/lkmpg/node17.html
> >
> > But, it failed to run on my linux (kernel 2.2.3) when I done 'insmod procfs.o'
> > with next errors:
> >
> > procfs.o: unresolved symbol __put_user_X
> > procfs.o: unresolved symbol __get_user_X
> >
>
> Sometime ago with a personal thread with Linus, he says to me that the
> functions put_user and get_user should never be used, except when you know
> what really are you doing, these functions doesn't have a range check and
> you need to use a verify_area() before. So use the new 2.2.x
> copy_from_user and copy_to_user, examples of utilization can be found at
> http://www.atnf.csiro.au/~rgooch/linux/docs/porting-to-2.2.html

You must be confusing it with 2.0 {put,get}_user or with 2.2 __get/__put_user.
There it was/is true.

2.2 *_user all do full
memory verification. What doesn't are the __ variants (__get_user, __put_user
etc.). They do exception handling for invalid user pages, but don't check
if the destination or source is a kernel address. So only use them when
when you checked the range earlier with another *_user or a verify_area.

get_user(bla, ptr) is equivalent (but slightly more efficient) to
copy_from_user(&bla, ptr, sizeof(bla)). Similar for put_user/copy_to_user.

-Andi

P.S.: I'm thinking about writing some section 9 pages for the basic stable
functions of the kernel to clear such myths in future. Mostly only for the
basic kernel infrastructure (e.g. locks, user access, interrupts), not for
the evolving parts.

--
This is like TV. I don't like TV.

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

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:0.101 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site