Subject: CVE-2023-52825: drm/amdkfd: Fix a race condition of vram buffer unref in svm code

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

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

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

drm/amdkfd: Fix a race condition of vram buffer unref in svm code

prange->svm_bo unref can happen in both mmu callback and a callback after
migrate to system ram. Both are async call in different tasks. Sync svm_bo
unref operation to avoid random "use-after-free".

The Linux kernel CVE team has assigned CVE-2023-52825 to this issue.

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

	Fixed in 5.15.140 with commit 7d43cdd22cd8
	Fixed in 6.1.64 with commit 50f35a907c4f
	Fixed in 6.5.13 with commit c772eacbd6d0
	Fixed in 6.6.3 with commit fc0210720127
	Fixed in 6.7 with commit 709c34826161

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-2023-52825
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/gpu/drm/amd/amdkfd/kfd_svm.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/7d43cdd22cd81a2b079e864c4321b9aba4c6af34
	https://git.kernel.org/stable/c/50f35a907c4f9ed431fd3dbb8b871ef1cbb0718e
	https://git.kernel.org/stable/c/c772eacbd6d0845fc922af8716bb9d29ae27b8cf
	https://git.kernel.org/stable/c/fc0210720127cc6302e6d6f3de48f49c3fcf5659
	https://git.kernel.org/stable/c/709c348261618da7ed89d6c303e2ceb9e453ba74