Subject: CVE-2020-36788: drm/nouveau: avoid a use-after-free when BO init fails

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

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

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

drm/nouveau: avoid a use-after-free when BO init fails

nouveau_bo_init() is backed by ttm_bo_init() and ferries its return code
back to the caller. On failures, ttm_bo_init() invokes the provided
destructor which should de-initialize and free the memory.

Thus, when nouveau_bo_init() returns an error the gem object has already
been released and the memory freed by nouveau_bo_del_ttm().

The Linux kernel CVE team has assigned CVE-2020-36788 to this issue.

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

	Issue introduced in 5.4 with commit 019cbd4a4feb and fixed in 5.10.73 with commit f86e19d918a8
	Issue introduced in 5.4 with commit 019cbd4a4feb and fixed in 5.14.12 with commit 548f2ff8ea5e
	Issue introduced in 5.4 with commit 019cbd4a4feb and fixed in 5.15 with commit bcf34aa5082e

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-2020-36788
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/nouveau/nouveau_gem.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/f86e19d918a85492ad1a01fcdc0ad5ecbdac6f96
	https://git.kernel.org/stable/c/548f2ff8ea5e0ce767ae3418d1ec5308990be87d
	https://git.kernel.org/stable/c/bcf34aa5082ee2343574bc3f4d1c126030913e54