From: Vitaly Mayatskikh <v.mayatskih@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Vitaly Mayatskikh <v.mayatskih@gmail.com>,
linux-kernel@vger.kernel.org, Andi Kleen <andi@firstfloor.org>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] x86: Optimize tail handling for copy_user
Date: Sat, 02 Aug 2008 00:53:32 +0200 [thread overview]
Message-ID: <m3sktol53n.fsf@gravicappa.englab.brq.redhat.com> (raw)
In-Reply-To: <alpine.LFD.1.10.0808011524150.6819@nehalem.linux-foundation.org> (Linus Torvalds's message of "Fri, 1 Aug 2008 15:30:26 -0700 (PDT)")
Linus Torvalds <torvalds@linux-foundation.org> writes:
> I was actually thinking more along the lines of actually doing a
> test-suite with the few most relevant system calls (to catch the few cases
> that matter), and judicious use of mmap/munmap to make sure to trigger it
> in-kernel.
Well, my test is a kernel module (with help of systemtap). It tests
copy_from_user, copy_to_user, copy_user_generic_unrolled,
copy_user_generic_string and __copy_user_nocache directly. Test
allocates a page in kernel space and uses a page in user space (this is
for range checks in copy_from/to_user) and tries to make a fault in
every possible place of these routines. I don't know how to get a
userspace page from kernel module easily, and did a dirty hack with
available pages and sys_mprotect. However, it works.
> It probably doesn't really need all that many system calls to trigger all
> the relevant paths. A "read()" should trigger the "to_user()" case, and a
> write() to a file should trigger the 'from_user_nocache()" case. And while
> the "from_user()" case with zeroing migth be harder to see (because all
> _normal_ users should also look at the error case and return EFAULT), I
> think there are a few cases where we just depend on the zeroing.
I found it hard to do a good testing for copy_user from user space
program and have used systemtap.
> Doing a
>
> git grep ' copy_from_user('
>
> (that's a tab in that grep thing) shows at least the termios code doing
> it, for example. But fewer cases than I expected.
>
> Linus
It might be a good idea to find such potentially faulty places.
--
wbr, Vitaly
next prev parent reply other threads:[~2008-08-01 22:53 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-28 14:10 Vitaly Mayatskikh
2008-07-28 15:48 ` Linus Torvalds
2008-07-29 15:24 ` Vitaly Mayatskikh
2008-07-30 12:02 ` Vitaly Mayatskikh
2008-07-30 17:29 ` Linus Torvalds
2008-07-31 14:27 ` Vitaly Mayatskikh
2008-08-01 20:10 ` Linus Torvalds
2008-08-01 22:04 ` Vitaly Mayatskikh
2008-08-01 22:30 ` Linus Torvalds
2008-08-01 22:53 ` Vitaly Mayatskikh [this message]
2008-07-30 12:07 ` Vitaly Mayatskikh
2008-07-30 12:13 ` Vitaly Mayatskikh
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=m3sktol53n.fsf@gravicappa.englab.brq.redhat.com \
--to=v.mayatskih@gmail.com \
--cc=andi@firstfloor.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®