locking/rwsem: Fix kernel crash when spinning on RWSEM_OWNER_UNKNOWN
authorWaiman Long <longman@redhat.com>
Wed, 15 Jan 2020 15:43:36 +0000 (10:43 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Jan 2020 07:22:37 +0000 (08:22 +0100)
commit710d9fd2f48bdd7e9944ea58d2205934951e7336
treeb7dc252113c72096a452987a8e8ef7b782966053
parent4e80eb337cb403bfef3f65b26020dd6a11bda1d8
locking/rwsem: Fix kernel crash when spinning on RWSEM_OWNER_UNKNOWN

commit 39e7234f00bc93613c086ae42d852d5f4147120a upstream.

The commit 91d2a812dfb9 ("locking/rwsem: Make handoff writer
optimistically spin on owner") will allow a recently woken up waiting
writer to spin on the owner. Unfortunately, if the owner happens to be
RWSEM_OWNER_UNKNOWN, the code will incorrectly spin on it leading to a
kernel crash. This is fixed by passing the proper non-spinnable bits
to rwsem_spin_on_owner() so that RWSEM_OWNER_UNKNOWN will be treated
as a non-spinnable target.

Fixes: 91d2a812dfb9 ("locking/rwsem: Make handoff writer optimistically spin on owner")

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Christoph Hellwig <hch@lst.de>
Cc: stable@vger.kernel.org
Link: https://lkml.kernel.org/r/20200115154336.8679-1-longman@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/locking/rwsem.c