From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938873AbdEYV1T (ORCPT ); Thu, 25 May 2017 17:27:19 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:47772 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751099AbdEYV1R (ORCPT ); Thu, 25 May 2017 17:27:17 -0400 Date: Thu, 25 May 2017 23:27:15 +0200 From: Pavel Machek To: Eric Dumazet Cc: Al Viro , mtk.manpages@gmail.com, Dmitry Vyukov , Alexander Potapenko , Kostya Serebryany , LKML Subject: Re: [PATCH] [iov_iter] use memmove() when copying to/from user page Message-ID: <20170525212715.GA23446@amd> References: <20170516193750.GR390@ZenIV.linux.org.uk> <20170516205212.GS390@ZenIV.linux.org.uk> <20170516213347.GT390@ZenIV.linux.org.uk> <20170516224854.GU390@ZenIV.linux.org.uk> <20170525170457.GA3085@amd> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PNTmBPCT7hxwcZjr" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu 2017-05-25 10:15:11, Eric Dumazet wrote: > On Thu, May 25, 2017 at 10:04 AM, Pavel Machek wrote: > > 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 > > 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. >=20 > To be fair, this BUG() only happens because Alexander added one in memcpy= () , > testing for the cases where memmove() should have been used. >=20 > Kind of a debugging trap if you prefer. >=20 > This is not something that a pristine kernel would do. Aha, so BUG() is not realy a problem. Problem is that memcpy() may not be called on overlapping regions, and may do something stupid; but we don't have evidence that it does. Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --PNTmBPCT7hxwcZjr Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlknTDMACgkQMOfwapXb+vIrfwCgq2VnK7vfpwDIl/Y+7aQ9dPaB 82AAn37h0q+TQmp2M8flXWsQb7Zqq18K =b0df -----END PGP SIGNATURE----- --PNTmBPCT7hxwcZjr--