Subject: CVE-2021-47066: async_xor: increase src_offs when dropping destination page

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

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

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

async_xor: increase src_offs when dropping destination page

Now we support sharing one page if PAGE_SIZE is not equal stripe size. To
support this, it needs to support calculating xor value with different
offsets for each r5dev. One offset array is used to record those offsets.

In RMW mode, parity page is used as a source page. It sets
ASYNC_TX_XOR_DROP_DST before calculating xor value in ops_run_prexor5.
So it needs to add src_list and src_offs at the same time. Now it only
needs src_list. So the xor value which is calculated is wrong. It can
cause data corruption problem.

I can reproduce this problem 100% on a POWER8 machine. The steps are:

  mdadm -CR /dev/md0 -l5 -n3 /dev/sdb1 /dev/sdc1 /dev/sdd1 --size=3G
  mkfs.xfs /dev/md0
  mount /dev/md0 /mnt/test
  mount: /mnt/test: mount(2) system call failed: Structure needs cleaning.

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

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

	Issue introduced in 5.10 with commit 29bcff787a25 and fixed in 5.10.37 with commit cab2e8e5997b
	Issue introduced in 5.10 with commit 29bcff787a25 and fixed in 5.11.21 with commit 29ffa50f33de
	Issue introduced in 5.10 with commit 29bcff787a25 and fixed in 5.12.4 with commit 53f8208e11ab
	Issue introduced in 5.10 with commit 29bcff787a25 and fixed in 5.13 with commit ceaf2966ab08

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-47066
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:
	crypto/async_tx/async_xor.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/cab2e8e5997b592fdb7d02cf2387b4b8e3057174
	https://git.kernel.org/stable/c/29ffa50f33de824b5491f8239c88c4a0efdd03af
	https://git.kernel.org/stable/c/53f8208e11abd6dde9480dfcb97fecdb1bc2ac18
	https://git.kernel.org/stable/c/ceaf2966ab082bbc4d26516f97b3ca8a676e2af8