]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
arm64: spinlock: Fix theoretical trylock() A-B-A with LSE atomics
authorWill Deacon <will.deacon@arm.com>
Wed, 31 Jan 2018 12:12:20 +0000 (12:12 +0000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 6 Jun 2018 17:44:25 +0000 (13:44 -0400)
commiteef45aab585ff1b0bd8a72e97171ab01e5abdf0e
tree89cb25e65d3024f7eab6e3baba4b09f3d790b903
parente0a15058897d5953a257f879459b369dc73a2eb6
arm64: spinlock: Fix theoretical trylock() A-B-A with LSE atomics

BugLink: http://bugs.launchpad.net/bugs/1774063
[ Upstream commit 202fb4ef81e3ec765c23bd1e6746a5c25b797d0e ]

If the spinlock "next" ticket wraps around between the initial LDR
and the cmpxchg in the LSE version of spin_trylock, then we can erroneously
think that we have successfuly acquired the lock because we only check
whether the next ticket return by the cmpxchg is equal to the owner ticket
in our updated lock word.

This patch fixes the issue by performing a full 32-bit check of the lock
word when trying to determine whether or not the CASA instruction updated
memory.

Reported-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/arm64/include/asm/spinlock.h