--- zzzz-none-000/linux-3.10.107/arch/x86/lib/usercopy_64.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/arch/x86/lib/usercopy_64.c 2021-02-04 17:41:59.000000000 +0000 @@ -68,22 +68,21 @@ * Since protection fault in copy_from/to_user is not a normal situation, * it is not necessary to optimize tail handling. */ -unsigned long -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest) +__visible unsigned long +copy_user_handle_tail(char *to, char *from, unsigned len) { - char c; - unsigned zero_len; - for (; len; --len, to++) { + char c; + if (__get_user_nocheck(c, from++, sizeof(char))) break; if (__put_user_nocheck(c, to, sizeof(char))) break; } - - for (c = 0, zero_len = len; zerorest && zero_len; --zero_len) - if (__put_user_nocheck(c, to++, sizeof(char))) - break; clac(); + + /* If the destination is a kernel buffer, we always clear the end */ + if (!__addr_ok(to)) + memset(to, 0, len); return len; }