No description
Find a file
Ali Saidi 84a24bf8c5 locking/qrwlock: Fix ordering in queued_write_lock_slowpath()
While this code is executed with the wait_lock held, a reader can
acquire the lock without holding wait_lock.  The writer side loops
checking the value with the atomic_cond_read_acquire(), but only truly
acquires the lock when the compare-and-exchange is completed
successfully which isn’t ordered. This exposes the window between the
acquire and the cmpxchg to an A-B-A problem which allows reads
following the lock acquisition to observe values speculatively before
the write lock is truly acquired.

We've seen a problem in epoll where the reader does a xchg while
holding the read lock, but the writer can see a value change out from
under it.

  Writer                                | Reader
  --------------------------------------------------------------------------------
  ep_scan_ready_list()                  |
  |- write_lock_irq()                   |
      |- queued_write_lock_slowpath()   |
	|- atomic_cond_read_acquire()   |
				        | read_lock_irqsave(&ep->lock, flags);
     --> (observes value before unlock) |  chain_epi_lockless()
     |                                  |    epi->next = xchg(&ep->ovflist, epi);
     |                                  | read_unlock_irqrestore(&ep->lock, flags);
     |                                  |
     |     atomic_cmpxchg_relaxed()     |
     |-- READ_ONCE(ep->ovflist);        |

A core can order the read of the ovflist ahead of the
atomic_cmpxchg_relaxed(). Switching the cmpxchg to use acquire
semantics addresses this issue at which point the atomic_cond_read can
be switched to use relaxed semantics.

Fixes: b519b56e37 ("locking/qrwlock: Use atomic_cond_read_acquire() when spinning in qrwlock")
Signed-off-by: Ali Saidi <alisaidi@amazon.com>
[peterz: use try_cmpxchg()]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Steve Capper <steve.capper@arm.com>
Acked-by: Will Deacon <will@kernel.org>
Acked-by: Waiman Long <longman@redhat.com>
Tested-by: Steve Capper <steve.capper@arm.com>
2021-04-17 13:40:50 +02:00
arch - Fix the vDSO exception handling return path to disable interrupts 2021-04-11 11:42:18 -07:00
block
certs
crypto
Documentation Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2021-04-10 09:10:55 -07:00
drivers - Fix the vDSO exception handling return path to disable interrupts 2021-04-11 11:42:18 -07:00
fs for-5.12-rc6-tag 2021-04-11 11:53:36 -07:00
include Merge branch 'akpm' (patches from Andrew) 2021-04-09 17:06:32 -07:00
init
ipc
kernel locking/qrwlock: Fix ordering in queued_write_lock_slowpath() 2021-04-17 13:40:50 +02:00
lib lib: fix kconfig dependency on ARCH_WANT_FRAME_POINTERS 2021-04-09 14:54:23 -07:00
LICENSES
mm Merge branch 'for-5.12-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/dennis/percpu 2021-04-10 12:51:12 -07:00
net net: fix hangup on napi_disable for threaded napi 2021-04-09 12:50:31 -07:00
samples
scripts
security selinux/stable-5.12 PR 20210409 2021-04-09 11:51:06 -07:00
sound
tools perf tools fixes for v5.12: 3rd batch 2021-04-09 17:12:31 -07:00
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap .mailmap: fix old email addresses 2021-04-09 14:54:23 -07:00
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS Merge branch 'akpm' (patches from Andrew) 2021-04-09 17:06:32 -07:00
Makefile Linux 5.12-rc7 2021-04-11 15:16:13 -07:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.