]> git.baikalelectronics.ru Git - kernel.git/commit
wait_on_bit: add an acquire memory barrier
authorMikulas Patocka <mpatocka@redhat.com>
Fri, 26 Aug 2022 13:17:08 +0000 (09:17 -0400)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 26 Aug 2022 16:30:25 +0000 (09:30 -0700)
commit178c04173a91b9ae0f1fe4a6a7f66d634974b8cd
treea61b3a10f1d6b53bc7c05b08b8b49bb84156ee2e
parentf53f2c211d4a726dafcb1fa45e0829952fc65524
wait_on_bit: add an acquire memory barrier

There are several places in the kernel where wait_on_bit is not followed
by a memory barrier (for example, in drivers/md/dm-bufio.c:new_read).

On architectures with weak memory ordering, it may happen that memory
accesses that follow wait_on_bit are reordered before wait_on_bit and
they may return invalid data.

Fix this class of bugs by introducing a new function "test_bit_acquire"
that works like test_bit, but has acquire memory ordering semantics.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Will Deacon <will@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Documentation/atomic_bitops.txt
arch/x86/include/asm/bitops.h
include/asm-generic/bitops/generic-non-atomic.h
include/asm-generic/bitops/instrumented-non-atomic.h
include/asm-generic/bitops/non-atomic.h
include/asm-generic/bitops/non-instrumented-non-atomic.h
include/linux/bitops.h
include/linux/buffer_head.h
include/linux/wait_bit.h
kernel/sched/wait_bit.c