linux-stable/drivers/soc
Johan Hovold 2bbd65c6ca soc: qcom: pmic_glink_altmode: fix drm bridge use-after-free
commit b979f2d50a upstream.

A recent DRM series purporting to simplify support for "transparent
bridges" and handling of probe deferrals ironically exposed a
use-after-free issue on pmic_glink_altmode probe deferral.

This has manifested itself as the display subsystem occasionally failing
to initialise and NULL-pointer dereferences during boot of machines like
the Lenovo ThinkPad X13s.

Specifically, the dp-hpd bridge is currently registered before all
resources have been acquired which means that it can also be
deregistered on probe deferrals.

In the meantime there is a race window where the new aux bridge driver
(or PHY driver previously) may have looked up the dp-hpd bridge and
stored a (non-reference-counted) pointer to the bridge which is about to
be deallocated.

When the display controller is later initialised, this triggers a
use-after-free when attaching the bridges:

	dp -> aux -> dp-hpd (freed)

which may, for example, result in the freed bridge failing to attach:

	[drm:drm_bridge_attach [drm]] *ERROR* failed to attach bridge /soc@0/phy@88eb000 to encoder TMDS-31: -16

or a NULL-pointer dereference:

	Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
	...
	Call trace:
	  drm_bridge_attach+0x70/0x1a8 [drm]
	  drm_aux_bridge_attach+0x24/0x38 [aux_bridge]
	  drm_bridge_attach+0x80/0x1a8 [drm]
	  dp_bridge_init+0xa8/0x15c [msm]
	  msm_dp_modeset_init+0x28/0xc4 [msm]

The DRM bridge implementation is clearly fragile and implicitly built on
the assumption that bridges may never go away. In this case, the fix is
to move the bridge registration in the pmic_glink_altmode driver to
after all resources have been looked up.

Incidentally, with the new dp-hpd bridge implementation, which registers
child devices, this is also a requirement due to a long-standing issue
in driver core that can otherwise lead to a probe deferral loop (see
commit fbc35b45f9 ("Add documentation on meaning of -EPROBE_DEFER")).

[DB: slightly fixed commit message by adding the word 'commit']
Fixes: 080b4e2485 ("soc: qcom: pmic_glink: Introduce altmode support")
Fixes: 2bcca96abf ("soc: qcom: pmic-glink: switch to DRM_AUX_HPD_BRIDGE")
Cc: <stable@vger.kernel.org>      # 6.3
Cc: Bjorn Andersson <andersson@kernel.org>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Reviewed-by: Bjorn Andersson <andersson@kernel.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20240217150228.5788-4-johan+linaro@kernel.org
[ johan: backport to 6.7 which does not have DRM aux bridge ]
Signed-off-by: Johan Hovold <johan+linaro@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:19:09 -04:00
..
actions genpd: move owl-sps-helper.c from drivers/soc 2023-07-26 14:41:01 +02:00
amlogic soc: amlogic: Explicitly include correct DT includes 2023-08-04 15:18:42 +02:00
apple soc: apple: Move power-domain driver to the genpd dir 2023-07-11 15:30:09 +02:00
aspeed ARM: SoC cleanups for 6.6 2023-08-30 16:49:40 -07:00
atmel soc: microchip: Explicitly include correct DT includes 2023-07-29 16:54:29 +03:00
bcm soc: bcm: Move power-domain drivers to the genpd dir 2023-07-11 15:30:09 +02:00
canaan soc: canaan: Make K210_SYSCTL depend on CLK_K210 2023-03-15 14:22:53 +00:00
dove
fsl soc: fsl: cpm1: qmc: Fix rx channel reset 2024-01-31 16:18:51 -08:00
fujitsu soc: fujitsu: remove MODULE_LICENSE in non-modules 2023-04-13 13:13:50 -07:00
gemini
hisilicon soc: kunpeng_hccs: fix some sparse warnings about incorrect type 2023-08-21 21:05:11 -04:00
imx soc: imx8m: Enable OCOTP clock for imx8mm before reading registers 2023-09-24 20:50:27 +08:00
ixp4xx
lantiq
litex
loongson soc: loongson: loongson2_guts: Remove unneeded semicolon 2023-09-27 11:05:47 +02:00
mediatek ARM: SoC cleanups for 6.6 2023-08-30 16:49:40 -07:00
microchip soc: microchip: Explicitly include correct DT includes 2023-07-29 16:54:29 +03:00
nuvoton soc: nuvoton: Add SoC info driver for WPCM450 2023-02-01 17:11:36 +01:00
pxa
qcom soc: qcom: pmic_glink_altmode: fix drm bridge use-after-free 2024-03-26 18:19:09 -04:00
renesas soc: renesas: ARCH_R9A07G043 depends on !RISCV_ISA_ZICBOM 2023-10-26 09:42:38 +02:00
rockchip ARM: SoC cleanups for 6.6 2023-08-30 16:49:40 -07:00
samsung Samsung SoC driver changes for v6.6 2023-08-12 12:09:43 +02:00
sifive
starfive soc: starfive: Move the power-domain driver to the genpd dir 2023-07-14 10:40:56 +02:00
sunxi - simplify code in sunxi-rsb 2023-08-12 12:07:58 +02:00
tegra soc/tegra: Changes for v6.6-rc1 2023-08-12 12:01:51 +02:00
ti TI SoC driver updates for v6.6 2023-08-14 18:26:27 +02:00
ux500
versatile
xilinx soc: xilinx: fix unhandled SGI warning message 2024-02-05 20:14:19 +00:00
Kconfig soc: hisilicon: Support HCCS driver on Kunpeng SoC 2023-08-08 12:36:29 +00:00
Makefile HiSilicon driver updates for v6.6 2023-08-12 12:10:46 +02:00