Subject: CVE-2024-35821: ubifs: Set page uptodate in the correct place

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

ubifs: Set page uptodate in the correct place

Page cache reads are lockless, so setting the freshly allocated page
uptodate before we've overwritten it with the data it's supposed to have
in it will allow a simultaneous reader to see old data.  Move the call
to SetPageUptodate into ubifs_write_end(), which is after we copied the
new data into the page.

The Linux kernel CVE team has assigned CVE-2024-35821 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 4.19.312 with commit 4aa554832b9d
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 5.4.274 with commit 778c6ad40256
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 5.10.215 with commit 8f599ab6fabb
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 5.15.154 with commit f19b1023a375
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 6.1.84 with commit 142d87c958d9
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 6.6.24 with commit fc99f4e2d2f1
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 6.7.12 with commit 4b7c4fc60d6a
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 6.8.3 with commit 17772bbe9cfa
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 6.9 with commit 723012cab779

Please see https://www.kernel.org for a full list of currently supported
kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to
older supported kernel versions.  The official CVE entry at
	https://cve.org/CVERecord/?id=CVE-2024-35821
will be updated if fixes are backported, please check that for the most
up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
	fs/ubifs/file.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest
stable kernel version for this, and many other bugfixes.  Individual
changes are never tested alone, but rather are part of a larger kernel
release.  Cherry-picking individual commits is not recommended or
supported by the Linux kernel community at all.  If however, updating to
the latest release is impossible, the individual changes to resolve this
issue can be found at these commits:
	https://git.kernel.org/stable/c/4aa554832b9dc9e66249df75b8f447d87853e12e
	https://git.kernel.org/stable/c/778c6ad40256f1c03244fc06d7cdf71f6b5e7310
	https://git.kernel.org/stable/c/8f599ab6fabbca4c741107eade70722a98adfd9f
	https://git.kernel.org/stable/c/f19b1023a3758f40791ec166038d6411c8894ae3
	https://git.kernel.org/stable/c/142d87c958d9454c3cffa625fab56f3016e8f9f3
	https://git.kernel.org/stable/c/fc99f4e2d2f1ce766c14e98463c2839194ae964f
	https://git.kernel.org/stable/c/4b7c4fc60d6a46350fbe54f5dc937aeaa02e675e
	https://git.kernel.org/stable/c/17772bbe9cfa972ea1ff827319f6e1340de76566
	https://git.kernel.org/stable/c/723012cab779eee8228376754e22c6594229bf8f