Subject: CVE-2023-52485: drm/amd/display: Wake DMCUB before sending a command

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

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

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

drm/amd/display: Wake DMCUB before sending a command

[Why]
We can hang in place trying to send commands when the DMCUB isn't
powered on.

[How]
For functions that execute within a DC context or DC lock we can
wrap the direct calls to dm_execute_dmub_cmd/list with code that
exits idle power optimizations and reallows once we're done with
the command submission on success.

For DM direct submissions the DM will need to manage the enter/exit
sequencing manually.

We cannot invoke a DMCUB command directly within the DM execution
helper or we can deadlock.

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

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

	Fixed in 6.7.3 with commit 303197775a97
	Fixed in 6.8 with commit 8892780834ae

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-52485
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/display/amdgpu_dm/amdgpu_dm.c
	drivers/gpu/drm/amd/display/dc/bios/command_table2.c
	drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
	drivers/gpu/drm/amd/display/dc/clk_mgr/dcn314/dcn314_clk_mgr.c
	drivers/gpu/drm/amd/display/dc/clk_mgr/dcn315/dcn315_clk_mgr.c
	drivers/gpu/drm/amd/display/dc/clk_mgr/dcn316/dcn316_clk_mgr.c
	drivers/gpu/drm/amd/display/dc/clk_mgr/dcn35/dcn35_clk_mgr.c
	drivers/gpu/drm/amd/display/dc/core/dc.c
	drivers/gpu/drm/amd/display/dc/core/dc_hw_sequencer.c
	drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
	drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h
	drivers/gpu/drm/amd/display/dc/dc_helper.c
	drivers/gpu/drm/amd/display/dc/dce/dmub_abm_lcd.c
	drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.c
	drivers/gpu/drm/amd/display/dc/dce/dmub_outbox.c
	drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c
	drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
	drivers/gpu/drm/amd/display/dc/dcn31/dcn31_dio_link_encoder.c
	drivers/gpu/drm/amd/display/dc/dcn31/dcn31_panel_cntl.c
	drivers/gpu/drm/amd/display/dc/hwss/dcn21/dcn21_hwseq.c
	drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c
	drivers/gpu/drm/amd/display/dc/hwss/dcn31/dcn31_hwseq.c
	drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c
	drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_capability.c
	drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_dpia.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/303197775a97416b62d4da69280d0c120a20e009
	https://git.kernel.org/stable/c/8892780834ae294bc3697c7d0e056d7743900b39