linux-stable/include
Mikulas Patocka b437275e89 add barriers to buffer_uptodate and set_buffer_uptodate
commit d4252071b9 upstream.

Let's have a look at this piece of code in __bread_slow:

	get_bh(bh);
	bh->b_end_io = end_buffer_read_sync;
	submit_bh(REQ_OP_READ, 0, bh);
	wait_on_buffer(bh);
	if (buffer_uptodate(bh))
		return bh;

Neither wait_on_buffer nor buffer_uptodate contain any memory barrier.
Consequently, if someone calls sb_bread and then reads the buffer data,
the read of buffer data may be executed before wait_on_buffer(bh) on
architectures with weak memory ordering and it may return invalid data.

Fix this bug by adding a memory barrier to set_buffer_uptodate and an
acquire barrier to buffer_uptodate (in a similar way as
folio_test_uptodate and folio_mark_uptodate).

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-08-17 14:22:46 +02:00
..
acpi ACPICA: actypes.h: Expand the ACPI_ACCESS_ definitions 2022-01-27 11:04:49 +01:00
asm-generic asm-generic: remove a broken and needless ifdef conditional 2022-08-03 12:03:42 +02:00
clocksource
crypto crypto: drbg - make reseeding from get_random_bytes() synchronous 2022-06-06 08:43:38 +02:00
drm drm: fix EDID struct for old ARM OABI format 2022-06-09 10:22:44 +02:00
dt-bindings
keys
kunit
kvm
linux add barriers to buffer_uptodate and set_buffer_uptodate 2022-08-17 14:22:46 +02:00
math-emu
media media: cec: fix a deadlock situation 2022-01-27 11:02:53 +01:00
memory memory: renesas-rpc-if: Fix HF/OSPI data transfer in Manual Mode 2022-05-09 09:14:34 +02:00
misc
net net: Fix data-races around sysctl_[rw]mem(_offset)?. 2022-08-03 12:03:51 +02:00
pcmcia
ras Revert "mm/memory-failure.c: fix race with changing page compound again" 2022-07-12 16:35:17 +02:00
rdma RDMA/netlink: Add __maybe_unused to static inline in C file 2021-11-25 09:49:07 +01:00
scsi scsi: fcoe: Fix Wstringop-overflow warnings in fcoe_wwn_from_mac() 2022-06-09 10:23:07 +02:00
soc
sound ALSA: jack: Access input_dev under mutex 2022-06-09 10:22:32 +02:00
target scsi: target: Fix ordered tag handling 2021-11-25 09:48:29 +01:00
trace net: ipv4: use kfree_skb_reason() in ip_rcv_finish_core() 2022-07-29 17:25:16 +02:00
uapi uapi/linux/stddef.h: Add include guards 2022-07-12 16:35:03 +02:00
vdso
video video: of_display_timing.h: include errno.h 2022-07-12 16:35:10 +02:00
xen xen/gnttab: fix gnttab_end_foreign_access() without page specified 2022-03-11 12:22:37 +01:00