Subject: CVE-2021-47351: ubifs: Fix races between xattr_{set|get} and listxattr operations

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

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

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

ubifs: Fix races between xattr_{set|get} and listxattr operations

UBIFS may occur some problems with concurrent xattr_{set|get} and
listxattr operations, such as assertion failure, memory corruption,
stale xattr value[1].

Fix it by importing a new rw-lock in @ubifs_inode to serilize write
operations on xattr, concurrent read operations are still effective,
just like ext4.

[1] https://lore.kernel.org/linux-mtd/[email-masked]

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

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

	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 5.4.133 with commit 7adc05b73d91
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 5.10.51 with commit 38dde03eb239
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 5.12.18 with commit 9558612cb829
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 5.13.3 with commit c0756f75c221
	Issue introduced in 2.6.27 with commit 1e51764a3c2a and fixed in 5.14 with commit f4e3634a3b64

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-47351
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/super.c
	fs/ubifs/ubifs.h
	fs/ubifs/xattr.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/7adc05b73d91a5e3d4ca7714fa53ad9b70c53d08
	https://git.kernel.org/stable/c/38dde03eb239605f428f3f1e4baa73d4933a4cc6
	https://git.kernel.org/stable/c/9558612cb829f2c022b788f55d6b8437d5234a82
	https://git.kernel.org/stable/c/c0756f75c22149d20fcb7d8409827cee905eb386
	https://git.kernel.org/stable/c/f4e3634a3b642225a530c292fdb1e8a4007507f5