Subject: CVE-2021-47166: NFS: Don't corrupt the value of pg_bytes_written in nfs_do_recoalesce()

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

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

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

NFS: Don't corrupt the value of pg_bytes_written in nfs_do_recoalesce()

The value of mirror->pg_bytes_written should only be updated after a
successful attempt to flush out the requests on the list.

The Linux kernel CVE team has assigned CVE-2021-47166 to this issue.

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

	Issue introduced in 4.0 with commit a7d42ddb3099 and fixed in 4.4.271 with commit e8b8418ce14a
	Issue introduced in 4.0 with commit a7d42ddb3099 and fixed in 4.9.271 with commit b291baae24f8
	Issue introduced in 4.0 with commit a7d42ddb3099 and fixed in 4.14.235 with commit c757c1f1e65d
	Issue introduced in 4.0 with commit a7d42ddb3099 and fixed in 4.19.193 with commit 40f139a6d50c
	Issue introduced in 4.0 with commit a7d42ddb3099 and fixed in 5.4.124 with commit 785917316b25
	Issue introduced in 4.0 with commit a7d42ddb3099 and fixed in 5.10.42 with commit 7087db95c0a0
	Issue introduced in 4.0 with commit a7d42ddb3099 and fixed in 5.12.9 with commit 2fe1cac336b5
	Issue introduced in 4.0 with commit a7d42ddb3099 and fixed in 5.13 with commit 0d0ea309357d

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-2021-47166
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/nfs/pagelist.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/e8b8418ce14ae66ee55179901edd12191ab06a9e
	https://git.kernel.org/stable/c/b291baae24f876acd5a5dd57d0bb2bbac8a68b0c
	https://git.kernel.org/stable/c/c757c1f1e65d89429db1409429436cf40d47c008
	https://git.kernel.org/stable/c/40f139a6d50c232c0d1fd1c5e65a845c62db0ede
	https://git.kernel.org/stable/c/785917316b25685c9b3a2a88f933139f2de75e33
	https://git.kernel.org/stable/c/7087db95c0a06ab201b8ebfac6a7ec1e34257997
	https://git.kernel.org/stable/c/2fe1cac336b55a1f79e603e9ce3552c3623e90eb
	https://git.kernel.org/stable/c/0d0ea309357dea0d85a82815f02157eb7fcda39f