Subject: CVE-2024-27400: drm/amdgpu: once more fix the call oder in amdgpu_ttm_move() v2

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

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

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

drm/amdgpu: once more fix the call oder in amdgpu_ttm_move() v2

This reverts drm/amdgpu: fix ftrace event amdgpu_bo_move always move
on same heap. The basic problem here is that after the move the old
location is simply not available any more.

Some fixes were suggested, but essentially we should call the move
notification before actually moving things because only this way we have
the correct order for DMA-buf and VM move notifications as well.

Also rework the statistic handling so that we don't update the eviction
counter before the move.

v2: add missing NULL check

The Linux kernel CVE team has assigned CVE-2024-27400 to this issue.

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

	Issue introduced in 6.1.77 with commit d443fb67ca5a and fixed in 6.1.91 with commit 5c25b169f9a0
	Issue introduced in 6.6.16 with commit e7a0ee45c653 and fixed in 6.6.31 with commit 0c7ed3ed35ee
	Issue introduced in 6.8 with commit 94aeb4117343 and fixed in 6.8.10 with commit 9a4f6e138720
	Issue introduced in 6.8 with commit 94aeb4117343 and fixed in 6.9 with commit d3a9331a6591
	Issue introduced in 5.15.149 with commit 77bcd4ab446f
	Issue introduced in 6.7.4 with commit 1cd2b612474c

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-2024-27400
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/amdgpu/amdgpu_object.c
	drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
	drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.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/5c25b169f9a0b34ee410891a96bc9d7b9ed6f9be
	https://git.kernel.org/stable/c/0c7ed3ed35eec9138b88d42217b5a6b9a62bda4d
	https://git.kernel.org/stable/c/9a4f6e138720b6e9adf7b82a71d0292f3f276480
	https://git.kernel.org/stable/c/d3a9331a6591e9df64791e076f6591f440af51c3