]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
dm bufio: use the acquire memory barrier when testing for B_READING
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 18 Oct 2022 14:06:45 +0000 (10:06 -0400)
committerMike Snitzer <snitzer@kernel.org>
Tue, 18 Oct 2022 16:38:16 +0000 (12:38 -0400)
commit141b3523e9be6f15577acf4bbc3bc1f82d81d6d1
tree66e3b3ea3e39a1d3f818d4de600e5e2546eb9bf3
parentbb1a1146467ad812bb65440696df0782e2bc63c8
dm bufio: use the acquire memory barrier when testing for B_READING

The function test_bit doesn't provide any memory barrier. It may be
possible that the read requests that follow test_bit(B_READING, &b->state)
are reordered before the test, reading invalid data that existed before
B_READING was cleared.

Fix this bug by changing test_bit to test_bit_acquire. This is
particularly important on arches with weak(er) memory ordering
(e.g. arm64).

Depends-On: 8238b4579866 ("wait_on_bit: add an acquire memory barrier")
Depends-On: d6ffe6067a54 ("provide arch_test_bit_acquire for architectures that define test_bit")
Cc: stable@vger.kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
drivers/md/dm-bufio.c