Re: [RFC] raw_copy_from_user() semantics

From: Linus Torvalds
Date: Sun Jul 19 2020 - 15:28:36 EST


On Sat, Jul 18, 2020 at 8:17 PM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>
> So any byte-squeezing loop of that sort would break on a bunch
> of architectures.

I think we should try to get rid of the exact semantics.

If "copy_from/to_user()" takes a fault because it does a
larger-than-byte access (and with unrolling, it could be a _lot_
larger than one byte: x86 dcurrently has that "generic" case that
isn't used very much, but it unrolls 8-byte accesses 8 times, so it
does a 64-byte block that we could just say "if any fo those didn't
work, then you're done), then the copy failed. The exact number of
bytes we _could_ have copied is not important.

So we could simplify the x86 end condition too and remove all the
"handle_tail" complexity.

Linus

(*) Yes, it aligns things to 64-byte boundaries too, but only for the
write side, not the read side.