From: Al Viro <viro@zeniv.linux.org.uk>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: "Jann Horn" <jannh@google.com>,
"Alexander Potapenko" <glider@google.com>,
"Joe Perches" <joe@perches.com>, "Todd Kjos" <tkjos@google.com>,
"Kees Cook" <keescook@chromium.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Ingo Molnar" <mingo@redhat.com>,
"Dmitriy Vyukov" <dvyukov@google.com>,
"open list:ANDROID DRIVERS" <devel@driverdev.osuosl.org>,
"Peter Zijlstra" <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] binder: do not initialize locals passed to copy_from_user()
Date: Fri, 6 Mar 2020 02:29:15 +0000 [thread overview]
Message-ID: <20200306022915.GW23230@ZenIV.linux.org.uk> (raw)
In-Reply-To: <205aa3d8-7d18-1b73-4650-5ef534fe55da@rasmusvillemoes.dk>
On Thu, Mar 05, 2020 at 10:03:25AM +0100, Rasmus Villemoes wrote:
> Does copy_from_user guarantee to zero-initialize the remaining buffer if
> copying fails partway through?
That's guaranteed, short of raw_copy_from_user() being completely broken.
What raw_copy_from_user() implementation must guarantee is that if
raw_copy_from_user(to, from, N) returns N - n, then
* 0 <= n <= N
* all attempted reads had been within the range [from .. from + N - 1]
* all stores had been to the range [to .. to + n - 1] and every byte
within that range had been overwritten
* for all k in [0 .. n - 1], the value stored at to[k] by the end of
the call is equal to the value that would've been possible to read from
from[k] at some point during the call. In particular, for all bytes in
range [from .. from + n - 1] there had been a successful read of some
object containing that byte.
* if everything in [from .. from + N - 1] is readable, the call
will copy the entire range into [to .. to + N - 1] and return 0.
Provided that, copy_from_user() will leave no uninitialized data in
destination object in any case, success or no success.
next prev parent reply other threads:[~2020-03-06 2:29 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-02 13:04 [PATCH v2 1/3] compiler.h: define __no_initialize glider
2020-03-02 13:04 ` [PATCH v2 2/3] binder: do not initialize locals passed to copy_from_user() glider
2020-03-02 13:09 ` Joe Perches
2020-03-02 13:25 ` Alexander Potapenko
2020-03-02 13:52 ` Dan Carpenter
2020-03-02 13:58 ` Joe Perches
2020-03-02 18:17 ` Alexander Potapenko
2020-03-02 18:31 ` Jann Horn
2020-03-05 9:03 ` Rasmus Villemoes
2020-03-05 12:45 ` Jann Horn
2020-03-06 2:29 ` Al Viro [this message]
2020-03-02 18:50 ` Joe Perches
2020-03-03 9:14 ` Alexander Potapenko
2020-03-03 9:38 ` Dan Carpenter
2020-03-03 13:56 ` Joe Perches
2020-03-03 14:15 ` Dan Carpenter
2020-03-04 18:13 ` Kees Cook
2020-03-05 8:07 ` Dan Carpenter
2020-03-05 8:26 ` Kees Cook
2020-03-05 8:33 ` Alexander Potapenko
2020-03-02 17:38 ` Greg KH
2020-03-02 18:28 ` Alexander Potapenko
2020-03-02 13:04 ` [PATCH v2 3/3] sched/wait: avoid double initialization in ___wait_event() glider
2020-03-02 16:56 ` Todd Kjos
2020-03-02 18:03 ` Alexander Potapenko
2020-03-02 18:39 ` Greg Kroah-Hartman
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=20200306022915.GW23230@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=arve@android.com \
--cc=devel@driverdev.osuosl.org \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=jannh@google.com \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tkjos@google.com \
/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