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. _______________________________________________ devel mailing list de...@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel