Subject: CVE-2021-47048: spi: spi-zynqmp-gqspi: fix use-after-free in zynqmp_qspi_exec_op

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

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

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

spi: spi-zynqmp-gqspi: fix use-after-free in zynqmp_qspi_exec_op

When handling op->addr, it is using the buffer "tmpbuf" which has been
freed. This will trigger a use-after-free KASAN warning. Let's use
temporary variables to store op->addr.val and op->cmd.opcode to fix
this issue.

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

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

	Issue introduced in 5.10 with commit 1c26372e5aa9 and fixed in 5.10.37 with commit 1231279389b5
	Issue introduced in 5.10 with commit 1c26372e5aa9 and fixed in 5.11.21 with commit d67e0d6bd92e
	Issue introduced in 5.10 with commit 1c26372e5aa9 and fixed in 5.12.4 with commit 23269ac9f123
	Issue introduced in 5.10 with commit 1c26372e5aa9 and fixed in 5.13 with commit a2c5bedb2d55

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-47048
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:
	drivers/spi/spi-zynqmp-gqspi.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/1231279389b5e638bc3b66b9741c94077aed4b5a
	https://git.kernel.org/stable/c/d67e0d6bd92ebbb0294e7062bbf5cdc773764e62
	https://git.kernel.org/stable/c/23269ac9f123eca3aea7682d3345c02e71ed696c
	https://git.kernel.org/stable/c/a2c5bedb2d55dd27c642c7b9fb6886d7ad7bdb58