kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: bernd@petrovitsch.priv.at (Bernd Petrovitsch)
To: kernelnewbies@lists.kernelnewbies.org
Subject: How does __user works?
Date: Mon, 21 Jan 2013 13:06:13 +0100	[thread overview]
Message-ID: <1358769974.1284.88.camel@thorin> (raw)
In-Reply-To: <CAOP-CUcza2A8+mBU-t56+iBRcudDj07iO_i0nRWL3UDHTgsUXQ@mail.gmail.com>

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
-- 
Bernd Petrovitsch                  Email : bernd at petrovitsch.priv.at
                     LUGA : http://www.luga.at

      parent reply	other threads:[~2013-01-21 12:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-19 16:34 How does __user works? Grzegorz Dwornicki
2013-01-19 20:41 ` Valdis.Kletnieks at vt.edu
2013-01-21 12:06 ` Bernd Petrovitsch [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358769974.1284.88.camel@thorin \
    --to=bernd@petrovitsch.priv.at \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).