Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1642827

Re: [PATCH] [iov_iter] use memmove() when copying to/from user page

From Dmitry Vyukov <dvyukov@google.com>
Newsgroups linux.kernel
Subject Re: [PATCH] [iov_iter] use memmove() when copying to/from user page
Date 2017-05-16 23:10 +0200
Message-ID <tHRTc-2nV-13@gated-at.bofh.it> (permalink)
References (1 earlier) <tHPHI-IC-11@gated-at.bofh.it> <tHPRp-M2-51@gated-at.bofh.it> <tHQu6-1gw-17@gated-at.bofh.it> <tHR6O-1Me-21@gated-at.bofh.it> <tHRJv-23G-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, May 16, 2017 at 1:52 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> On Tue, May 16, 2017 at 01:10:56PM -0700, Dmitry Vyukov wrote:
>
>> >         * behaviour of sendfile() in such a case.  And there I've no problem
>> > with saying "contents after operation is undefined".  If you wish to change
>> > that, by all means start with documenting the semantics you want to promise
>> > to userland.
>>
>> I would say it's already documented.
>> sendfile says that it "copies data". memmove says that it "copies
>> data". memcpy says that it "copies data, but data must not overlap".
>> sendfile does not say that "data must not overlap".
>
> In that case your patch does not suffice.  Overlapping move _forwards_ still
> yields unexpected results, doesn't it?

Why? memmove can move both ways. Do we need to change more memcpy's to
memmove's?


>  I'm all for documenting that
> resulting contents is undefined in case of overlap.  The same goes for write()
> from mmap'ed area, BTW.  You suggest changing that undefined behaviour *and*
> either pretending that it's not undefined anymore (obviously false)

Why is it false?

> or
> failing to describe the new cases when it is not undefined anymore.

I would say it just fixes a bug in current impl. Sendfile docs always
said "sendfile() copies data" (without any but's), but we failed to do
this.


> It's not the cost of extra branch; it's ill-defined rules that would need to
> be followed to be able to rely upon the "improvement".

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] [iov_iter] use memmove() when copying to/from user page Alexander Potapenko <glider@google.com> - 2017-05-16 14:30 +0200
  Re: [PATCH] [iov_iter] use memmove() when copying to/from user page Al Viro <viro@ZenIV.linux.org.uk> - 2017-05-16 20:50 +0200
    Re: [PATCH] [iov_iter] use memmove() when copying to/from user page Dmitry Vyukov <dvyukov@google.com> - 2017-05-16 21:00 +0200
      Re: [PATCH] [iov_iter] use memmove() when copying to/from user page Al Viro <viro@ZenIV.linux.org.uk> - 2017-05-16 21:40 +0200
        Re: [PATCH] [iov_iter] use memmove() when copying to/from user page Dmitry Vyukov <dvyukov@google.com> - 2017-05-16 22:20 +0200
          Re: [PATCH] [iov_iter] use memmove() when copying to/from user page Al Viro <viro@ZenIV.linux.org.uk> - 2017-05-16 23:00 +0200
            Re: [PATCH] [iov_iter] use memmove() when copying to/from user page Dmitry Vyukov <dvyukov@google.com> - 2017-05-16 23:10 +0200
              Re: [PATCH] [iov_iter] use memmove() when copying to/from user page Al Viro <viro@ZenIV.linux.org.uk> - 2017-05-16 23:40 +0200
                Re: [PATCH] [iov_iter] use memmove() when copying to/from user page Dmitry Vyukov <dvyukov@google.com> - 2017-05-17 00:20 +0200
                Re: [PATCH] [iov_iter] use memmove() when copying to/from user page Al Viro <viro@ZenIV.linux.org.uk> - 2017-05-17 00:50 +0200

csiph-web