public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Al Viro <viro@ZenIV.linux.org.uk>, mtk.manpages@gmail.com
Cc: Dmitry Vyukov <dvyukov@google.com>,
	Alexander Potapenko <glider@google.com>,
	Kostya Serebryany <kcc@google.com>,
	Eric Dumazet <edumazet@google.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] [iov_iter] use memmove() when copying to/from user page
Date: Thu, 25 May 2017 19:04:57 +0200	[thread overview]
Message-ID: <20170525170457.GA3085@amd> (raw)
In-Reply-To: <20170516224854.GU390@ZenIV.linux.org.uk>

[-- Attachment #1: Type: text/plain, Size: 1800 bytes --]

Hi!

On Tue 2017-05-16 23:48:54, Al Viro wrote:
> On Tue, May 16, 2017 at 03:15:16PM -0700, Dmitry Vyukov wrote:
> > > Because it's not going to be *one* call of memcpy() or memmove().  It's
> > > one per page.
> > 
> > 
> > I missed that.
> > 
> > I assumed that in the case of sendfile from memfd to memfd data will
> > be copied directly. But it goes through a pipe with multiple buffers.
> > Does not look easily fixable.
> 
> Which leaves us only with "will nasal demons really fly there?".

It seems so:

Date: Tue, 16 May 2017 14:27:34 +0200
From: Alexander Potapenko <glider@google.com>
Subject: [PATCH] [iov_iter] use memmove() when copying to/from user
page

BUG: memcpy-param-overlap in generic_perform_write+0x551/0xa20
__msan_memcpy(ffff88013c6e3001, ffff88013c6e3000, 105)
CPU: 0 PID: 1040 Comm: probe Not tainted 4.11.0-rc5+ #2562
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs
01/01/2011

At the very least, we do not want userland to trigger kernel
BUG()s... so this needs fixes beyond documentation.

> Consider the case of write() from an mmapped piece of file to overlapping
> piece of the same file.  It is possible and not hard to trigger; all we
> can guarantee is the lack of infoleaks, filesystem corruption or memory
> corruption.  File *contents* in the affected area can't be sanely relied
> upon.
> 
> This case is not different.  BTW, neither SUS, nor our manpages for
> write(2) mention these issues with mmap()-created aliases between the
> source and destination.

Added people doing documentation; seems like we have some updates to
do there, too.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2017-05-25 17:05 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-16 12:27 [PATCH] [iov_iter] use memmove() when copying to/from user page Alexander Potapenko
2017-05-16 18:48 ` Al Viro
2017-05-16 18:53   ` Dmitry Vyukov
2017-05-16 19:37     ` Al Viro
2017-05-16 20:10       ` Dmitry Vyukov
2017-05-16 20:52         ` Al Viro
2017-05-16 21:01           ` Dmitry Vyukov
2017-05-16 21:33             ` Al Viro
2017-05-16 22:15               ` Dmitry Vyukov
2017-05-16 22:48                 ` Al Viro
2017-05-25 17:04                   ` Pavel Machek [this message]
2017-05-25 17:15                     ` Eric Dumazet
2017-05-25 21:27                       ` Pavel Machek
2017-05-25 18:22                     ` Al Viro
2017-05-25 19:15                       ` Al Viro

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=20170525170457.GA3085@amd \
    --to=pavel@ucw.cz \
    --cc=dvyukov@google.com \
    --cc=edumazet@google.com \
    --cc=glider@google.com \
    --cc=kcc@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --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