public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Bron Gondwana <brong@fastmail.fm>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Nick Piggin <npiggin@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>,
	Rob Mueller <robm@fastmail.fm>, Ingo Molnar <mingo@elte.hu>
Subject: Re: BUG: mmapfile/writev spurious zero bytes (x86_64/not i386,	bisected, reproducable)
Date: Tue, 17 Jun 2008 23:42:03 +0200	[thread overview]
Message-ID: <48582FAB.1020402@firstfloor.org> (raw)
In-Reply-To: <20080617213618.GL28946@ZenIV.linux.org.uk>

Al Viro wrote:
> On Tue, Jun 17, 2008 at 02:24:39PM -0700, Linus Torvalds wrote:
> 
>> The whole *and*only* reason for copy_to/from_user() existing AT ALL is 
>> exactly the fact that the source or destination access can fault. 
> 
> Erm...  The reason for copy_to_user() existing is that dereferencing
> a user-supplied address in the kernel does not have to access any
> memory reachable in user mode, regardless of any faults. 

Well on x86 it is reachable, so it only handles faults.

> WTF are you
> guys talking about?

Linus seems to think that copy_to_user() should have
copy_in_user semantics(). It happens to be in some cases (when string instructions
are used), but not for the unrolled case.

What seems also confusing him is that x86-64 copy_from/to_user use a shared
subfunction. The trick that this subfunction uses is to assume that
either the destination faults or the source, but never both. It's legal
because the caller should never pass in a faulting source for copy to
or a faulting destination for copy from.

Actually they handle it, but the return value is not correct.

Now he "fixed" copy_to_user to return a kind of correct return value
for source faults, but it'll of course break copy_from_user()'s return value.

It's still unclear why his patch fixes the test case. The caller should
be using copy_in_user perhaps? Or is it just buggy by passing something
unmapped to copy_to_user?

-Andi


  reply	other threads:[~2008-06-17 21:42 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-17  6:00 BUG: mmapfile/writev spurious zero bytes (x86_64/not i386, bisected, reproducable) Bron Gondwana
2008-06-17  6:02 ` Bron Gondwana
2008-06-17 17:08   ` Linus Torvalds
2008-06-17 17:45     ` Linus Torvalds
2008-06-17 20:16       ` Linus Torvalds
2008-06-17 20:41         ` Linus Torvalds
2008-06-17 21:06           ` Linus Torvalds
2008-06-17 21:16             ` Andi Kleen
2008-06-17 21:24               ` Linus Torvalds
2008-06-17 21:30                 ` Andi Kleen
2008-06-17 21:37                   ` Linus Torvalds
2008-06-17 21:36                 ` Al Viro
2008-06-17 21:42                   ` Andi Kleen [this message]
2008-06-17 21:49                     ` Linus Torvalds
2008-06-17 22:11                     ` Al Viro
2008-06-17 22:21                       ` Andi Kleen
2008-06-18  6:22                         ` Nick Piggin
2008-06-17 21:20             ` Linus Torvalds
2008-06-18  2:27               ` Bron Gondwana
2008-06-18  3:14               ` Bron Gondwana
2008-06-18  4:03                 ` Linus Torvalds
2008-06-18  5:11                   ` Cyrus mmap vs lseek/write usage - (WAS: BUG: mmapfile/writev spurious zero bytes (x86_64/not i386, bisected, reproducable)) Bron Gondwana
2008-06-18 16:22                     ` Linus Torvalds
2008-06-18 23:45                       ` Robert Mueller
2008-06-19  0:20                         ` Linus Torvalds
2008-10-03 11:44               ` BUG: mmapfile/writev spurious zero bytes still in the wild Bron Gondwana
2008-10-03 13:07                 ` Andrew Morton
2008-10-04  0:13                   ` Bron Gondwana
2008-06-17 21:15           ` BUG: mmapfile/writev spurious zero bytes (x86_64/not i386, bisected, reproducable) Andi Kleen
2008-06-17 20:58         ` Andi Kleen
2008-06-17 21:14           ` Linus Torvalds
2008-06-17 21:26             ` Andi Kleen
2008-06-17 21:31               ` Linus Torvalds
2008-06-17 21:34                 ` Linus Torvalds
2008-06-17 21:34                 ` Andi Kleen
2008-06-17 21:46                   ` Linus Torvalds
2008-06-18  6:10                     ` Nick Piggin
2008-06-18  2:21     ` Bron Gondwana

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=48582FAB.1020402@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=akpm@linux-foundation.org \
    --cc=brong@fastmail.fm \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=npiggin@suse.de \
    --cc=robm@fastmail.fm \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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