]> git.ipfire.org Git - people/arne_f/kernel.git/commit
arm64: swp emulation: bound LL/SC retries before rescheduling
authorWill Deacon <will.deacon@arm.com>
Mon, 4 Jul 2016 15:59:43 +0000 (16:59 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 28 Oct 2016 07:45:29 +0000 (03:45 -0400)
commit44870b14a4b3fe0dba53858ba55851c7856847c3
tree62c865f7f9b7f2a1844161c626c29a6487cb3e18
parent5e09db27f6d63095ca42c67c903c8a31174cb603
arm64: swp emulation: bound LL/SC retries before rescheduling

commit 1c5b51dfb7b4564008e0cadec5381a69e88b0d21 upstream.

If a CPU does not implement a global monitor for certain memory types,
then userspace can attempt a kernel DoS by issuing SWP instructions
targetting the problematic memory (for example, a framebuffer mapped
with non-cacheable attributes).

The SWP emulation code protects against these sorts of attacks by
checking for pending signals and potentially rescheduling when the STXR
instruction fails during the emulation. Whilst this is good for avoiding
livelock, it harms emulation of legitimate SWP instructions on CPUs
where forward progress is not guaranteed if there are memory accesses to
the same reservation granule (up to 2k) between the failing STXR and
the retry of the LDXR.

This patch solves the problem by retrying the STXR a bounded number of
times (4) before breaking out of the LL/SC loop and looking for
something else to do.

Fixes: bd35a4adc413 ("arm64: Port SWP/SWPB emulation support from arm")
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/kernel/armv8_deprecated.c