How does __user works?
bernd at petrovitsch.priv.at
Mon Jan 21 07:06:13 EST 2013
On Sam, 2013-01-19 at 17:34 +0100, Grzegorz Dwornicki wrote:
> How does __user macro works? I know it is defined in
> include/linux/compiler.h as:
> # define __user. __attribute__((noderef, address_space(1)))
> I could write thesse macros defs too but my real problem is: what does this
> stuff do? Some functions use this macro and other does not. For example
> compat_do_execve (from include/linux/comtap.h) use normal pointer named
> filename and second pointer named argv as __user pointer. Why does argv
> needs __user but filename not?
In the kernel, some memory is the user-space memory (which can be
swapped out and - therefore - shouldn't dereferenced directly) and some
of it is kernel-space memory (which is always in real RAM).
That macro tells static checkers in which of those the pointer points to
so that errors are compile-time visible.
Bernd Petrovitsch Email : bernd at petrovitsch.priv.at
LUGA : http://www.luga.at
More information about the Kernelnewbies