linux-stable/include
Dave Hansen 74e19ef0ff uaccess: Add speculation barrier to copy_from_user()
The results of "access_ok()" can be mis-speculated.  The result is that
you can end speculatively:

	if (access_ok(from, size))
		// Right here

even for bad from/size combinations.  On first glance, it would be ideal
to just add a speculation barrier to "access_ok()" so that its results
can never be mis-speculated.

But there are lots of system calls just doing access_ok() via
"copy_to_user()" and friends (example: fstat() and friends).  Those are
generally not problematic because they do not _consume_ data from
userspace other than the pointer.  They are also very quick and common
system calls that should not be needlessly slowed down.

"copy_from_user()" on the other hand uses a user-controller pointer and
is frequently followed up with code that might affect caches.  Take
something like this:

	if (!copy_from_user(&kernelvar, uptr, size))
		do_something_with(kernelvar);

If userspace passes in an evil 'uptr' that *actually* points to a kernel
addresses, and then do_something_with() has cache (or other)
side-effects, it could allow userspace to infer kernel data values.

Add a barrier to the common copy_from_user() code to prevent
mis-speculated values which happen after the copy.

Also add a stub for architectures that do not define barrier_nospec().
This makes the macro usable in generic code.

Since the barrier is now usable in generic code, the x86 #ifdef in the
BPF code can also go away.

Reported-by: Jordy Zomer <jordyzomer@google.com>
Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>   # BPF bits
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2023-02-21 14:45:22 -08:00
..
acpi ACPI updates for 6.3-rc1 2023-02-21 12:23:24 -08:00
asm-generic Scheduler updates in this cycle are: 2023-02-20 17:41:08 -08:00
clocksource
crypto
drm drm/client: fix circular reference counting issue 2023-02-07 09:42:56 +01:00
dt-bindings Thermal control updates for 6.3-rc1 2023-02-21 12:32:05 -08:00
keys
kunit kunit: fix kunit_test_init_section_suites(...) 2023-01-31 09:10:38 -07:00
kvm KVM: arm64: Add helper vgic_write_guest_lock() 2023-01-29 18:46:11 +00:00
linux uaccess: Add speculation barrier to copy_from_user() 2023-02-21 14:45:22 -08:00
math-emu
media
memory
misc
net dccp/tcp: Avoid negative sk_forward_alloc by ipv6_pinfo.pktoptions. 2023-02-10 19:53:42 -08:00
pcmcia
ras
rdma
rv
scsi scsi: iscsi_tcp: Fix UAF during logout when accessing the shost ipaddress 2023-01-18 19:14:56 -05:00
soc
sound ASoC: samsung: remove unused drivers 2023-01-16 09:26:06 +01:00
target
trace Scheduler updates in this cycle are: 2023-02-20 17:41:08 -08:00
uapi hardening updates for v6.3-rc1 2023-02-21 11:07:23 -08:00
ufs scsi: ufs: core: Fix devfreq deadlocks 2023-01-18 19:08:37 -05:00
vdso vdso/bits.h: Add BIT_ULL() for the sake of consistency 2023-01-31 14:42:10 +01:00
video fbdev: remove w100fb driver 2023-02-01 17:23:38 +01:00
xen