From: Andrew Morton <akpm@osdl.org>
To: Linus Torvalds <torvalds@osdl.org>
Cc: albert@users.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: atomic copy_from_user?
Date: Mon, 22 Dec 2003 01:36:13 -0800 [thread overview]
Message-ID: <20031222013613.7e0741f5.akpm@osdl.org> (raw)
In-Reply-To: <Pine.LNX.4.58.0312212024230.6448@home.osdl.org>
Linus Torvalds <torvalds@osdl.org> wrote:
>
> > From some naughty place in the code where might_sleep
> > would trigger, I'd like to read from user memory.
> > I'll pretty much assume that mlockall() has been
> > called. Suppose that "current" is correct as well.
> > I'd just use a pointer directly, except that:
> >
> > a. it isn't OK for the 4g/4g feature, s390, or sparc64
> > b. it causes the "sparse" type checker to complain
> > c. it will oops or worse if the user screwed up
> >
> > If the page is swapped out, I want a failed copy.
>
> the sequence
>
> local_bh_disable();
> err = get_user(n, ptr);
> local_bh_enable();
> if (!err)
> .. 'n' .. was the value
>
> will do this in 2.6.x, except it will complain loudly about the unatomic
> access. Other than that, it will do what you ask for.
An explicit inc_preempt_count() would be clearer. See how ia32's
kmap_atomic() does it. And filemap_copy_from_user().
next prev parent reply other threads:[~2003-12-22 9:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-22 0:48 atomic copy_from_user? Albert Cahalan
2003-12-22 4:31 ` Linus Torvalds
2003-12-22 9:36 ` Andrew Morton [this message]
2003-12-22 15:00 ` William Lee Irwin III
2003-12-22 18:26 ` Joe Korty
2003-12-22 20:55 ` Rob Love
2003-12-22 21:22 ` Joe Korty
2003-12-22 21:40 ` Rob Love
2003-12-22 21:59 ` Joe Korty
2003-12-22 22:14 ` Rob Love
2003-12-22 22:24 ` Andrew Morton
2003-12-22 22:06 ` Joe Korty
2003-12-22 22:18 ` Rob Love
2003-12-22 22:14 ` Andrew Morton
2003-12-22 22:19 ` Rob Love
2003-12-22 22:35 ` Joe Korty
2003-12-22 22:59 ` Rob Love
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=20031222013613.7e0741f5.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=albert@users.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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