linux-stable/arch/arm64
Will Deacon 045afc2412 arm64: futex: Fix FUTEX_WAKE_OP atomic ops with non-zero result value
Rather embarrassingly, our futex() FUTEX_WAKE_OP implementation doesn't
explicitly set the return value on the non-faulting path and instead
leaves it holding the result of the underlying atomic operation. This
means that any FUTEX_WAKE_OP atomic operation which computes a non-zero
value will be reported as having failed. Regrettably, I wrote the buggy
code back in 2011 and it was upstreamed as part of the initial arm64
support in 2012.

The reasons we appear to get away with this are:

  1. FUTEX_WAKE_OP is rarely used and therefore doesn't appear to get
     exercised by futex() test applications

  2. If the result of the atomic operation is zero, the system call
     behaves correctly

  3. Prior to version 2.25, the only operation used by GLIBC set the
     futex to zero, and therefore worked as expected. From 2.25 onwards,
     FUTEX_WAKE_OP is not used by GLIBC at all.

Fix the implementation by ensuring that the return value is either 0
to indicate that the atomic operation completed successfully, or -EFAULT
if we encountered a fault when accessing the user mapping.

Cc: <stable@kernel.org>
Fixes: 6170a97460 ("arm64: Atomic operations")
Signed-off-by: Will Deacon <will.deacon@arm.com>
2019-04-12 15:04:33 +01:00
..
boot Fixes for dtc warnings, fixes for ethernet transfers on rk3328, 2019-04-07 15:15:31 -07:00
configs Allwinner arm64 defconfig changes for 5.1 2019-02-15 16:51:26 +01:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2019-03-05 09:09:55 -08:00
include arm64: futex: Fix FUTEX_WAKE_OP atomic ops with non-zero result value 2019-04-12 15:04:33 +01:00
kernel arm64: backtrace: Don't bother trying to unwind the userspace stack 2019-04-08 18:05:24 +01:00
kvm KVM: arm64: Reset the PMU in preemptible context 2019-03-19 17:56:24 +00:00
lib arm64: string: use asm EXPORT_SYMBOL() 2018-12-10 11:50:12 +00:00
mm treewide: add checks for the return value of memblock_alloc*() 2019-03-12 10:04:02 -07:00
net arm64: bpf: implement jitting of JMP32 2019-01-26 13:33:02 -08:00
xen
Kconfig arm64: remove obsolete selection of MULTI_IRQ_HANDLER 2019-03-20 17:34:16 +00:00
Kconfig.debug
Kconfig.platforms This pull request brings in a build fix for arm64 with bcm2835 2019-03-18 10:31:24 -07:00
Makefile kasan, arm64: adjust shadow size for tag-based mode 2018-12-28 12:11:43 -08:00