[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200306022915.GW23230@ZenIV.linux.org.uk>
Date: Fri, 6 Mar 2020 02:29:15 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Rasmus Villemoes <linux@...musvillemoes.dk>
Cc: Jann Horn <jannh@...gle.com>,
Alexander Potapenko <glider@...gle.com>,
Joe Perches <joe@...ches.com>, Todd Kjos <tkjos@...gle.com>,
Kees Cook <keescook@...omium.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Arve Hjønnevåg <arve@...roid.com>,
Ingo Molnar <mingo@...hat.com>,
Dmitriy Vyukov <dvyukov@...gle.com>,
"open list:ANDROID DRIVERS" <devel@...verdev.osuosl.org>,
Peter Zijlstra <peterz@...radead.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/3] binder: do not initialize locals passed to
copy_from_user()
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.
Powered by blists - more mailing lists