linux-stable/arch
Linus Torvalds e1f2750edc x86: remove 'zerorest' argument from __copy_user_nocache()
Every caller passes in zero, meaning they don't want any partial copy to
zero the remainder of the destination buffer.

Which is just as well, because the implementation of that function
didn't actually even look at that argument, and wasn't even aware it
existed, although some misleading comments did mention it still.

The 'zerorest' thing is a historical artifact of how "copy_from_user()"
worked, in that it would zero the rest of the kernel buffer that it
copied into.

That zeroing still exists, but it's long since been moved to generic
code, and the raw architecture-specific code doesn't do it.  See
_copy_from_user() in lib/usercopy.c for this all.

However, while __copy_user_nocache() shares some history and superficial
other similarities with copy_from_user(), it is in many ways also very
different.

In particular, while the code makes it *look* similar to the generic
user copy functions that can copy both to and from user space, and take
faults on both reads and writes as a result, __copy_user_nocache() does
no such thing at all.

__copy_user_nocache() always copies to kernel space, and will never take
a page fault on the destination.  What *can* happen, though, is that the
non-temporal stores take a machine check because one of the use cases is
for writing to stable memory, and any memory errors would then take
synchronous faults.

So __copy_user_nocache() does look a lot like copy_from_user(), but has
faulting behavior that is more akin to our old copy_in_user() (which no
longer exists, but copied from user space to user space and could fault
on both source and destination).

And it very much does not have the "zero the end of the destination
buffer", since a problem with the destination buffer is very possibly
the very source of the partial copy.

So this whole thing was just a confusing historical artifact from having
shared some code with a completely different function with completely
different use cases.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2023-04-19 19:09:52 -07:00
..
alpha alpha: fix lazy-FPU mis(merged/applied/whatnot) 2023-03-06 20:13:49 -05:00
arc
arm ARM: SoC fixes for 6.3, part 2 2023-03-24 15:38:13 -07:00
arm64 Including fixes from bpf, and bluetooth. 2023-04-13 15:33:04 -07:00
csky
hexagon VM_FAULT_RETRY fixes 2023-03-05 11:07:58 -08:00
ia64 cpumask: re-introduce constant-sized cpumask optimizations 2023-03-05 14:30:34 -08:00
loongarch LoongArch, bpf: Fix jit to skip speculation barrier opcode 2023-03-28 10:34:52 +02:00
m68k m68k: Only force 030 bus error if PC not in exception table 2023-03-06 14:09:42 +01:00
microblaze VM_FAULT_RETRY fixes 2023-03-05 11:07:58 -08:00
mips mips: bmips: BCM6358: disable RAC flush for TP1 2023-03-18 14:36:06 +01:00
nios2 VM_FAULT_RETRY fixes 2023-03-05 11:07:58 -08:00
openrisc VM_FAULT_RETRY fixes 2023-03-05 11:07:58 -08:00
parisc VM_FAULT_RETRY fixes 2023-03-05 11:07:58 -08:00
powerpc powerpc fixes for 6.3 #5 2023-04-16 09:55:18 -07:00
riscv Kbuild fixes for v6.3 (3rd) 2023-04-16 09:46:32 -07:00
s390 PPC: 2023-04-04 11:29:37 -07:00
sh sh: sanitize the flags on sigreturn 2023-03-09 10:01:59 -08:00
sparc VM_FAULT_RETRY fixes 2023-03-05 11:07:58 -08:00
um This pull request contains the following changes for UML: 2023-03-01 09:13:00 -08:00
x86 x86: remove 'zerorest' argument from __copy_user_nocache() 2023-04-19 19:09:52 -07:00
xtensa xtensa: fix KASAN report for show_stack 2023-03-17 16:44:28 -07:00
.gitignore
Kconfig